working to improve consistency between settings views
This commit is contained in:
parent
c298116777
commit
11d6b659fb
5 changed files with 48 additions and 92 deletions
|
|
@ -47,13 +47,22 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
internal SettingsLayout()
|
||||
{
|
||||
LoadAndParseLayoutFile(Simple, SliceSettingsLayouts.SimpleSettings());
|
||||
LoadAndParseLayoutFile(Moderate, SliceSettingsLayouts.ModerateSettings());
|
||||
LoadAndParseLayoutFile(Advanced, SliceSettingsLayouts.AdvancedSettings());
|
||||
LoadAndParseLayoutFile(Printer, SliceSettingsLayouts.PrinterSettings());
|
||||
CreateLayout(Advanced, SliceSettingsLayouts.AdvancedSettings());
|
||||
CreateLayout(Simple, SliceSettingsLayouts.AdvancedSettings(), (setting) =>
|
||||
{
|
||||
if (PrinterSettings.SettingsData.TryGetValue(setting, out SliceSettingData data))
|
||||
{
|
||||
return data.IncludeInSimple;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
CreateLayout(Moderate, SliceSettingsLayouts.ModerateSettings());
|
||||
CreateLayout(Printer, SliceSettingsLayouts.PrinterSettings());
|
||||
}
|
||||
|
||||
private void LoadAndParseLayoutFile(SettingsSection section, (string categoryName, (string groupName, string[] settings)[] groups)[] layout)
|
||||
private void CreateLayout(SettingsSection section, (string categoryName, (string groupName, string[] settings)[] groups)[] layout, Func<string, bool> includeSetting = null)
|
||||
{
|
||||
foreach (var (categoryName, groups) in layout)
|
||||
{
|
||||
|
|
@ -67,7 +76,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
if (PrinterSettings.SettingsData.TryGetValue(setting, out SliceSettingData data))
|
||||
if (PrinterSettings.SettingsData.TryGetValue(setting, out SliceSettingData data)
|
||||
&& includeSetting?.Invoke(setting) != false)
|
||||
{
|
||||
groupToAddTo.Settings.Add(data);
|
||||
data.OrganizerGroup = groupToAddTo;
|
||||
|
|
|
|||
|
|
@ -81,5 +81,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
public SettingsLayout.Group OrganizerGroup { get; set; }
|
||||
|
||||
public ValueConverter Converter { get; set; }
|
||||
public bool IncludeInSimple { get; internal set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -100,6 +100,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
PresentationName = "Bed Temperature".Localize(),
|
||||
HelpText = "The temperature to which the bed will be set for the duration of the print. Set to 0 to disable.".Localize(),
|
||||
DataEditType = DataEditTypes.POSITIVE_DOUBLE,
|
||||
IncludeInSimple = true,
|
||||
Units = "°C".Localize(),
|
||||
ShowIfSet = "has_heated_bed",
|
||||
DefaultValue = "70"
|
||||
|
|
@ -245,6 +246,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
HelpText = "The layer(s) at which the print will pause, allowing for a change in filament. Printer is paused before starting the given layer. Leave blank to disable. To pause on multiple layers, separate the layer numbers with semicolons. For example: \"16; 37\".".Localize(),
|
||||
DataEditType = DataEditTypes.STRING,
|
||||
ShowIfSet = "!sla_printer",
|
||||
IncludeInSimple = true,
|
||||
ResetAtEndOfPrint = true,
|
||||
DefaultValue = ""
|
||||
},
|
||||
|
|
@ -345,6 +347,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
DataEditType = DataEditTypes.CHECK_BOX,
|
||||
DefaultValue = "0",
|
||||
ReloadUiWhenChanged = true,
|
||||
IncludeInSimple = true,
|
||||
Converter = new MappedToBoolString(),
|
||||
},
|
||||
new SliceSettingData()
|
||||
|
|
@ -551,12 +554,13 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
},
|
||||
new SliceSettingData()
|
||||
{
|
||||
QuickMenuSettings = { { "Light", "10%" }, { "Standard", "30%" }, { "Heavy", "90%" } },
|
||||
SlicerConfigName = SettingsKey.fill_density,
|
||||
QuickMenuSettings = { { "Light", "10%" }, { "Standard", "30%" }, { "Heavy", "90%" } },
|
||||
PresentationName = "Fill Density".Localize(),
|
||||
HelpText = "The amount of infill material to generate, expressed as a ratio or a percentage.".Localize(),
|
||||
DataEditType = DataEditTypes.DOUBLE_OR_PERCENT,
|
||||
DefaultValue = "0.4",
|
||||
IncludeInSimple = true,
|
||||
Converter = new AsPercentOrDirectFirst(),
|
||||
},
|
||||
new SliceSettingData()
|
||||
|
|
@ -587,6 +591,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
HelpText = "The thickness of the first layer. A first layer taller than the default layer thickness can ensure good adhesion to the build plate.".Localize(),
|
||||
DataEditType = DataEditTypes.DOUBLE_OR_PERCENT,
|
||||
Units = "mm or %".Localize(),
|
||||
IncludeInSimple = true,
|
||||
DefaultValue = "0.3",
|
||||
Converter = new AsPercentOfReferenceOrDirect(SettingsKey.layer_height),
|
||||
},
|
||||
|
|
@ -640,6 +645,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
HelpText = "Checks before each print that the layer height is less than the nozzle diameter (important for filament adhesion)".Localize(),
|
||||
DataEditType = DataEditTypes.CHECK_BOX,
|
||||
Units = "",
|
||||
IncludeInSimple = true,
|
||||
ShowAsOverride = true,
|
||||
DefaultValue = "1",
|
||||
ShowIfSet = "!sla_printer",
|
||||
|
|
@ -1773,6 +1779,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
DataEditType = DataEditTypes.CHECK_BOX,
|
||||
ShowIfSet = "!sla_printer",
|
||||
ResetAtEndOfPrint = true,
|
||||
IncludeInSimple = true,
|
||||
DefaultValue = "0",
|
||||
Converter = new MappedToBoolString(),
|
||||
},
|
||||
|
|
@ -1872,6 +1879,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
ShowIfSet = "!sla_printer",
|
||||
DataEditType = DataEditTypes.CHECK_BOX,
|
||||
DefaultValue = "0",
|
||||
IncludeInSimple = true,
|
||||
Converter = new MappedToBoolString(),
|
||||
ReloadUiWhenChanged = true
|
||||
},
|
||||
|
|
@ -2011,6 +2019,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
HelpText = "The target temperature the extruder will attempt to reach during the print.".Localize(),
|
||||
DataEditType = DataEditTypes.POSITIVE_DOUBLE,
|
||||
Units = "°C".Localize(),
|
||||
IncludeInSimple = true,
|
||||
ShowIfSet = "!sla_printer",
|
||||
DefaultValue = "200"
|
||||
},
|
||||
|
|
@ -2518,6 +2527,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
HelpText = "Creates a brim attached to the base of the print. Useful to prevent warping when printing ABS (and other warping-prone plastics) as it helps parts adhere to the bed.".Localize(),
|
||||
DataEditType = DataEditTypes.CHECK_BOX,
|
||||
DefaultValue = "0",
|
||||
IncludeInSimple = true,
|
||||
ReloadUiWhenChanged = true
|
||||
},
|
||||
new SliceSettingData()
|
||||
|
|
@ -2527,6 +2537,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
HelpText = "Creates an outline around the print, but not attached to it. This is useful for priming the nozzle to ensure the plastic is flowing when the print starts.".Localize(),
|
||||
DataEditType = DataEditTypes.CHECK_BOX,
|
||||
DefaultValue = "1",
|
||||
IncludeInSimple = true,
|
||||
ReloadUiWhenChanged = true
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -27,36 +27,25 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||
{
|
||||
public static class SliceSettingsLayouts
|
||||
{
|
||||
public static (string categoryName, (string groupName, string[] settings)[] groups)[] SimpleSettings()
|
||||
public static HashSet<string> SimpleSettings()
|
||||
{
|
||||
var settings = new[]
|
||||
return new HashSet<string>(new []
|
||||
{
|
||||
("General", new[]
|
||||
{
|
||||
("General", new[]
|
||||
{
|
||||
SettingsKey.layer_height,
|
||||
SettingsKey.fill_density,
|
||||
SettingsKey.create_skirt,
|
||||
SettingsKey.create_raft,
|
||||
SettingsKey.create_brim,
|
||||
SettingsKey.create_per_layer_support,
|
||||
SettingsKey.temperature,
|
||||
SettingsKey.bed_temperature,
|
||||
}),
|
||||
("Advanced", new[]
|
||||
{
|
||||
SettingsKey.spiral_vase,
|
||||
SettingsKey.layer_to_pause,
|
||||
}),
|
||||
}),
|
||||
};
|
||||
|
||||
return settings;
|
||||
SettingsKey.layer_height,
|
||||
SettingsKey.fill_density,
|
||||
SettingsKey.create_skirt,
|
||||
SettingsKey.create_raft,
|
||||
SettingsKey.create_brim,
|
||||
SettingsKey.create_per_layer_support,
|
||||
SettingsKey.temperature,
|
||||
SettingsKey.bed_temperature,
|
||||
});
|
||||
}
|
||||
|
||||
public static (string categoryName, (string groupName, string[] settings)[] groups)[] ModerateSettings()
|
||||
|
|
@ -206,6 +195,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
SettingsKey.wipe_shield_distance,
|
||||
SettingsKey.wipe_tower_size,
|
||||
}),
|
||||
("Advanced", new[]
|
||||
{
|
||||
SettingsKey.spiral_vase,
|
||||
SettingsKey.layer_to_pause,
|
||||
}),
|
||||
}),
|
||||
("Speed", new[]
|
||||
{
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
var sectionName = group.Name.Localize();
|
||||
|
||||
var sectionWidget = new SectionWidget(sectionName, groupPanel, theme, serializationKey: userSettingsKey, rightAlignedContent: uiField?.Content);
|
||||
var sectionWidget = new SectionWidget(sectionName, groupPanel, theme, serializationKey: userSettingsKey, defaultExpansion: true, rightAlignedContent: uiField?.Content);
|
||||
theme.ApplyBoxStyle(sectionWidget);
|
||||
|
||||
bool firstRow = true;
|
||||
|
|
@ -519,66 +519,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
base.OnLoad(args);
|
||||
}
|
||||
|
||||
private UIField CreateToggleFieldForSection(SliceSettingData settingData)
|
||||
{
|
||||
bool useDefaultSavePattern = false;
|
||||
|
||||
string sliceSettingValue = settingsContext.GetValue(settingData.SlicerConfigName);
|
||||
|
||||
// Create toggle field for key
|
||||
var uiField = new ToggleboxField(theme)
|
||||
{
|
||||
HelpText = settingData.HelpText,
|
||||
Name = $"{settingData.PresentationName} Field"
|
||||
};
|
||||
uiField.Initialize(tabIndexForItem++);
|
||||
|
||||
uiField.ValueChanged += (s, e) =>
|
||||
{
|
||||
if (e.UserInitiated)
|
||||
{
|
||||
ICheckbox checkbox = uiField.Content as ICheckbox;
|
||||
string checkedKey = checkbox.Checked ? "OnValue" : "OffValue";
|
||||
|
||||
// Linked settings should be updated in all cases (user clicked checkbox, user clicked clear)
|
||||
foreach (var setSettingsData in settingData.SetSettingsOnChange)
|
||||
{
|
||||
if (setSettingsData.TryGetValue(checkedKey, out string targetValue))
|
||||
{
|
||||
settingsContext.SetValue(setSettingsData["TargetSetting"], targetValue);
|
||||
}
|
||||
}
|
||||
|
||||
// Store actual field value
|
||||
settingsContext.SetValue(settingData.SlicerConfigName, uiField.Value);
|
||||
}
|
||||
};
|
||||
|
||||
if (allUiFields != null)
|
||||
{
|
||||
allUiFields[settingData.SlicerConfigName] = uiField;
|
||||
}
|
||||
|
||||
uiField.SetValue(sliceSettingValue, userInitiated: false);
|
||||
|
||||
// Second ValueChanged listener defined after SetValue to ensure it's unaffected by initial change
|
||||
uiField.ValueChanged += (s, e) =>
|
||||
{
|
||||
if (useDefaultSavePattern
|
||||
&& e.UserInitiated)
|
||||
{
|
||||
settingsContext.SetValue(settingData.SlicerConfigName, uiField.Value);
|
||||
}
|
||||
};
|
||||
|
||||
uiField.Content.Margin = uiField.Content.Margin.Clone(right: 15);
|
||||
// uiField.Content.ToolTipText = settingData.HelpText;
|
||||
uiField.Content.ToolTipText = "";
|
||||
uiField.HelpText = "";
|
||||
|
||||
return uiField;
|
||||
}
|
||||
|
||||
private static bool CheckIfShouldBeShown(SliceSettingData settingData, SettingsContext settingsContext)
|
||||
{
|
||||
bool settingShouldBeShown = settingsContext.ParseShowString(settingData.ShowIfSet);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue