Better name validation

This commit is contained in:
Lars Brubaker 2022-10-28 18:00:19 -07:00
parent fc2d0bad6b
commit 8cac6069b4

View file

@ -164,14 +164,22 @@ namespace MatterHackers.MatterControl.DesignTools
var currentName = SheetData[x, y].Name;
if (!string.IsNullOrEmpty(currentName))
{
existingNames.Add(currentName);
existingNames.Add(currentName.ToLower());
}
}
}
}
// first replace spaces with '_'
var name = editSelectedName.Text.Replace(' ', '_');
var reservedWords = new string[] { "pi", "e", "true", "false", "round" };
// add all the reserved words to the existing names
foreach (var reservedWord in reservedWords)
{
existingNames.Add(reservedWord);
}
// first replace spaces with '_'
var name = editSelectedName.Text.Replace(' ', '_');
// next make sure we don't have the exact name already
name = agg_basics.GetNonCollidingName(name, existingNames, false);
editSelectedName.Text = name;