Unify to single GetNonCollidingName

Improve it to check for and replace numbers
add new calling method
Make sure Object3D Close does not end up modifying object in processes
Don't try to render meshes with no faces
This commit is contained in:
Lars Brubaker 2017-12-06 16:29:31 -08:00
parent c4c945753d
commit 71979e35e9
11 changed files with 78 additions and 87 deletions

View file

@ -161,26 +161,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
};
}
private string GetNonCollidingName(string profileName, IEnumerable<string> existingNames)
{
if (!existingNames.Contains(profileName))
{
return profileName;
}
else
{
int currentIndex = 1;
string possiblePrinterName;
do
{
possiblePrinterName = String.Format("{0} ({1})", profileName, currentIndex++);
} while (existingNames.Contains(possiblePrinterName));
return possiblePrinterName;
}
}
private FlowLayoutWidget GetBottomRow(TextImageButtonFactory buttonFactory)
{
var container = new FlowLayoutWidget()
@ -195,7 +175,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
UiThread.RunOnIdle(() =>
{
string sanitizedName = numberMatch.Replace(presetNameInput.Text, "").Trim();
string newProfileName = GetNonCollidingName(sanitizedName, presetsContext.PresetLayers.Select(preset => preset.ValueOrDefault(SettingsKey.layer_name)));
string newProfileName = agg_basics.GetNonCollidingName(sanitizedName, presetsContext.PresetLayers.Select(preset => preset.ValueOrDefault(SettingsKey.layer_name)));
var clonedLayer = presetsContext.PersistenceLayer.Clone();
clonedLayer.Name = newProfileName;