Restored ability to switch back quick settings on revert settings button
This commit is contained in:
parent
f3b3cd3c43
commit
00d8346ccf
2 changed files with 4 additions and 67 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue