more work on import

This commit is contained in:
Lars Brubaker 2016-06-14 12:55:19 -07:00
parent 86a7e7c415
commit b9f92280b3
3 changed files with 85 additions and 3 deletions

View file

@ -81,7 +81,7 @@ namespace MatterHackers.MatterControl
CreateDetailInfo("Add new quality preset with the settings from this import.")
);
// add as materila preset
// add as material preset
var newMaterialPresetButton = new RadioButton("Import settings as new MATERIAL preset".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);
newMaterialPresetButton.CheckedStateChanged += (s, e) => importMode = "materialPreset";
container.AddChild(newMaterialPresetButton);
@ -140,11 +140,64 @@ namespace MatterHackers.MatterControl
break;
case "qualityPreset":
throw new NotImplementedException("import to preset");
ImportToPreset(settingsFilePath);
break;
}
}
private void ImportToPreset(string settingsFilePath)
{
if (!string.IsNullOrEmpty(settingsFilePath) && File.Exists(settingsFilePath))
{
string importType = Path.GetExtension(settingsFilePath).ToLower();
switch (importType)
{
case ".printer":
// open a wizard to ask what to import to the preset
throw new NotImplementedException("need to import from 'MatterControl.printer' files");
break;
case ".ini":
var settingsToImport = SettingsLayer.LoadFromIni(settingsFilePath);
string layerHeight;
bool isSlic3r = settingsToImport.TryGetValue("layer_height", out layerHeight);
if (isSlic3r)
{
// TODO: this should only be the oem and user layer (not the quality or material layer)
var activeSettings = ActiveSliceSettings.Instance;
foreach (var item in settingsToImport)
{
// Compare the value to import to the layer cascade value and only set if different
string currentValue = activeSettings.GetActiveValue(item.Key, null).Trim();
if (currentValue != item.Value)
{
activeSettings.UserLayer[item.Key] = item.Value;
}
}
activeSettings.SaveChanges();
UiThread.RunOnIdle(ApplicationController.Instance.ReloadAdvancedControlsPanel);
}
else
{
// looks like a cura file
throw new NotImplementedException("need to import from 'cure.ini' files");
}
break;
default:
// Did not figure out what this file is, let the user know we don't understand it
StyledMessageBox.ShowMessageBox(null, "Oops! Unable to recognize settings file '{0}'.".Localize().FormatWith(Path.GetFileName(settingsFilePath)), "Unable to Import".Localize());
break;
}
}
Invalidate();
}
private void MergeSettings(string settingsFilePath)
{
if (!string.IsNullOrEmpty(settingsFilePath) && File.Exists(settingsFilePath))
@ -156,6 +209,7 @@ namespace MatterHackers.MatterControl
throw new NotImplementedException("need to import from 'MatterControl.printer' files");
break;
case ".slice": // old presets format
case ".ini":
var settingsToImport = SettingsLayer.LoadFromIni(settingsFilePath);
string layerHeight;
@ -163,6 +217,7 @@ namespace MatterHackers.MatterControl
bool isSlic3r = settingsToImport.TryGetValue("layer_height", out layerHeight);
if (isSlic3r)
{
// TODO: this should only be the oem and user layer (not the quality or material layer)
var activeSettings = ActiveSliceSettings.Instance;
foreach (var item in settingsToImport)

View file

@ -4999,3 +4999,30 @@ Translated:Import Settings
English:Oops! Please select a serial port.
Translated:Oops! Please select a serial port.
English:The layers at which the print will pause, allowing for a change in filament. Leave blank to disable. To pause on multiple layers, separate the layer numbers with semicolons. For example: "16; 37".
Translated:The layers at which the print will pause, allowing for a change in filament. Leave blank to disable. To pause on multiple layers, separate the layer numbers with semicolons. For example: "16; 37".
English:Layers To Pause:
Translated:Layers To Pause:
English:Import Wizard
Translated:Import Wizard
English:Import settings as new QUALITY preset
Translated:Import settings as new QUALITY preset
English:Import settings as new MATERIAL preset
Translated:Import settings as new MATERIAL preset
English:Choose File
Translated:Choose File
English:Export Wizard
Translated:Export Wizard
English:Oops! Unable to recognize settings file '{0}'.
Translated:Oops! Unable to recognize settings file '{0}'.
English:Unable to Import
Translated:Unable to Import

@ -1 +1 @@
Subproject commit a78c996079a66ccfdb6e03cc9c26a41b72aa0164
Subproject commit 592ff542480fc9a0982046486fa1e9264d66ccd9