Fixed import to not rely on layer_height validation
- Import preset no longer checks for slicer and will validate import on weather or not any settigns were valid - calling Import from MenuOptionFIle will cause the same error message as importing a printer form the settings import page - Import to new printer now attempts to load values and validates success on importing a valid setting
This commit is contained in:
parent
89f12946a4
commit
5b42eac301
3 changed files with 41 additions and 38 deletions
|
|
@ -294,25 +294,43 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
break;
|
||||
|
||||
case ".ini":
|
||||
var settingsToImport = PrinterSettingsLayer.LoadFromIni(settingsFilePath);
|
||||
//Other import paths validate that this is a slicer or MC ini file via checking if layer_height is a setting
|
||||
if(settingsToImport.ContainsKey(SettingsKey.layer_height))
|
||||
//Scope variables
|
||||
{
|
||||
var settingsToImport = PrinterSettingsLayer.LoadFromIni(settingsFilePath);
|
||||
var layeredProfile = new PrinterSettings()
|
||||
{
|
||||
ID = printerInfo.ID,
|
||||
OemLayer = settingsToImport
|
||||
};
|
||||
|
||||
// TODO: Resolve name conflicts
|
||||
layeredProfile.UserLayer[SettingsKey.printer_name.ToString()] = printerInfo.Name;
|
||||
bool containsValidSetting = false;
|
||||
var activeSettings = layeredProfile;
|
||||
|
||||
layeredProfile.ClearValue(SettingsKey.device_token);
|
||||
printerInfo.DeviceToken = "";
|
||||
Instance.Profiles.Add(printerInfo);
|
||||
foreach (var item in settingsToImport)
|
||||
{
|
||||
if (activeSettings.Contains(item.Key))
|
||||
{
|
||||
containsValidSetting = true;
|
||||
string currentValue = activeSettings.GetValue(item.Key).Trim();
|
||||
// Compare the value to import to the layer cascade value and only set if different
|
||||
if (currentValue != item.Value)
|
||||
{
|
||||
activeSettings.OemLayer[item.Key] = item.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(containsValidSetting)
|
||||
{
|
||||
// TODO: Resolve name conflicts
|
||||
layeredProfile.UserLayer[SettingsKey.printer_name] = printerInfo.Name;
|
||||
|
||||
layeredProfile.Save();
|
||||
importSuccessful = true;
|
||||
layeredProfile.ClearValue(SettingsKey.device_token);
|
||||
printerInfo.DeviceToken = "";
|
||||
Instance.Profiles.Add(printerInfo);
|
||||
|
||||
layeredProfile.Save();
|
||||
importSuccessful = true;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue