Merge pull request #2917 from jlewin/design_tools
Fix issues blocking settings restore
This commit is contained in:
commit
257cb2b77e
13 changed files with 61 additions and 52 deletions
|
|
@ -73,7 +73,7 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
private static string _libraryAssetPath => Path.Combine(_applicationLibraryDataPath, "Assets");
|
||||
private static string _platingDirectory => Path.Combine(_applicationLibraryDataPath, "Plating");
|
||||
private static string _applicationTempDataPath => Path.Combine(_applicationUserDataPath, "data", "temp");
|
||||
private static string _gcodeOutputPath => Path.Combine(_applicationUserDataPath, "data", "gcode");
|
||||
private static string _gcodeOutputPath => Path.Combine(_applicationTempDataPath, "gcode");
|
||||
|
||||
public static string ApplicationUserDataPath => EnsurePath(_applicationUserDataPath);
|
||||
|
||||
|
|
|
|||
|
|
@ -555,13 +555,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
};
|
||||
progressContainer.AddChild(timeContainer);
|
||||
|
||||
var timeImage = AggContext.StaticData.LoadImage(Path.Combine("Images", "Screensaver", "time.png"));
|
||||
if (!ActiveTheme.Instance.IsDarkTheme)
|
||||
timeContainer.AddChild(new ImageWidget(AggContext.StaticData.LoadIcon("fa-clock_24.png", IconColor.Theme))
|
||||
{
|
||||
timeImage.InvertLightness();
|
||||
}
|
||||
|
||||
timeContainer.AddChild(new ImageWidget(timeImage));
|
||||
VAnchor = VAnchor.Center
|
||||
});
|
||||
|
||||
var timeWidget = new TextWidget("", pointSize: 22, textColor: ActiveTheme.Instance.PrimaryTextColor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
public class SliceSettingData
|
||||
{
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum DataEditTypes { STRING, INT, INT_OR_MM, DOUBLE, POSITIVE_DOUBLE, OFFSET, DOUBLE_OR_PERCENT, VECTOR2, OFFSET2, CHECK_BOX, LIST, MULTI_LINE_TEXT, HARDWARE_PRESENT, COM_PORT, IP_LIST };
|
||||
public enum DataEditTypes { STRING, WIDE_STRING, INT, INT_OR_MM, DOUBLE, POSITIVE_DOUBLE, OFFSET, DOUBLE_OR_PERCENT, VECTOR2, OFFSET2, CHECK_BOX, LIST, MULTI_LINE_TEXT, HARDWARE_PRESENT, COM_PORT, IP_LIST };
|
||||
|
||||
public string SlicerConfigName { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
restoreButton.ToolTipText = "Restore Default".Localize();
|
||||
restoreButton.Click += (sender, e) =>
|
||||
{
|
||||
// Revert the user override
|
||||
settingsContext.ClearValue(settingData.SlicerConfigName);
|
||||
// Revert the user override
|
||||
settingsContext.ClearValue(settingData.SlicerConfigName);
|
||||
};
|
||||
|
||||
restoreArea.AddChild(restoreButton);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ using MatterHackers.MatterControl.SetupWizard;
|
|||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||
{
|
||||
{
|
||||
public class SliceSettingsWidget : FlowLayoutWidget
|
||||
{
|
||||
internal PresetsToolbar settingsControlBar;
|
||||
|
|
@ -74,27 +74,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
this.RebuildSliceSettingsTabs();
|
||||
|
||||
ActiveSliceSettings.SettingChanged.RegisterEvent(
|
||||
(s, e) =>
|
||||
{
|
||||
if (e is StringEventArgs stringEvent)
|
||||
{
|
||||
string settingsKey = stringEvent.Data;
|
||||
if (sliceSettingsTabView.UIFields.TryGetValue(settingsKey, out UIField field2))
|
||||
{
|
||||
string currentValue = settingsContext.GetValue(settingsKey);
|
||||
if (field2.Value != currentValue
|
||||
|| settingsKey == "com_port")
|
||||
{
|
||||
field2.SetValue(
|
||||
currentValue,
|
||||
userInitiated: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
ref unregisterEvents);
|
||||
|
||||
ApplicationController.Instance.ShowHelpChanged += ShowHelp_Changed;
|
||||
|
||||
this.AnchorAll();
|
||||
|
|
@ -217,6 +196,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
private List<(GuiWidget widget, SliceSettingData settingData)> settingsRows;
|
||||
private TextWidget filteredItemsHeading;
|
||||
private ScrollableWidget scrollable;
|
||||
private EventHandler unregisterEvents;
|
||||
|
||||
public SliceSettingsTabView(SettingsContext settingsContext, PrinterConfig printer, string UserLevel, ThemeConfig theme, bool isPrimarySettingsView, string databaseMRUKey)
|
||||
: base(new SliceSettingsOverflowMenu(printer))
|
||||
|
|
@ -305,6 +285,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
this.settingsRows = new List<(GuiWidget, SliceSettingData)>();
|
||||
|
||||
allUiFields = new Dictionary<string, UIField>();
|
||||
|
||||
// Loop over categories creating a tab for each
|
||||
foreach (var category in userLevel.Categories)
|
||||
{
|
||||
|
|
@ -384,6 +366,27 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
UserSettings.Instance.set(databaseMRUKey, this.SelectedTabIndex.ToString());
|
||||
}
|
||||
};
|
||||
|
||||
ActiveSliceSettings.SettingChanged.RegisterEvent(
|
||||
(s, e) =>
|
||||
{
|
||||
if (e is StringEventArgs stringEvent)
|
||||
{
|
||||
string settingsKey = stringEvent.Data;
|
||||
if (this.allUiFields.TryGetValue(settingsKey, out UIField uifield))
|
||||
{
|
||||
string currentValue = settingsContext.GetValue(settingsKey);
|
||||
if (uifield.Value != currentValue
|
||||
|| settingsKey == "com_port")
|
||||
{
|
||||
uifield.SetValue(
|
||||
currentValue,
|
||||
userInitiated: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
ref unregisterEvents);
|
||||
}
|
||||
|
||||
public Dictionary<string, UIField> UIFields => allUiFields;
|
||||
|
|
@ -443,8 +446,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
if (EngineMappingsMatterSlice.Instance.MapContains(settingData.SlicerConfigName)
|
||||
&& settingShouldBeShown)
|
||||
{
|
||||
|
||||
var settingsRow = CreateItemRow(settingData, settingsContext, printer, theme.Colors.PrimaryTextColor, theme, ref tabIndexForItem);
|
||||
var settingsRow = CreateItemRow(settingData);
|
||||
|
||||
this.settingsRows.Add((settingsRow, settingData));
|
||||
|
||||
|
|
@ -569,7 +571,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
return dataArea;
|
||||
}
|
||||
|
||||
internal GuiWidget CreateItemRow(SliceSettingData settingData, ref int tabIndexForItem, ThemeConfig theme)
|
||||
internal GuiWidget CreateItemRow(SliceSettingData settingData)
|
||||
{
|
||||
return CreateItemRow(settingData, settingsContext, printer, theme.Colors.PrimaryTextColor, theme, ref tabIndexForItem, allUiFields);
|
||||
}
|
||||
|
|
@ -670,6 +672,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
break;
|
||||
|
||||
case SliceSettingData.DataEditTypes.STRING:
|
||||
case SliceSettingData.DataEditTypes.WIDE_STRING:
|
||||
uiField = new TextField();
|
||||
break;
|
||||
|
||||
|
|
@ -742,6 +745,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
uiField.Name = $"{settingData.PresentationName} Field";
|
||||
uiField.Initialize(tabIndexForItem++);
|
||||
|
||||
if (settingData.DataEditType == SliceSettingData.DataEditTypes.WIDE_STRING)
|
||||
{
|
||||
uiField.Content.HAnchor = HAnchor.Stretch;
|
||||
placeFieldInDedicatedRow = true;
|
||||
}
|
||||
|
||||
uiField.SetValue(sliceSettingValue, userInitiated: false);
|
||||
|
||||
uiField.ValueChanged += (s, e) =>
|
||||
|
|
@ -890,6 +899,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
base.OnActiveTabChanged();
|
||||
}
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
public void ClearFilter()
|
||||
{
|
||||
foreach (var item in this.settingsRows)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
var column = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
Margin = new BorderDouble(20, 0, 0, 0),
|
||||
HAnchor = HAnchor.Fit,
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit,
|
||||
};
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
var row = new FlowLayoutWidget()
|
||||
{
|
||||
HAnchor = HAnchor.Fit,
|
||||
HAnchor = HAnchor.Fit | HAnchor.Right,
|
||||
VAnchor = VAnchor.Fit,
|
||||
MinimumSize = new Vector2(0, 28)
|
||||
};
|
||||
|
|
@ -85,11 +85,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
var labelWidget = SliceSettingsTabView.CreateSettingsLabel($"Nozzle {i + 1}", "", textColor);
|
||||
labelWidget.Name = $"Nozzle {i}";
|
||||
labelWidget.Margin = new BorderDouble(right: 60, left: 20);
|
||||
labelWidget.Margin = new BorderDouble(right: 60);
|
||||
row.AddChild(labelWidget);
|
||||
|
||||
var field = new Vector2Field();
|
||||
field.Initialize(tabIndex++);
|
||||
field.Content.Margin = new BorderDouble(right: 55);
|
||||
field.Content.VAnchor = VAnchor.Center;
|
||||
field.ValueChanged += (s, e) =>
|
||||
{
|
||||
|
|
|
|||
BIN
StaticData/Icons/fa-clock_24.png
Normal file
BIN
StaticData/Icons/fa-clock_24.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 555 B |
Binary file not shown.
|
Before Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 176 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 KiB |
|
|
@ -191,7 +191,11 @@ Printer
|
|||
max_acceleration
|
||||
max_velocity
|
||||
jerk_velocity
|
||||
Loading
|
||||
Slicing
|
||||
Slicing Options
|
||||
output_only_first_layer
|
||||
g0
|
||||
Material Loading
|
||||
Loading
|
||||
load_filament_length
|
||||
load_filament_speed
|
||||
|
|
@ -199,10 +203,6 @@ Printer
|
|||
insert_image
|
||||
running_clean_image
|
||||
unload_filament_length
|
||||
Slicing
|
||||
Slicing Options
|
||||
output_only_first_layer
|
||||
g0
|
||||
G-Code
|
||||
G-Code
|
||||
G-Code
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@
|
|||
"SlicerConfigName": "trim_image",
|
||||
"PresentationName": "Trim Image",
|
||||
"HelpText": "The image to show when explaining trimming.",
|
||||
"DataEditType": "STRING",
|
||||
"DataEditType": "WIDE_STRING",
|
||||
"ShowIfSet": "!sla_printer",
|
||||
"DefaultValue": "https://lh3.googleusercontent.com/7vFs0ih2mGseQBKo-0gHnzaT2SsuAPgeRuqFlVKG23c4brFnIaA2nlYIg8BUcdI-mVaDAadgu5bdBv_jZ69VOi3mYw"
|
||||
},
|
||||
|
|
@ -90,7 +90,7 @@
|
|||
"SlicerConfigName": "insert_image",
|
||||
"PresentationName": "Insert Image",
|
||||
"HelpText": "The image to show when explaining inserting.",
|
||||
"DataEditType": "STRING",
|
||||
"DataEditType": "WIDE_STRING",
|
||||
"ShowIfSet": "!sla_printer",
|
||||
"DefaultValue": "https://lh3.googleusercontent.com/S4eW9-uZ0lgpg_ws9Ss4LmUc_MiXCfHnfJmGVQ0XtOdpvr_XZQLuP5zWGv7eCSM65EbsWIdHVMC40EYL7u8k7LvMP4Y"
|
||||
},
|
||||
|
|
@ -98,7 +98,7 @@
|
|||
"SlicerConfigName": "running_clean_image",
|
||||
"PresentationName": "Running Clean Image",
|
||||
"HelpText": "The image to show when explaining filament running clean.",
|
||||
"DataEditType": "STRING",
|
||||
"DataEditType": "WIDE_STRING",
|
||||
"ShowIfSet": "!sla_printer",
|
||||
"DefaultValue": ""
|
||||
},
|
||||
|
|
|
|||
|
|
@ -270,15 +270,11 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
public static bool CompareExpectedSliceSettingValueWithActualVaue(string sliceSetting, string expectedValue)
|
||||
{
|
||||
string fullPath = TestContext.CurrentContext.ResolveProjectPath(4, "Tests", "temp", runName, "Test0", "data", "gcode");
|
||||
|
||||
foreach (string iniPath in Directory.GetFiles(fullPath, "*.ini"))
|
||||
foreach (string iniPath in Directory.GetFiles(ApplicationDataStorage.Instance.GCodeOutputPath, "*.ini"))
|
||||
{
|
||||
var settings = PrinterSettingsLayer.LoadFromIni(iniPath);
|
||||
|
||||
string currentValue;
|
||||
|
||||
if (settings.TryGetValue(sliceSetting, out currentValue))
|
||||
if (settings.TryGetValue(sliceSetting, out string currentValue))
|
||||
{
|
||||
return currentValue.Trim() == expectedValue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue