Working on settings import and export wizards

This commit is contained in:
Lars Brubaker 2016-06-13 15:28:56 -07:00
parent 85caa12dfe
commit 2173b43e46
4 changed files with 99 additions and 5 deletions

View file

@ -34,6 +34,7 @@ using MatterHackers.MatterControl;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.MatterControl.SlicerConfiguration;
using MatterHackers.Localizations;
using MatterHackers.Agg;
namespace MatterHackers.MatterControl
{
@ -44,22 +45,40 @@ namespace MatterHackers.MatterControl
public ExportSettingsPage() :
base("Cancel")
{
var container = new FlowLayoutWidget(FlowDirection.TopToBottom);
var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
HAnchor = HAnchor.ParentLeftRight,
};
contentRow.AddChild(container);
// export as matter control
var matterControlButton = new RadioButton("Export MatterControl settings (*.printer)".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);
matterControlButton.CheckedStateChanged += (s, e) => exportMode = "mattercontrol";
matterControlButton.Checked = true;
container.AddChild(matterControlButton);
container.AddChild(
CreateDetailInfo("Export the complete set of features for this profile. All settings, quality and material presets, and editing states.")
);
// export as slic3r
var slic3rButton = new RadioButton("Export Slic3r settings (*.ini)".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);
slic3rButton.CheckedStateChanged += (s, e) => exportMode = "slic3r";
container.AddChild(slic3rButton);
container.AddChild(
CreateDetailInfo("Export as a config.ini file that can be read by older versions of Matter Control and Slic3r.")
);
// export as cura
#if DEBUG
var curaButton = new RadioButton("Export Cura settings (*.ini)".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);
curaButton.CheckedStateChanged += (s, e) => exportMode = "cura";
container.AddChild(curaButton);
container.AddChild(
CreateDetailInfo("Export as a file that can be read by Cura.\nNote: Not all settings are exportable in this format.")
);
#endif
var exportButton = textImageButtonFactory.Generate("Export Settings".Localize());
@ -74,6 +93,23 @@ namespace MatterHackers.MatterControl
footerRow.AddChild(cancelButton);
}
private GuiWidget CreateDetailInfo(string detailText)
{
var wrappedText = new WrappedTextWidget(detailText, 5)
{
TextColor = ActiveTheme.Instance.PrimaryTextColor,
};
var container = new GuiWidget(HAnchor.ParentLeftRight, VAnchor.FitToChildren)
{
Margin = new BorderDouble(25, 15, 5, 5),
};
container.AddChild(wrappedText);
return container;
}
private void exportButton_Click()
{
WizardWindow.Close();

View file

@ -46,28 +46,56 @@ namespace MatterHackers.MatterControl
public ImportSettingsPage() :
base("Cancel")
{
var container = new FlowLayoutWidget(FlowDirection.TopToBottom);
var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
HAnchor = HAnchor.ParentLeftRight,
};
contentRow.AddChild(container);
// add new profile
var newPrinterButton = new RadioButton("Import as new printer profile".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);
newPrinterButton.CheckedStateChanged += (s, e) => importMode = "new";
newPrinterButton.Checked = true;
container.AddChild(newPrinterButton);
this.importMode = "new";
container.AddChild(
CreateDetailInfo("Add a new printer profile, base on the imported settings, to your list of available printers.\nThis will not change your current settings.")
);
// merge into current settings
var mergeButton = new RadioButton("Merge into current printer profile".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);
mergeButton.CheckedStateChanged += (s, e) => importMode = "merge";
container.AddChild(mergeButton);
container.AddChild(
CreateDetailInfo("Merge imported settings and presets into your current profile. \nNote: You will still be able to revert to the factory settings at any time.")
);
// replace current settings
var replaceButton = new RadioButton("Replace current printer profile".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);
replaceButton.CheckedStateChanged += (s, e) => importMode = "replace";
container.AddChild(replaceButton);
container.AddChild(
CreateDetailInfo("Replace current settings and presets with the imported profile. \nNote: You will still be able to revert to the factory settings at any time.")
);
// add as preset
var newPresetButton = new RadioButton("Add as a new quality preset".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);
newPresetButton.CheckedStateChanged += (s, e) => importMode = "qualityPreset";
container.AddChild(newPresetButton);
container.AddChild(
CreateDetailInfo("Add new quality preset(s) with the settings from this import.")
);
var importButton = textImageButtonFactory.Generate("Import Settings".Localize());
importButton.Click += (s, e) => UiThread.RunOnIdle(() =>
{
FileDialog.OpenFileDialog(
new OpenFileDialogParams("settings files|*.ini;*.printer,"),
new OpenFileDialogParams("settings files|*.ini;*.printer;*.slice"),
(dialogParams) => ImportSettingsFile(dialogParams.FileName));
});
@ -80,6 +108,23 @@ namespace MatterHackers.MatterControl
footerRow.AddChild(cancelButton);
}
private GuiWidget CreateDetailInfo(string detailText)
{
var wrappedText = new WrappedTextWidget(detailText, 5)
{
TextColor = ActiveTheme.Instance.PrimaryTextColor,
};
var container = new GuiWidget(HAnchor.ParentLeftRight, VAnchor.FitToChildren)
{
Margin = new BorderDouble(25, 15, 5, 5),
};
container.AddChild(wrappedText);
return container;
}
private void ImportSettingsFile(string settingsFilePath)
{
WizardWindow.Close();
@ -94,6 +139,10 @@ namespace MatterHackers.MatterControl
case "replace":
ReplaceOrMergeSettings(settingsFilePath);
break;
case "qualityPreset":
throw new NotImplementedException("import to preset");
break;
}
}

View file

@ -81,8 +81,8 @@
"QuickMenuSettings": [],
"SetSettingsOnChange": [],
"SlicerConfigName": "layer_to_pause",
"PresentationName": "Select Layer To Pause:",
"HelpText": "If you want to select a layer to pause your print on do so here (for changing filament)",
"PresentationName": "Layers To Pause:",
"HelpText": "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\".",
"DataEditType": "STRING",
"ExtraSettings": "",
"ShowAsOverride": true,

View file

@ -4996,3 +4996,12 @@ Translated:Replace current printer profile
English:Import Settings
Translated:Import Settings
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:Add as a new quality preset
Translated:Add as a new quality preset