From 50afeea7dc813bce795141dc2050adb6d473eafb Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 21 Jun 2016 13:48:28 -0700 Subject: [PATCH 1/5] More work on macro test --- Submodules/agg-sharp | 2 +- Tests/MatterControl.Tests/MatterControl/GCodeProcessingTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index bc29582ef..7286b10ef 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit bc29582ef31ff4e1f303377960b9596eeaa861d9 +Subproject commit 7286b10ef420741a1d4015f16204aa7d2d7da30d diff --git a/Tests/MatterControl.Tests/MatterControl/GCodeProcessingTests.cs b/Tests/MatterControl.Tests/MatterControl/GCodeProcessingTests.cs index 38e0049e8..39d723f78 100644 --- a/Tests/MatterControl.Tests/MatterControl/GCodeProcessingTests.cs +++ b/Tests/MatterControl.Tests/MatterControl/GCodeProcessingTests.cs @@ -70,7 +70,7 @@ namespace MatterControl.Tests.MatterControl TestMacroReplacement("{support_material_speed}", "3600"); TestMacroReplacement("{temperature}", "200"); TestMacroReplacement("{z_offset}", "0"); - TestMacroReplacement("[{0}]".FormatWith(SettingsKey.bed_temperature), "70"); + TestMacroReplacement("[" + SettingsKey.bed_temperature + "]", "70"); TestMacroReplacement("{infill_speed}", "3600"); TestMacroReplacement("{min_print_speed}", "600"); TestMacroReplacement("{travel_speed}", "7800"); From 93530a64c155861dc4854528f3ddf26d72baf2ef Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 21 Jun 2016 15:39:18 -0700 Subject: [PATCH 2/5] can merge from .printer into current. --- SetupWizard/ImportSettingsPage.cs | 182 +++++++++++++++++++----------- 1 file changed, 119 insertions(+), 63 deletions(-) diff --git a/SetupWizard/ImportSettingsPage.cs b/SetupWizard/ImportSettingsPage.cs index 58e580834..bb4687f63 100644 --- a/SetupWizard/ImportSettingsPage.cs +++ b/SetupWizard/ImportSettingsPage.cs @@ -42,18 +42,18 @@ namespace MatterHackers.MatterControl { public class SelectPartsOfPrinterToImport : WizardPage { - static string importMessage = "Select the parts of the printer file that you would like to merge into your current profile.".Localize(); + static string importMessage = "Select what you would like to merge into your current profile.".Localize(); string settingsFilePath; - List qualityChecks = new List(); - List materialChecks = new List(); PrinterSettings settingsToImport; + int selectedMaterial = -1; + int selectedQuality = -1; public SelectPartsOfPrinterToImport(string settingsFilePath) : base(unlocalizedTextForTitle: "Import Wizard") { settingsToImport = PrinterSettings.LoadFile(settingsFilePath); - this.headerLabel.Text = "Select Parts to Import".Localize(); + this.headerLabel.Text = "Select What to Import".Localize(); this.settingsFilePath = settingsFilePath; @@ -82,14 +82,14 @@ namespace MatterHackers.MatterControl Margin = new BorderDouble(0, 3, 0, 10), }); - var mainProfileCheckBox = new CheckBox("Printer Profile") + var mainProfileRadioButton = new RadioButton("Printer Profile") { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(5, 0), HAnchor = HAnchor.ParentLeft, Checked = true, }; - container.AddChild(mainProfileCheckBox); + container.AddChild(mainProfileRadioButton); if (settingsToImport.QualityLayers.Count > 0) { @@ -99,15 +99,31 @@ namespace MatterHackers.MatterControl Margin = new BorderDouble(0, 3, 0, 15), }); + int buttonIndex = 0; foreach (var qualitySetting in settingsToImport.QualityLayers) { - qualityChecks.Add(new CheckBox(qualitySetting.Name) + RadioButton qualityButton = new RadioButton(qualitySetting.Name) { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(5, 0, 0, 0), HAnchor = HAnchor.ParentLeft, - }); - container.AddChild(qualityChecks[qualityChecks.Count - 1]); + }; + container.AddChild(qualityButton); + + int localButtonIndex = buttonIndex; + qualityButton.CheckedStateChanged += (s, e) => + { + if (qualityButton.Checked) + { + selectedQuality = localButtonIndex; + } + else + { + selectedQuality = -1; + } + }; + + buttonIndex++; } } @@ -119,34 +135,97 @@ namespace MatterHackers.MatterControl Margin = new BorderDouble(0, 3, 0, 15), }); + int buttonIndex = 0; foreach (var materialSetting in settingsToImport.MaterialLayers) { - materialChecks.Add(new CheckBox(materialSetting.Name) + RadioButton materialButton = new RadioButton(materialSetting.Name) { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(5, 0), HAnchor = HAnchor.ParentLeft, - }); - container.AddChild(materialChecks[materialChecks.Count - 1]); + }; + + container.AddChild(materialButton); + + int localButtonIndex = buttonIndex; + materialButton.CheckedStateChanged += (s, e) => + { + if (materialButton.Checked) + { + selectedMaterial = localButtonIndex; + } + else + { + selectedMaterial = -1; + } + }; + + buttonIndex++; } } var mergeButton = textImageButtonFactory.Generate("Merge".Localize()); mergeButton.Name = "Merge Profile"; - mergeButton.Click += (s, e) => + mergeButton.Click += (s,e) => UiThread.RunOnIdle(Merge); + footerRow.AddChild(mergeButton); + + footerRow.AddChild(new HorizontalSpacer()); + footerRow.AddChild(cancelButton); + + if(settingsToImport.QualityLayers.Count == 0 && settingsToImport.MaterialLayers.Count == 0) { - UiThread.RunOnIdle(() => WizardWindow?.Close()); + // Only main setting so don't ask what to merge just do it. + UiThread.RunOnIdle(Merge); + } + } - var activeSettings = ActiveSliceSettings.Instance; + static string importPrinterSuccessMessage = "Settings have been merged into your current printer.".Localize(); - var layerCascade = new List + HashSet skipKeys = new HashSet + { + "layer_name", + "layer_id", + }; + + void Merge() + { + var activeSettings = ActiveSliceSettings.Instance; + + var layerCascade = new List + { + ActiveSliceSettings.Instance.OemLayer, + ActiveSliceSettings.Instance.BaseLayer, + ActiveSliceSettings.Instance.UserLayer, + }; + + PrinterSettingsLayer layerToImport = settingsToImport.BaseLayer; + if (selectedMaterial > -1) + { + var material = settingsToImport.MaterialLayers[selectedMaterial]; + + foreach(var item in material) { - ActiveSliceSettings.Instance.OemLayer, - ActiveSliceSettings.Instance.BaseLayer, - ActiveSliceSettings.Instance.UserLayer, - }; + if (!skipKeys.Contains(item.Key)) + { + activeSettings.UserLayer[item.Key] = item.Value; + } + } + } + else if (selectedQuality > -1) + { + var quality = settingsToImport.QualityLayers[selectedQuality]; - foreach (var item in settingsToImport.BaseLayer) + foreach (var item in quality) + { + if (!skipKeys.Contains(item.Key)) + { + activeSettings.UserLayer[item.Key] = item.Value; + } + } + } + else + { + foreach (var item in layerToImport) { // Compare the value to import to the layer cascade value and only set if different string currentValue = activeSettings.GetValue(item.Key, layerCascade).Trim(); @@ -156,28 +235,27 @@ namespace MatterHackers.MatterControl activeSettings.UserLayer[item.Key] = item.Value; } } + } - activeSettings.SaveChanges(); + activeSettings.SaveChanges(); - UiThread.RunOnIdle(ApplicationController.Instance.ReloadAdvancedControlsPanel); - }; - footerRow.AddChild(mergeButton); + UiThread.RunOnIdle(ApplicationController.Instance.ReloadAdvancedControlsPanel); - footerRow.AddChild(new HorizontalSpacer()); - footerRow.AddChild(cancelButton); + ProfileManager.ImportFromExisting(settingsFilePath); + WizardWindow.ChangeToPage(new ImportSucceeded(importPrinterSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath))) + { + WizardWindow = this.WizardWindow, + }); } } - public class ImportToPrinterSucceeded : WizardPage + public class ImportSucceeded : WizardPage { - static string successMessage = "You have successfully imported a new printer profile. You can find '{0}' in your list of available printers.".Localize(); - public ImportToPrinterSucceeded(string newProfileName) : + public ImportSucceeded(string successMessage) : base("Done", "Import Wizard") { this.headerLabel.Text = "Import Successful".Localize(); - successMessage = successMessage.FormatWith(newProfileName); - var container = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.ParentLeftRight, @@ -192,34 +270,6 @@ namespace MatterHackers.MatterControl } } - public class ImportToSettingSucceeded : WizardPage - { - static string successMessage = "You have successfully imported a new {0} setting. You can find '{1}' in your list of {2} settings.".Localize(); - string settingType; - - public ImportToSettingSucceeded(string newProfileName, string settingType) : - base("Done", "Import Wizard") - { - this.settingType = settingType; - this.headerLabel.Text = "Import Successful".Localize(); - - successMessage = successMessage.FormatWith(settingType, newProfileName, settingType); - - var container = new FlowLayoutWidget(FlowDirection.TopToBottom) - { - HAnchor = HAnchor.ParentLeftRight, - }; - contentRow.AddChild(container); - - var successMessageWidget = new WrappedTextWidget(successMessage, 10, textColor: ActiveTheme.Instance.PrimaryTextColor); - container.AddChild(successMessageWidget); - - footerRow.AddChild(new HorizontalSpacer()); - footerRow.AddChild(cancelButton); - } - } - - public class ImportSettingsPage : WizardPage { RadioButton newPrinterButton; @@ -344,12 +394,18 @@ namespace MatterHackers.MatterControl return container; } + static string importPrinterSuccessMessage = "You have successfully imported a new printer profile. You can find '{0}' in your list of available printers.".Localize(); + static string importSettingSuccessMessage = "You have successfully imported a new {0} setting. You can find '{1}' in your list of {2} settings.".Localize(); + private void ImportSettingsFile(string settingsFilePath) { if(newPrinterButton.Checked) { ProfileManager.ImportFromExisting(settingsFilePath); - WizardWindow.ChangeToPage(new ImportToPrinterSucceeded(Path.GetFileNameWithoutExtension(settingsFilePath))); + WizardWindow.ChangeToPage(new ImportSucceeded(importPrinterSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath))) + { + WizardWindow = this.WizardWindow, + }); } else if(mergeButton.Checked) { @@ -358,7 +414,7 @@ namespace MatterHackers.MatterControl else if(newQualityPresetButton.Checked) { ImportToPreset(settingsFilePath); - WizardWindow.ChangeToPage(new ImportToSettingSucceeded(Path.GetFileNameWithoutExtension(settingsFilePath), "Quality".Localize()) + WizardWindow.ChangeToPage(new ImportSucceeded(importSettingSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath), "Quality".Localize())) { WizardWindow = this.WizardWindow, }); @@ -366,7 +422,7 @@ namespace MatterHackers.MatterControl else if(newMaterialPresetButton.Checked) { ImportToPreset(settingsFilePath); - WizardWindow.ChangeToPage(new ImportToSettingSucceeded(Path.GetFileNameWithoutExtension(settingsFilePath), "Material".Localize()) + WizardWindow.ChangeToPage(new ImportSucceeded(importSettingSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath), "Material".Localize())) { WizardWindow = this.WizardWindow, }); From 7b1fa6c2020de2cc9fd60a588147c11e4a7f274c Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 21 Jun 2016 15:43:09 -0700 Subject: [PATCH 3/5] start the import to settings. --- SetupWizard/ImportSettingsPage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SetupWizard/ImportSettingsPage.cs b/SetupWizard/ImportSettingsPage.cs index bb4687f63..d6a2af680 100644 --- a/SetupWizard/ImportSettingsPage.cs +++ b/SetupWizard/ImportSettingsPage.cs @@ -438,7 +438,7 @@ namespace MatterHackers.MatterControl { case ".printer": // open a wizard to ask what to import to the preset - throw new NotImplementedException("need to import from 'MatterControl.printer' files"); + WizardWindow.ChangeToPage(new SelectPartsOfPrinterToImport(settingsFilePath)); break; case ".slice": // legacy presets file extension From 493b2b2b3f7bfdd895b43efab1a214102fc588ec Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 21 Jun 2016 16:36:11 -0700 Subject: [PATCH 4/5] Import into new preset layer --- SetupWizard/ImportSettingsPage.cs | 63 +++++++++++++++++++++--------- StaticData/Translations/Master.txt | 12 ++++++ 2 files changed, 57 insertions(+), 18 deletions(-) diff --git a/SetupWizard/ImportSettingsPage.cs b/SetupWizard/ImportSettingsPage.cs index d6a2af680..e4c7c4029 100644 --- a/SetupWizard/ImportSettingsPage.cs +++ b/SetupWizard/ImportSettingsPage.cs @@ -48,9 +48,12 @@ namespace MatterHackers.MatterControl int selectedMaterial = -1; int selectedQuality = -1; - public SelectPartsOfPrinterToImport(string settingsFilePath) : + PrinterSettingsLayer destinationLayer; + + public SelectPartsOfPrinterToImport(string settingsFilePath, PrinterSettingsLayer destinationLayer) : base(unlocalizedTextForTitle: "Import Wizard") { + this.destinationLayer = destinationLayer; settingsToImport = PrinterSettings.LoadFile(settingsFilePath); this.headerLabel.Text = "Select What to Import".Localize(); @@ -195,7 +198,7 @@ namespace MatterHackers.MatterControl { ActiveSliceSettings.Instance.OemLayer, ActiveSliceSettings.Instance.BaseLayer, - ActiveSliceSettings.Instance.UserLayer, + destinationLayer, }; PrinterSettingsLayer layerToImport = settingsToImport.BaseLayer; @@ -207,9 +210,14 @@ namespace MatterHackers.MatterControl { if (!skipKeys.Contains(item.Key)) { - activeSettings.UserLayer[item.Key] = item.Value; + destinationLayer[item.Key] = item.Value; } } + + if (destinationLayer != ActiveSliceSettings.Instance.UserLayer && material.ContainsKey("layer_name")) + { + destinationLayer["layer_name"] = material["layer_name"]; + } } else if (selectedQuality > -1) { @@ -219,9 +227,14 @@ namespace MatterHackers.MatterControl { if (!skipKeys.Contains(item.Key)) { - activeSettings.UserLayer[item.Key] = item.Value; + destinationLayer[item.Key] = item.Value; } } + + if (destinationLayer != ActiveSliceSettings.Instance.UserLayer && quality.ContainsKey("layer_name")) + { + destinationLayer["layer_name"] = quality["layer_name"]; + } } else { @@ -232,7 +245,7 @@ namespace MatterHackers.MatterControl string importValue = settingsToImport.GetValue(item.Key, layerCascade).Trim(); if (currentValue != item.Value) { - activeSettings.UserLayer[item.Key] = item.Value; + destinationLayer[item.Key] = item.Value; } } } @@ -241,7 +254,6 @@ namespace MatterHackers.MatterControl UiThread.RunOnIdle(ApplicationController.Instance.ReloadAdvancedControlsPanel); - ProfileManager.ImportFromExisting(settingsFilePath); WizardWindow.ChangeToPage(new ImportSucceeded(importPrinterSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath))) { WizardWindow = this.WizardWindow, @@ -395,7 +407,7 @@ namespace MatterHackers.MatterControl } static string importPrinterSuccessMessage = "You have successfully imported a new printer profile. You can find '{0}' in your list of available printers.".Localize(); - static string importSettingSuccessMessage = "You have successfully imported a new {0} setting. You can find '{1}' in your list of {2} settings.".Localize(); + static string importSettingSuccessMessage = "You have successfully imported a new {1} setting. You can find '{0}' in your list of {1} settings.".Localize(); private void ImportSettingsFile(string settingsFilePath) { @@ -414,18 +426,10 @@ namespace MatterHackers.MatterControl else if(newQualityPresetButton.Checked) { ImportToPreset(settingsFilePath); - WizardWindow.ChangeToPage(new ImportSucceeded(importSettingSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath), "Quality".Localize())) - { - WizardWindow = this.WizardWindow, - }); } else if(newMaterialPresetButton.Checked) { ImportToPreset(settingsFilePath); - WizardWindow.ChangeToPage(new ImportSucceeded(importSettingSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath), "Material".Localize())) - { - WizardWindow = this.WizardWindow, - }); } } @@ -433,12 +437,27 @@ namespace MatterHackers.MatterControl { if (!string.IsNullOrEmpty(settingsFilePath) && File.Exists(settingsFilePath)) { + PrinterSettingsLayer newLayer; + string importType = Path.GetExtension(settingsFilePath).ToLower(); switch (importType) { case ".printer": + newLayer = new PrinterSettingsLayer(); + newLayer["layer_name"] = Path.GetFileNameWithoutExtension(settingsFilePath); + if (newQualityPresetButton.Checked) + { + ActiveSliceSettings.Instance.QualityLayers.Add(newLayer); + } + else + { + // newMaterialPresetButton.Checked + ActiveSliceSettings.Instance.MaterialLayers.Add(newLayer); + } + // open a wizard to ask what to import to the preset - WizardWindow.ChangeToPage(new SelectPartsOfPrinterToImport(settingsFilePath)); + WizardWindow.ChangeToPage(new SelectPartsOfPrinterToImport(settingsFilePath, newLayer)); + break; case ".slice": // legacy presets file extension @@ -449,7 +468,7 @@ namespace MatterHackers.MatterControl bool isSlic3r = importType == ".slice" || settingsToImport.TryGetValue(SettingsKey.layer_height, out layerHeight); if (isSlic3r) { - var newLayer = new PrinterSettingsLayer(); + newLayer = new PrinterSettingsLayer(); newLayer.Name = Path.GetFileNameWithoutExtension(settingsFilePath); // Only be the base and oem layers (not the user, quality or material layer) @@ -469,16 +488,24 @@ namespace MatterHackers.MatterControl } } + string section; if (newMaterialPresetButton.Checked) { ActiveSliceSettings.Instance.MaterialLayers.Add(newLayer); + section = "Material".Localize(); } else { ActiveSliceSettings.Instance.QualityLayers.Add(newLayer); + section = "Quality".Localize(); } ActiveSliceSettings.Instance.SaveChanges(); + + WizardWindow.ChangeToPage(new ImportSucceeded(importSettingSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath), section)) + { + WizardWindow = this.WizardWindow, + }); } else { @@ -505,7 +532,7 @@ namespace MatterHackers.MatterControl switch (importType) { case ".printer": - WizardWindow.ChangeToPage(new SelectPartsOfPrinterToImport(settingsFilePath)); + WizardWindow.ChangeToPage(new SelectPartsOfPrinterToImport(settingsFilePath, ActiveSliceSettings.Instance.UserLayer)); break; case ".slice": // old presets format diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 1827be167..544a67c4a 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -5065,3 +5065,15 @@ Translated:Export As English:Cura Translated:Cura +English:You have successfully imported a new {1} setting. You can find '{0}' in your list of {1} settings. +Translated:You have successfully imported a new {1} setting. You can find '{0}' in your list of {1} settings. + +English:Select what you would like to merge into your current profile. +Translated:Select what you would like to merge into your current profile. + +English:Settings have been merged into your current printer. +Translated:Settings have been merged into your current printer. + +English:Select What to Import +Translated:Select What to Import + From b63551aee6697b86789d25eca46a222e4dd92168 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 21 Jun 2016 17:06:01 -0700 Subject: [PATCH 5/5] Finished import to settings overrides --- SetupWizard/ImportSettingsPage.cs | 47 +++++++++++++++++++++--------- StaticData/Translations/Master.txt | 3 ++ 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/SetupWizard/ImportSettingsPage.cs b/SetupWizard/ImportSettingsPage.cs index e4c7c4029..21ecc24f3 100644 --- a/SetupWizard/ImportSettingsPage.cs +++ b/SetupWizard/ImportSettingsPage.cs @@ -43,17 +43,25 @@ namespace MatterHackers.MatterControl public class SelectPartsOfPrinterToImport : WizardPage { static string importMessage = "Select what you would like to merge into your current profile.".Localize(); + string settingsFilePath; PrinterSettings settingsToImport; int selectedMaterial = -1; int selectedQuality = -1; PrinterSettingsLayer destinationLayer; + string sectionName; - public SelectPartsOfPrinterToImport(string settingsFilePath, PrinterSettingsLayer destinationLayer) : + private bool isMergeIntoUserLayer = false; + + + public SelectPartsOfPrinterToImport(string settingsFilePath, PrinterSettingsLayer destinationLayer, string sectionName = null) : base(unlocalizedTextForTitle: "Import Wizard") { + this.isMergeIntoUserLayer = destinationLayer == ActiveSliceSettings.Instance.UserLayer; this.destinationLayer = destinationLayer; + this.sectionName = sectionName; + settingsToImport = PrinterSettings.LoadFile(settingsFilePath); this.headerLabel.Text = "Select What to Import".Localize(); @@ -75,14 +83,16 @@ namespace MatterHackers.MatterControl }; scrollWindow.AddChild(container); - var selectPartsMessage = new WrappedTextWidget(importMessage, 10, textColor: ActiveTheme.Instance.PrimaryTextColor); - container.AddChild(selectPartsMessage); + if (isMergeIntoUserLayer) + { + container.AddChild(new WrappedTextWidget(importMessage, 10, textColor: ActiveTheme.Instance.PrimaryTextColor)); + } // add in the check boxes to select what to import container.AddChild(new TextWidget("Main Settings:") { TextColor = ActiveTheme.Instance.PrimaryTextColor, - Margin = new BorderDouble(0, 3, 0, 10), + Margin = new BorderDouble(0, 3, 0, isMergeIntoUserLayer ? 10 : 0), }); var mainProfileRadioButton = new RadioButton("Printer Profile") @@ -167,7 +177,8 @@ namespace MatterHackers.MatterControl } } - var mergeButton = textImageButtonFactory.Generate("Merge".Localize()); + var mergeButtonTitle = this.isMergeIntoUserLayer ? "Merge".Localize() : "Import".Localize(); + var mergeButton = textImageButtonFactory.Generate( mergeButtonTitle); mergeButton.Name = "Merge Profile"; mergeButton.Click += (s,e) => UiThread.RunOnIdle(Merge); footerRow.AddChild(mergeButton); @@ -214,7 +225,7 @@ namespace MatterHackers.MatterControl } } - if (destinationLayer != ActiveSliceSettings.Instance.UserLayer && material.ContainsKey("layer_name")) + if (!isMergeIntoUserLayer && material.ContainsKey("layer_name")) { destinationLayer["layer_name"] = material["layer_name"]; } @@ -231,7 +242,7 @@ namespace MatterHackers.MatterControl } } - if (destinationLayer != ActiveSliceSettings.Instance.UserLayer && quality.ContainsKey("layer_name")) + if (!isMergeIntoUserLayer && quality.ContainsKey("layer_name")) { destinationLayer["layer_name"] = quality["layer_name"]; } @@ -254,7 +265,14 @@ namespace MatterHackers.MatterControl UiThread.RunOnIdle(ApplicationController.Instance.ReloadAdvancedControlsPanel); - WizardWindow.ChangeToPage(new ImportSucceeded(importPrinterSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath))) + string successMessage = importPrinterSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath)); + if (!isMergeIntoUserLayer) + { + string sourceName = isMergeIntoUserLayer ? Path.GetFileNameWithoutExtension(settingsFilePath) : destinationLayer["layer_name"]; + successMessage = ImportSettingsPage.importSettingSuccessMessage.FormatWith(sourceName, sectionName); + } + + WizardWindow.ChangeToPage(new ImportSucceeded(successMessage) { WizardWindow = this.WizardWindow, }); @@ -407,7 +425,7 @@ namespace MatterHackers.MatterControl } static string importPrinterSuccessMessage = "You have successfully imported a new printer profile. You can find '{0}' in your list of available printers.".Localize(); - static string importSettingSuccessMessage = "You have successfully imported a new {1} setting. You can find '{0}' in your list of {1} settings.".Localize(); + internal static string importSettingSuccessMessage = "You have successfully imported a new {1} setting. You can find '{0}' in your list of {1} settings.".Localize(); private void ImportSettingsFile(string settingsFilePath) { @@ -439,15 +457,19 @@ namespace MatterHackers.MatterControl { PrinterSettingsLayer newLayer; + string sectionName = (newMaterialPresetButton.Checked) ? "Material".Localize() : "Quality".Localize(); + string importType = Path.GetExtension(settingsFilePath).ToLower(); switch (importType) { case ".printer": newLayer = new PrinterSettingsLayer(); newLayer["layer_name"] = Path.GetFileNameWithoutExtension(settingsFilePath); + if (newQualityPresetButton.Checked) { ActiveSliceSettings.Instance.QualityLayers.Add(newLayer); + } else { @@ -456,7 +478,7 @@ namespace MatterHackers.MatterControl } // open a wizard to ask what to import to the preset - WizardWindow.ChangeToPage(new SelectPartsOfPrinterToImport(settingsFilePath, newLayer)); + WizardWindow.ChangeToPage(new SelectPartsOfPrinterToImport(settingsFilePath, newLayer, sectionName)); break; @@ -488,21 +510,18 @@ namespace MatterHackers.MatterControl } } - string section; if (newMaterialPresetButton.Checked) { ActiveSliceSettings.Instance.MaterialLayers.Add(newLayer); - section = "Material".Localize(); } else { ActiveSliceSettings.Instance.QualityLayers.Add(newLayer); - section = "Quality".Localize(); } ActiveSliceSettings.Instance.SaveChanges(); - WizardWindow.ChangeToPage(new ImportSucceeded(importSettingSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath), section)) + WizardWindow.ChangeToPage(new ImportSucceeded(importSettingSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath), sectionName)) { WizardWindow = this.WizardWindow, }); diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 544a67c4a..c93dbd80a 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -5077,3 +5077,6 @@ Translated:Settings have been merged into your current printer. English:Select What to Import Translated:Select What to Import +English:Select section to import to preset. +Translated:Select section to import to preset. +