From 00d8346ccf4bfe2bb655ba87bc69109ccf95ae16 Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Sat, 13 Jan 2018 18:53:29 -0800 Subject: [PATCH] Restored ability to switch back quick settings on revert settings button --- SlicerConfiguration/SliceSettingsWidget.cs | 66 ------------------- .../UIFields/DropMenuWrappedField.cs | 5 +- 2 files changed, 4 insertions(+), 67 deletions(-) diff --git a/SlicerConfiguration/SliceSettingsWidget.cs b/SlicerConfiguration/SliceSettingsWidget.cs index 9560791c7..9cec7aeaa 100644 --- a/SlicerConfiguration/SliceSettingsWidget.cs +++ b/SlicerConfiguration/SliceSettingsWidget.cs @@ -705,71 +705,5 @@ namespace MatterHackers.MatterControl.SlicerConfiguration Margin = new BorderDouble(0, 5, 5, 5), }; } - - public static GuiWidget CreateQuickMenu(SliceSettingData settingData, SettingsContext settingsContext, GuiWidget content, InternalTextEditWidget internalTextWidget) - { - var theme = ApplicationController.Instance.Theme; - - string sliceSettingValue =settingsContext.GetValue(settingData.SlicerConfigName); - FlowLayoutWidget totalContent = new FlowLayoutWidget(); - - DropDownList selectableOptions = new DropDownList("Custom", theme.Colors.PrimaryTextColor, maxHeight: 200, pointSize: theme.DefaultFontSize); - selectableOptions.Margin = new BorderDouble(0, 0, 10, 0); - - foreach (QuickMenuNameValue nameValue in settingData.QuickMenuSettings) - { - string valueLocal = nameValue.Value; - - MenuItem newItem = selectableOptions.AddItem(nameValue.MenuName); - if (sliceSettingValue == valueLocal) - { - selectableOptions.SelectedLabel = nameValue.MenuName; - } - - newItem.Selected += (sender, e) => - { - settingsContext.SetValue(settingData.SlicerConfigName, valueLocal); - internalTextWidget.Text = valueLocal; - internalTextWidget.OnEditComplete(null); - }; - } - - // put in the custom menu to allow direct editing - MenuItem customMenueItem = selectableOptions.AddItem("Custom"); - - totalContent.AddChild(selectableOptions); - content.VAnchor = VAnchor.Center; - totalContent.AddChild(content); - - EventHandler localUnregisterEvents = null; - - ActiveSliceSettings.SettingChanged.RegisterEvent((sender, e) => - { - bool foundSetting = false; - foreach (QuickMenuNameValue nameValue in settingData.QuickMenuSettings) - { - string localName = nameValue.MenuName; - string newSliceSettingValue = settingsContext.GetValue(settingData.SlicerConfigName); - if (newSliceSettingValue == nameValue.Value) - { - selectableOptions.SelectedLabel = localName; - foundSetting = true; - break; - } - } - - if (!foundSetting) - { - selectableOptions.SelectedLabel = "Custom"; - } - }, ref localUnregisterEvents); - - totalContent.Closed += (s, e) => - { - localUnregisterEvents?.Invoke(s, null); - }; - - return totalContent; - } } } diff --git a/SlicerConfiguration/UIFields/DropMenuWrappedField.cs b/SlicerConfiguration/UIFields/DropMenuWrappedField.cs index 166609eaa..9493f87b7 100644 --- a/SlicerConfiguration/UIFields/DropMenuWrappedField.cs +++ b/SlicerConfiguration/UIFields/DropMenuWrappedField.cs @@ -80,6 +80,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration }; } + selectableOptions.AddItem("Custom"); + totalContent.AddChild(selectableOptions); uiField.Content.VAnchor = VAnchor.Center; @@ -92,11 +94,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration if (e is StringEventArgs stringArgs && stringArgs.Data == settingData.SlicerConfigName) { + string newSliceSettingValue = ActiveSliceSettings.Instance.GetValue(settingData.SlicerConfigName); + bool foundSetting = false; foreach (QuickMenuNameValue nameValue in settingData.QuickMenuSettings) { string localName = nameValue.MenuName; - string newSliceSettingValue = uiField.Value; if (newSliceSettingValue == nameValue.Value) { selectableOptions.SelectedLabel = localName;