Always set make and model on imported printers

Made the import printer get non-colliding names
MatterHackers/MCCentral#417
MatterControl is unable to upload imported printers
This commit is contained in:
Lars Brubaker 2016-10-04 17:54:57 -07:00
parent cf09c15e2c
commit 231aadc554
7 changed files with 89 additions and 68 deletions

View file

@ -238,24 +238,9 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
string mappedMakeText = printerManufacturerSelector.SelectedLabel;
string printerInputName = string.Format("{0} {1}", mappedMakeText, activeModel);
var names = ProfileManager.Instance.ActiveProfiles.Where(p => p.Name.StartsWith(printerInputName)).Select(p => p.Name).ToList();
if (!names.Contains(printerInputName))
{
printerNameInput.Text = printerInputName;
}
else
{
int printerModelCount = 1; //Used to keep track of how many of the printer models we run into before and empty one
string possiblePrinterName;
do
{
possiblePrinterName = string.Format("{0} ({1})", printerInputName, printerModelCount++);
} while (names.Contains(possiblePrinterName));
printerNameInput.Text = possiblePrinterName;
}
printerInputName = agg_basics.GetNonCollidingName(names, printerInputName);
}
});
}