private GuiWidget CreateSettingInfoUIControls(OrganizerSettingsData settingData, double minSettingNameWidth) { GuiWidget container = new GuiWidget(); FlowLayoutWidget leftToRightLayout = new FlowLayoutWidget(); bool addQualityOverlay = false; bool addMaterialOverlay = false; RGBA_Bytes qualityOverlayColor = new RGBA_Bytes(255, 255, 0, 40); RGBA_Bytes materialOverlayColor = new RGBA_Bytes(255, 127, 0, 40); if (ActiveSliceSettings.Instance.Contains(settingData.SlicerConfigName)) { int intEditWidth = 60; int doubleEditWidth = 60; int vectorXYEditWidth = 60; int multiLineEditHeight = 60; string sliceSettingValue = ActiveSliceSettings.Instance.GetActiveValue(settingData.SlicerConfigName); leftToRightLayout.Margin = new BorderDouble(0, 2); leftToRightLayout.Padding = new BorderDouble(3); leftToRightLayout.HAnchor = Agg.UI.HAnchor.ParentLeftRight; if (settingData.DataEditType != OrganizerSettingsData.DataEditTypes.MULTI_LINE_TEXT) { string convertedNewLines = settingData.PresentationName.Replace("\\n ", "\n"); convertedNewLines = convertedNewLines.Replace("\\n", "\n"); convertedNewLines = LocalizedString.Get(convertedNewLines); TextWidget settingName = new TextWidget(convertedNewLines); settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor; if (ActiveSliceSettings.Instance.SettingExistsInLayer(settingData.SlicerConfigName, 3)) { addMaterialOverlay = true; } else if (ActiveSliceSettings.Instance.SettingExistsInLayer(settingData.SlicerConfigName, 2)) { addQualityOverlay = true; } settingName.Width = minSettingNameWidth; //settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.MinimumSize.y); leftToRightLayout.AddChild(settingName); } switch (settingData.DataEditType) { case OrganizerSettingsData.DataEditTypes.INT: { int currentValue = 0; int.TryParse(sliceSettingValue, out currentValue); MHNumberEdit intEditWidget = new MHNumberEdit(currentValue, pixelWidth: intEditWidth, tabIndex: tabIndexForItem++); intEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; leftToRightLayout.AddChild(intEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.DOUBLE: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowNegatives: true, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; leftToRightLayout.AddChild(doubleEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.POSITIVE_DOUBLE: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; leftToRightLayout.AddChild(doubleEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.OFFSET: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, allowNegatives: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; leftToRightLayout.AddChild(doubleEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.DOUBLE_OR_PERCENT: { MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: 60, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { TextEditWidget textEditWidget = (TextEditWidget)sender; string text = textEditWidget.Text; text = text.Trim(); bool isPercent = text.Contains("%"); if (isPercent) { text = text.Substring(0, text.IndexOf("%")); } double result; double.TryParse(text, out result); text = result.ToString(); if (isPercent) { text += "%"; } textEditWidget.Text = text; SaveSetting(settingData.SlicerConfigName, textEditWidget.Text); }; leftToRightLayout.AddChild(stringEdit); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.CHECK_BOX: { CheckBox checkBoxWidget = new CheckBox(""); checkBoxWidget.VAnchor = Agg.UI.VAnchor.ParentBottom; checkBoxWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; checkBoxWidget.Checked = (sliceSettingValue == "1"); checkBoxWidget.CheckedStateChanged += (sender, e) => { if (((CheckBox)sender).Checked) { SaveSetting(settingData.SlicerConfigName, "1"); } else { SaveSetting(settingData.SlicerConfigName, "0"); } }; leftToRightLayout.AddChild(checkBoxWidget); } break; case OrganizerSettingsData.DataEditTypes.STRING: { MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: 120, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text); }; leftToRightLayout.AddChild(stringEdit); } break; case OrganizerSettingsData.DataEditTypes.MULTI_LINE_TEXT: { string convertedNewLines = sliceSettingValue.Replace("\\n", "\n"); MHTextEditWidget stringEdit = new MHTextEditWidget(convertedNewLines, pixelWidth: 320, pixelHeight: multiLineEditHeight, multiLine: true, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text.Replace("\n", "\\n")); }; leftToRightLayout.AddChild(stringEdit); } break; case OrganizerSettingsData.DataEditTypes.LIST: { StyledDropDownList selectableOptions = new StyledDropDownList("None", maxHeight: 200); selectableOptions.Margin = new BorderDouble(); string[] listItems = settingData.ExtraSettings.Split(','); foreach (string listItem in listItems) { MenuItem newItem = selectableOptions.AddItem(listItem); if (newItem.Text == sliceSettingValue) { selectableOptions.SelectedLabel = sliceSettingValue; } newItem.Selected += (sender, e) => { MenuItem menuItem = ((MenuItem)sender); SaveSetting(settingData.SlicerConfigName, menuItem.Text); }; } leftToRightLayout.AddChild(selectableOptions); } break; case OrganizerSettingsData.DataEditTypes.VECTOR2: { string[] xyValueStrings = sliceSettingValue.Split(','); if (xyValueStrings.Length != 2) { xyValueStrings = new string[] { "0", "0" }; } double currentXValue = 0; double.TryParse(xyValueStrings[0], out currentXValue); MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); double currentYValue = 0; double.TryParse(xyValueStrings[1], out currentYValue); MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); { xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); }; leftToRightLayout.AddChild(xEditWidget); TextWidget xText = new TextWidget("x"); xText.TextColor = ActiveTheme.Instance.PrimaryTextColor; xText.Margin = new BorderDouble(5, 0); leftToRightLayout.AddChild(xText); } { yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); }; leftToRightLayout.AddChild(yEditWidget); TextWidget yText = new TextWidget("y"); yText.TextColor = ActiveTheme.Instance.PrimaryTextColor; yText.Margin = new BorderDouble(5, 0); leftToRightLayout.AddChild(yText); } } break; case OrganizerSettingsData.DataEditTypes.OFFSET2: { string[] xyValueStrings = sliceSettingValue.Split('x'); if (xyValueStrings.Length != 2) { xyValueStrings = new string[] { "0", "0" }; } double currentXValue = 0; double.TryParse(xyValueStrings[0], out currentXValue); MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); double currentYValue = 0; double.TryParse(xyValueStrings[1], out currentYValue); MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); { xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); }; leftToRightLayout.AddChild(xEditWidget); TextWidget xText = new TextWidget("x"); xText.TextColor = ActiveTheme.Instance.PrimaryTextColor; xText.Margin = new BorderDouble(5, 0); leftToRightLayout.AddChild(xText); } { yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); }; leftToRightLayout.AddChild(yEditWidget); TextWidget yText = new TextWidget("y"); yText.TextColor = ActiveTheme.Instance.PrimaryTextColor; yText.Margin = new BorderDouble(5, 0); leftToRightLayout.AddChild(yText); } } break; default: TextWidget missingSetting = new TextWidget(String.Format("Missing the setting for '{0}'.", settingData.DataEditType.ToString())); missingSetting.TextColor = ActiveTheme.Instance.PrimaryTextColor; missingSetting.BackgroundColor = RGBA_Bytes.Red; leftToRightLayout.AddChild(missingSetting); break; } } else // the setting we think we are adding is not in the config.ini it may have been depricated { TextWidget settingName = new TextWidget(String.Format("Setting '{0}' not found in config.ini", settingData.SlicerConfigName)); settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor; settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.MinimumSize.y); leftToRightLayout.AddChild(settingName); leftToRightLayout.BackgroundColor = RGBA_Bytes.Red; } container.HAnchor = HAnchor.ParentLeftRight; container.VAnchor = VAnchor.FitToChildren; container.AddChild(leftToRightLayout); if (addQualityOverlay || addMaterialOverlay) { SettingPresetOverlay overlay = new SettingPresetOverlay(); overlay.HAnchor = HAnchor.ParentLeftRight; overlay.VAnchor = Agg.UI.VAnchor.ParentBottomTop; SettingPresetClick clickToEdit = new SettingPresetClick(); clickToEdit.HAnchor = HAnchor.ParentLeftRight; clickToEdit.VAnchor = Agg.UI.VAnchor.ParentBottomTop; clickToEdit.Visible = false; Button editButton = buttonFactory.Generate("Edit Preset".Localize().ToUpper()); editButton.HAnchor = Agg.UI.HAnchor.ParentCenter; editButton.VAnchor = Agg.UI.VAnchor.ParentCenter; clickToEdit.AddChild(editButton); if (addQualityOverlay) { overlay.OverlayColor = qualityOverlayColor; clickToEdit.OverlayColor = qualityOverlayColor; editButton.Click += (sender, e) => { if (ApplicationWidget.Instance.EditSlicePresetsWindow == null) { ApplicationWidget.Instance.EditSlicePresetsWindow = new SlicePresetsWindow(ReloadOptions, "Quality", "quality", false, ActivePrinterProfile.Instance.ActiveQualitySettingsID); ApplicationWidget.Instance.EditSlicePresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationWidget.Instance.EditSlicePresetsWindow = null; }; } else { ApplicationWidget.Instance.EditSlicePresetsWindow.ChangeToSlicePresetFromID(ActivePrinterProfile.Instance.ActiveQualitySettingsID); ApplicationWidget.Instance.EditSlicePresetsWindow.BringToFront(); } }; } else if (addMaterialOverlay) { overlay.OverlayColor = materialOverlayColor; clickToEdit.OverlayColor = materialOverlayColor; editButton.Click += (sender, e) => { if (ApplicationWidget.Instance.EditSlicePresetsWindow == null) { ApplicationWidget.Instance.EditSlicePresetsWindow = new SlicePresetsWindow(ReloadOptions, "Material", "material", false, ActivePrinterProfile.Instance.GetMaterialSetting(1)); ApplicationWidget.Instance.EditSlicePresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationWidget.Instance.EditSlicePresetsWindow = null; }; } else { ApplicationWidget.Instance.EditSlicePresetsWindow.ChangeToSlicePresetFromID(ActivePrinterProfile.Instance.GetMaterialSetting(1)); ApplicationWidget.Instance.EditSlicePresetsWindow.BringToFront(); } }; } container.MouseEnterBounds += (sender, e) => { UiThread.RunOnIdle((state) => { overlay.Visible = false; clickToEdit.Visible = true; }); }; container.MouseLeaveBounds += (sender, e) => { UiThread.RunOnIdle((state) => { overlay.Visible = true; clickToEdit.Visible = false; }); }; container.AddChild(overlay); container.AddChild(clickToEdit); } return(container); }
private GuiWidget CreateSettingInfoUIControls(OrganizerSettingsData settingData, double minSettingNameWidth, int extruderIndex) { GuiWidget container = new GuiWidget(); FlowLayoutWidget leftToRightLayout = new FlowLayoutWidget(); bool addQualityOverlay = false; bool addMaterialOverlay = false; RGBA_Bytes qualityOverlayColor = new RGBA_Bytes(255, 255, 0, 40); RGBA_Bytes materialOverlayColor = new RGBA_Bytes(255, 127, 0, 40); if (ActiveSliceSettings.Instance.Contains(settingData.SlicerConfigName)) { int intEditWidth = (int)(60 * TextWidget.GlobalPointSizeScaleRatio + .5); int doubleEditWidth = (int)(60 * TextWidget.GlobalPointSizeScaleRatio + .5); if (settingData.QuickMenuSettings.Count > 0) { doubleEditWidth = (int)(35 * TextWidget.GlobalPointSizeScaleRatio + .5); } int vectorXYEditWidth = (int)(60 * TextWidget.GlobalPointSizeScaleRatio + .5); int multiLineEditHeight = (int)(60 * TextWidget.GlobalPointSizeScaleRatio + .5); string sliceSettingValue = ActiveSliceSettings.Instance.GetActiveValue(settingData.SlicerConfigName); leftToRightLayout.Margin = new BorderDouble(0, 2); leftToRightLayout.Padding = new BorderDouble(3); leftToRightLayout.HAnchor = Agg.UI.HAnchor.ParentLeftRight; if (settingData.DataEditType != OrganizerSettingsData.DataEditTypes.MULTI_LINE_TEXT) { string convertedNewLines = settingData.PresentationName.Replace("\\n ", "\n"); convertedNewLines = convertedNewLines.Replace("\\n", "\n"); convertedNewLines = LocalizedString.Get(convertedNewLines); TextWidget settingName = new TextWidget(convertedNewLines, pointSize: 10); settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor; settingName.VAnchor = Agg.UI.VAnchor.ParentCenter; #if DO_IN_PLACE_EDIT if (SettingsIndexBeingEdited != 0) { if (ActiveSliceSettings.Instance.SettingExistsInLayer(settingData.SlicerConfigName, SettingsIndexBeingEdited)) { CheckBox removeFromSettingCheckBox = new CheckBox(""); removeFromSettingCheckBox.Checked = true; removeFromSettingCheckBox.VAnchor = VAnchor.ParentCenter; leftToRightLayout.AddChild(removeFromSettingCheckBox); } else { CheckBox addToSettingCheckBox = new CheckBox(""); addToSettingCheckBox.VAnchor = VAnchor.ParentCenter; leftToRightLayout.AddChild(addToSettingCheckBox); } } #endif settingName.Width = minSettingNameWidth; //settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.MinimumSize.y); leftToRightLayout.AddChild(settingName); } if (ActiveSliceSettings.Instance.SettingExistsInLayer(settingData.SlicerConfigName, 3)) { addMaterialOverlay = true; } else if (ActiveSliceSettings.Instance.SettingExistsInLayer(settingData.SlicerConfigName, 2)) { addQualityOverlay = true; } switch (settingData.DataEditType) { case OrganizerSettingsData.DataEditTypes.INT: { int currentValue = 0; int.TryParse(sliceSettingValue, out currentValue); MHNumberEdit intEditWidget = new MHNumberEdit(currentValue, pixelWidth: intEditWidth, tabIndex: tabIndexForItem++); intEditWidget.ToolTipText = settingData.HelpText; intEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); CallEventsOnSettingsChange(settingData); }; intEditWidget.SelectAllOnFocus = true; leftToRightLayout.AddChild(intEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.DOUBLE: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowNegatives: true, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ToolTipText = settingData.HelpText; doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); CallEventsOnSettingsChange(settingData); }; doubleEditWidget.SelectAllOnFocus = true; leftToRightLayout.AddChild(doubleEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.POSITIVE_DOUBLE: { const string multiValuesAreDiffernt = "-"; FlowLayoutWidget content = new FlowLayoutWidget(); MHNumberEdit doubleEditWidget = new MHNumberEdit(0, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ToolTipText = settingData.HelpText; double currentValue = 0; bool ChangesMultipleOtherSettings = settingData.SetSettingsOnChange.Count > 0; if (ChangesMultipleOtherSettings) { bool allTheSame = true; string setting = ActiveSliceSettings.Instance.GetActiveValue(settingData.SetSettingsOnChange[0]); for (int i = 1; i < settingData.SetSettingsOnChange.Count; i++) { string nextSetting = ActiveSliceSettings.Instance.GetActiveValue(settingData.SetSettingsOnChange[i]); if (setting != nextSetting) { allTheSame = false; break; } } if (allTheSame && setting.EndsWith("mm")) { double.TryParse(setting.Substring(0, setting.Length-2), out currentValue); doubleEditWidget.ActuallNumberEdit.Value = currentValue; } else { doubleEditWidget.ActuallNumberEdit.InternalNumberEdit.Text = multiValuesAreDiffernt; } } else // just set the setting nomrmaly { double.TryParse(sliceSettingValue, out currentValue); doubleEditWidget.ActuallNumberEdit.Value = currentValue; } doubleEditWidget.ActuallNumberEdit.InternalTextEditWidget.MarkAsStartingState(); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { NumberEdit numberEdit = (NumberEdit)sender; // If this setting sets other settings, then do that. if (ChangesMultipleOtherSettings && numberEdit.Text != multiValuesAreDiffernt) { foreach (string setting in settingData.SetSettingsOnChange) { SaveSetting(setting, numberEdit.Value.ToString() + "mm"); } } // also always save to the local setting SaveSetting(settingData.SlicerConfigName, numberEdit.Value.ToString()); CallEventsOnSettingsChange(settingData); }; doubleEditWidget.SelectAllOnFocus = true; content.AddChild(doubleEditWidget); content.AddChild(getSettingInfoData(settingData)); if (settingData.QuickMenuSettings.Count > 0) { leftToRightLayout.AddChild(CreateQuickMenu(settingData, content, doubleEditWidget.ActuallNumberEdit.InternalTextEditWidget)); } else { leftToRightLayout.AddChild(content); } } break; case OrganizerSettingsData.DataEditTypes.OFFSET: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, allowNegatives: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ToolTipText = settingData.HelpText; doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); CallEventsOnSettingsChange(settingData); }; doubleEditWidget.SelectAllOnFocus = true; leftToRightLayout.AddChild(doubleEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.DOUBLE_OR_PERCENT: { FlowLayoutWidget content = new FlowLayoutWidget(); MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: doubleEditWidth - 2, tabIndex: tabIndexForItem++); stringEdit.ToolTipText = settingData.HelpText; stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { TextEditWidget textEditWidget = (TextEditWidget)sender; string text = textEditWidget.Text; text = text.Trim(); bool isPercent = text.Contains("%"); if (isPercent) { text = text.Substring(0, text.IndexOf("%")); } double result; double.TryParse(text, out result); text = result.ToString(); if (isPercent) { text += "%"; } textEditWidget.Text = text; SaveSetting(settingData.SlicerConfigName, textEditWidget.Text); CallEventsOnSettingsChange(settingData); }; stringEdit.SelectAllOnFocus = true; stringEdit.ActualTextEditWidget.InternalTextEditWidget.AllSelected += (sender, e) => { // select evrything up to the % (if present) InternalTextEditWidget textEditWidget = (InternalTextEditWidget)sender; int percentIndex = textEditWidget.Text.IndexOf("%"); if (percentIndex != -1) { textEditWidget.SetSelection(0, percentIndex-1); } }; content.AddChild(stringEdit); content.AddChild(getSettingInfoData(settingData)); if (settingData.QuickMenuSettings.Count > 0) { leftToRightLayout.AddChild(CreateQuickMenu(settingData, content, stringEdit.ActualTextEditWidget.InternalTextEditWidget)); } else { leftToRightLayout.AddChild(content); } } break; case OrganizerSettingsData.DataEditTypes.INT_OR_MM: { FlowLayoutWidget content = new FlowLayoutWidget(); MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: doubleEditWidth - 2, tabIndex: tabIndexForItem++); stringEdit.ToolTipText = settingData.HelpText; stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { TextEditWidget textEditWidget = (TextEditWidget)sender; string text = textEditWidget.Text; text = text.Trim(); bool isMm = text.Contains("mm"); if (isMm) { text = text.Substring(0, text.IndexOf("mm")); } double result; double.TryParse(text, out result); text = result.ToString(); if (isMm) { text += "mm"; } else { result = (int)result; text = result.ToString(); } textEditWidget.Text = text; SaveSetting(settingData.SlicerConfigName, textEditWidget.Text); CallEventsOnSettingsChange(settingData); }; stringEdit.SelectAllOnFocus = true; stringEdit.ActualTextEditWidget.InternalTextEditWidget.AllSelected += (sender, e) => { // select evrything up to the mm (if present) InternalTextEditWidget textEditWidget = (InternalTextEditWidget)sender; int mMIndex = textEditWidget.Text.IndexOf("mm"); if (mMIndex != -1) { textEditWidget.SetSelection(0, mMIndex-1); } }; content.AddChild(stringEdit); content.AddChild(getSettingInfoData(settingData)); if (settingData.QuickMenuSettings.Count > 0) { leftToRightLayout.AddChild(CreateQuickMenu(settingData, content, stringEdit.ActualTextEditWidget.InternalTextEditWidget)); } else { leftToRightLayout.AddChild(content); } } break; case OrganizerSettingsData.DataEditTypes.CHECK_BOX: { CheckBox checkBoxWidget = new CheckBox(""); checkBoxWidget.ToolTipText = settingData.HelpText; checkBoxWidget.VAnchor = Agg.UI.VAnchor.ParentBottom; checkBoxWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; checkBoxWidget.Checked = (sliceSettingValue == "1"); checkBoxWidget.CheckedStateChanged += (sender, e) => { if (((CheckBox)sender).Checked) { SaveSetting(settingData.SlicerConfigName, "1"); } else { SaveSetting(settingData.SlicerConfigName, "0"); } CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(checkBoxWidget); } break; case OrganizerSettingsData.DataEditTypes.STRING: { MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: 120, tabIndex: tabIndexForItem++); stringEdit.ToolTipText = settingData.HelpText; stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text); CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(stringEdit); } break; case OrganizerSettingsData.DataEditTypes.MULTI_LINE_TEXT: { string convertedNewLines = sliceSettingValue.Replace("\\n", "\n"); MHTextEditWidget stringEdit = new MHTextEditWidget(convertedNewLines, pixelWidth: 320, pixelHeight: multiLineEditHeight, multiLine: true, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text.Replace("\n", "\\n")); CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(stringEdit); } break; case OrganizerSettingsData.DataEditTypes.LIST: { StyledDropDownList selectableOptions = new StyledDropDownList("None", maxHeight: 200); selectableOptions.ToolTipText = settingData.HelpText; selectableOptions.Margin = new BorderDouble(); string[] listItems = settingData.ExtraSettings.Split(','); foreach (string listItem in listItems) { MenuItem newItem = selectableOptions.AddItem(listItem); if (newItem.Text == sliceSettingValue) { selectableOptions.SelectedLabel = sliceSettingValue; } newItem.Selected += (sender, e) => { MenuItem menuItem = ((MenuItem)sender); SaveSetting(settingData.SlicerConfigName, menuItem.Text); CallEventsOnSettingsChange(settingData); }; } leftToRightLayout.AddChild(selectableOptions); } break; case OrganizerSettingsData.DataEditTypes.HARDWARE_PRESENT: { CheckBox checkBoxWidget = new CheckBox(""); checkBoxWidget.ToolTipText = settingData.HelpText; checkBoxWidget.VAnchor = Agg.UI.VAnchor.ParentBottom; checkBoxWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; checkBoxWidget.Checked = (sliceSettingValue == "1"); checkBoxWidget.CheckedStateChanged += (sender, e) => { if (((CheckBox)sender).Checked) { SaveSetting(settingData.SlicerConfigName, "1"); // Now show all of the settings that this control is associated with. } else { SaveSetting(settingData.SlicerConfigName, "0"); // Now hide all of the settings that this control is associated with. } CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(checkBoxWidget); } break; case OrganizerSettingsData.DataEditTypes.VECTOR2: { string[] xyValueStrings = sliceSettingValue.Split(','); if (xyValueStrings.Length != 2) { xyValueStrings = new string[] { "0", "0" }; } double currentXValue = 0; double.TryParse(xyValueStrings[0], out currentXValue); MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); xEditWidget.ToolTipText = settingData.HelpText; double currentYValue = 0; double.TryParse(xyValueStrings[1], out currentYValue); MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); yEditWidget.ToolTipText = settingData.HelpText; xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); CallEventsOnSettingsChange(settingData); }; xEditWidget.SelectAllOnFocus = true; leftToRightLayout.AddChild(xEditWidget); leftToRightLayout.AddChild(new HorizontalSpacer()); yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); CallEventsOnSettingsChange(settingData); }; yEditWidget.SelectAllOnFocus = true; leftToRightLayout.AddChild(yEditWidget); } break; case OrganizerSettingsData.DataEditTypes.OFFSET2: { Vector2 offset = ActiveSliceSettings.Instance.GetOffset(extruderIndex); MHNumberEdit xEditWidget = new MHNumberEdit(offset.x, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); xEditWidget.ToolTipText = settingData.HelpText; MHNumberEdit yEditWidget = new MHNumberEdit(offset.y, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); yEditWidget.ToolTipText = settingData.HelpText; { xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { int extruderIndexLocal = extruderIndex; SaveCommaSeparatedIndexSetting(extruderIndexLocal, settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); CallEventsOnSettingsChange(settingData); }; xEditWidget.SelectAllOnFocus = true; leftToRightLayout.AddChild(xEditWidget); leftToRightLayout.AddChild(new HorizontalSpacer()); } { yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { int extruderIndexLocal = extruderIndex; SaveCommaSeparatedIndexSetting(extruderIndexLocal, settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); CallEventsOnSettingsChange(settingData); }; yEditWidget.SelectAllOnFocus = true; leftToRightLayout.AddChild(yEditWidget); } } break; default: TextWidget missingSetting = new TextWidget(String.Format("Missing the setting for '{0}'.", settingData.DataEditType.ToString())); missingSetting.TextColor = ActiveTheme.Instance.PrimaryTextColor; missingSetting.BackgroundColor = RGBA_Bytes.Red; leftToRightLayout.AddChild(missingSetting); break; } } else // the setting we think we are adding is not in the config.ini it may have been depricated { TextWidget settingName = new TextWidget(String.Format("Setting '{0}' not found in config.ini", settingData.SlicerConfigName)); settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor; settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.MinimumSize.y); leftToRightLayout.AddChild(settingName); leftToRightLayout.BackgroundColor = RGBA_Bytes.Red; } container.HAnchor = HAnchor.ParentLeftRight; container.VAnchor = VAnchor.FitToChildren; container.AddChild(leftToRightLayout); if (addQualityOverlay || addMaterialOverlay) { SettingPresetOverlay overlay = new SettingPresetOverlay(); overlay.HAnchor = HAnchor.ParentLeftRight; overlay.VAnchor = Agg.UI.VAnchor.ParentBottomTop; SettingPresetClick clickToEdit = new SettingPresetClick(); clickToEdit.HAnchor = HAnchor.ParentLeftRight; clickToEdit.VAnchor = Agg.UI.VAnchor.ParentBottomTop; clickToEdit.Visible = false; Button editButton = buttonFactory.Generate("Edit Preset".Localize().ToUpper()); editButton.HAnchor = Agg.UI.HAnchor.ParentCenter; editButton.VAnchor = Agg.UI.VAnchor.ParentCenter; clickToEdit.AddChild(editButton); if (addQualityOverlay) { overlay.OverlayColor = qualityOverlayColor; clickToEdit.OverlayColor = qualityOverlayColor; editButton.Click += (sender, e) => { if (ApplicationController.Instance.EditQualityPresetsWindow == null) { ApplicationController.Instance.EditQualityPresetsWindow = new SlicePresetsWindow(ReloadOptions, "Quality", "quality", false, ActivePrinterProfile.Instance.ActiveQualitySettingsID); ApplicationController.Instance.EditQualityPresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationController.Instance.EditQualityPresetsWindow = null; }; } else { ApplicationController.Instance.EditQualityPresetsWindow.ChangeToSlicePresetFromID(ActivePrinterProfile.Instance.ActiveQualitySettingsID); ApplicationController.Instance.EditQualityPresetsWindow.BringToFront(); } }; } else if (addMaterialOverlay) { overlay.OverlayColor = materialOverlayColor; clickToEdit.OverlayColor = materialOverlayColor; editButton.Click += (sender, e) => { if (ApplicationController.Instance.EditMaterialPresetsWindow == null) { ApplicationController.Instance.EditMaterialPresetsWindow = new SlicePresetsWindow(ReloadOptions, "Material", "material", false, ActivePrinterProfile.Instance.GetMaterialSetting(1)); ApplicationController.Instance.EditMaterialPresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationController.Instance.EditMaterialPresetsWindow = null; }; } else { ApplicationController.Instance.EditMaterialPresetsWindow.ChangeToSlicePresetFromID(ActivePrinterProfile.Instance.GetMaterialSetting(1)); ApplicationController.Instance.EditMaterialPresetsWindow.BringToFront(); } }; } container.MouseEnterBounds += (sender, e) => { UiThread.RunOnIdle(() => { overlay.Visible = false; clickToEdit.Visible = true; }); }; container.MouseLeaveBounds += (sender, e) => { UiThread.RunOnIdle(() => { overlay.Visible = true; clickToEdit.Visible = false; }); }; container.AddChild(overlay); container.AddChild(clickToEdit); } return container; }
private GuiWidget CreateSettingInfoUIControls(OrganizerSettingsData settingData, double minSettingNameWidth) { GuiWidget container = new GuiWidget(); FlowLayoutWidget leftToRightLayout = new FlowLayoutWidget(); bool addQualityOverlay = false; bool addMaterialOverlay = false; RGBA_Bytes qualityOverlayColor = new RGBA_Bytes(255, 255, 0, 40); RGBA_Bytes materialOverlayColor = new RGBA_Bytes(255, 127, 0, 40); if (ActiveSliceSettings.Instance.Contains(settingData.SlicerConfigName)) { int intEditWidth = 60; int doubleEditWidth = 60; int vectorXYEditWidth = 60; int multiLineEditHeight = 60; string sliceSettingValue = ActiveSliceSettings.Instance.GetActiveValue(settingData.SlicerConfigName); leftToRightLayout.Margin = new BorderDouble(0, 2); leftToRightLayout.Padding = new BorderDouble(3); leftToRightLayout.HAnchor = Agg.UI.HAnchor.ParentLeftRight; if (settingData.DataEditType != OrganizerSettingsData.DataEditTypes.MULTI_LINE_TEXT) { string convertedNewLines = settingData.PresentationName.Replace("\\n ", "\n"); convertedNewLines = convertedNewLines.Replace("\\n", "\n"); convertedNewLines = LocalizedString.Get(convertedNewLines); TextWidget settingName = new TextWidget(convertedNewLines); settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor; if (ActiveSliceSettings.Instance.SettingExistsInLayer(settingData.SlicerConfigName, 3)) { addMaterialOverlay = true; } else if (ActiveSliceSettings.Instance.SettingExistsInLayer(settingData.SlicerConfigName, 2)) { addQualityOverlay = true; } settingName.Width = minSettingNameWidth; //settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.MinimumSize.y); leftToRightLayout.AddChild(settingName); } switch (settingData.DataEditType) { case OrganizerSettingsData.DataEditTypes.INT: { int currentValue = 0; int.TryParse(sliceSettingValue, out currentValue); MHNumberEdit intEditWidget = new MHNumberEdit(currentValue, pixelWidth: intEditWidth, tabIndex: tabIndexForItem++); intEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(intEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.DOUBLE: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowNegatives: true, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(doubleEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.POSITIVE_DOUBLE: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(doubleEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.OFFSET: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, allowNegatives: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(doubleEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.DOUBLE_OR_PERCENT: { MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: 60, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { TextEditWidget textEditWidget = (TextEditWidget)sender; string text = textEditWidget.Text; text = text.Trim(); bool isPercent = text.Contains("%"); if (isPercent) { text = text.Substring(0, text.IndexOf("%")); } double result; double.TryParse(text, out result); text = result.ToString(); if (isPercent) { text += "%"; } textEditWidget.Text = text; SaveSetting(settingData.SlicerConfigName, textEditWidget.Text); CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(stringEdit); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.CHECK_BOX: { CheckBox checkBoxWidget = new CheckBox(""); checkBoxWidget.VAnchor = Agg.UI.VAnchor.ParentBottom; checkBoxWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; checkBoxWidget.Checked = (sliceSettingValue == "1"); checkBoxWidget.CheckedStateChanged += (sender, e) => { if (((CheckBox)sender).Checked) { SaveSetting(settingData.SlicerConfigName, "1"); } else { SaveSetting(settingData.SlicerConfigName, "0"); } CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(checkBoxWidget); } break; case OrganizerSettingsData.DataEditTypes.STRING: { MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: 120, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text); CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(stringEdit); } break; case OrganizerSettingsData.DataEditTypes.MULTI_LINE_TEXT: { string convertedNewLines = sliceSettingValue.Replace("\\n", "\n"); MHTextEditWidget stringEdit = new MHTextEditWidget(convertedNewLines, pixelWidth: 320, pixelHeight: multiLineEditHeight, multiLine: true, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text.Replace("\n", "\\n")); CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(stringEdit); } break; case OrganizerSettingsData.DataEditTypes.LIST: { StyledDropDownList selectableOptions = new StyledDropDownList("None", maxHeight: 200); selectableOptions.Margin = new BorderDouble(); string[] listItems = settingData.ExtraSettings.Split(','); foreach (string listItem in listItems) { MenuItem newItem = selectableOptions.AddItem(listItem); if (newItem.Text == sliceSettingValue) { selectableOptions.SelectedLabel = sliceSettingValue; } newItem.Selected += (sender, e) => { MenuItem menuItem = ((MenuItem)sender); SaveSetting(settingData.SlicerConfigName, menuItem.Text); CallEventsOnSettingsChange(settingData); }; } leftToRightLayout.AddChild(selectableOptions); } break; case OrganizerSettingsData.DataEditTypes.HARDWARE_PRESENT: { CheckBox checkBoxWidget = new CheckBox(""); checkBoxWidget.VAnchor = Agg.UI.VAnchor.ParentBottom; checkBoxWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; checkBoxWidget.Checked = (sliceSettingValue == "1"); checkBoxWidget.CheckedStateChanged += (sender, e) => { if (((CheckBox)sender).Checked) { SaveSetting(settingData.SlicerConfigName, "1"); // Now show all of the settings that this control is associated with. } else { SaveSetting(settingData.SlicerConfigName, "0"); // Now hide all of the settings that this control is associated with. } CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(checkBoxWidget); } break; case OrganizerSettingsData.DataEditTypes.VECTOR2: { string[] xyValueStrings = sliceSettingValue.Split(','); if (xyValueStrings.Length != 2) { xyValueStrings = new string[] { "0", "0" }; } double currentXValue = 0; double.TryParse(xyValueStrings[0], out currentXValue); MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); double currentYValue = 0; double.TryParse(xyValueStrings[1], out currentYValue); MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(xEditWidget); TextWidget xText = new TextWidget("x"); xText.TextColor = ActiveTheme.Instance.PrimaryTextColor; xText.Margin = new BorderDouble(5, 0); leftToRightLayout.AddChild(xText); yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(yEditWidget); TextWidget yText = new TextWidget("y"); yText.TextColor = ActiveTheme.Instance.PrimaryTextColor; yText.Margin = new BorderDouble(5, 0); leftToRightLayout.AddChild(yText); } break; case OrganizerSettingsData.DataEditTypes.OFFSET2: { string[] xyValueStrings = sliceSettingValue.Split('x'); if (xyValueStrings.Length != 2) { xyValueStrings = new string[] { "0", "0" }; } double currentXValue = 0; double.TryParse(xyValueStrings[0], out currentXValue); MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); double currentYValue = 0; double.TryParse(xyValueStrings[1], out currentYValue); MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); { xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(xEditWidget); TextWidget xText = new TextWidget("x"); xText.TextColor = ActiveTheme.Instance.PrimaryTextColor; xText.Margin = new BorderDouble(5, 0); leftToRightLayout.AddChild(xText); } { yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); CallEventsOnSettingsChange(settingData); }; leftToRightLayout.AddChild(yEditWidget); TextWidget yText = new TextWidget("y"); yText.TextColor = ActiveTheme.Instance.PrimaryTextColor; yText.Margin = new BorderDouble(5, 0); leftToRightLayout.AddChild(yText); } } break; default: TextWidget missingSetting = new TextWidget(String.Format("Missing the setting for '{0}'.", settingData.DataEditType.ToString())); missingSetting.TextColor = ActiveTheme.Instance.PrimaryTextColor; missingSetting.BackgroundColor = RGBA_Bytes.Red; leftToRightLayout.AddChild(missingSetting); break; } } else // the setting we think we are adding is not in the config.ini it may have been depricated { TextWidget settingName = new TextWidget(String.Format("Setting '{0}' not found in config.ini", settingData.SlicerConfigName)); settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor; settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.MinimumSize.y); leftToRightLayout.AddChild(settingName); leftToRightLayout.BackgroundColor = RGBA_Bytes.Red; } container.HAnchor = HAnchor.ParentLeftRight; container.VAnchor = VAnchor.FitToChildren; container.AddChild(leftToRightLayout); if (addQualityOverlay || addMaterialOverlay) { SettingPresetOverlay overlay = new SettingPresetOverlay(); overlay.HAnchor = HAnchor.ParentLeftRight; overlay.VAnchor = Agg.UI.VAnchor.ParentBottomTop; SettingPresetClick clickToEdit = new SettingPresetClick(); clickToEdit.HAnchor = HAnchor.ParentLeftRight; clickToEdit.VAnchor = Agg.UI.VAnchor.ParentBottomTop; clickToEdit.Visible = false; Button editButton = buttonFactory.Generate("Edit Preset".Localize().ToUpper()); editButton.HAnchor = Agg.UI.HAnchor.ParentCenter; editButton.VAnchor = Agg.UI.VAnchor.ParentCenter; clickToEdit.AddChild(editButton); if (addQualityOverlay) { overlay.OverlayColor = qualityOverlayColor; clickToEdit.OverlayColor = qualityOverlayColor; editButton.Click += (sender, e) => { if (ApplicationWidget.Instance.EditQualityPresetsWindow == null) { ApplicationWidget.Instance.EditQualityPresetsWindow = new SlicePresetsWindow(ReloadOptions, "Quality", "quality", false, ActivePrinterProfile.Instance.ActiveQualitySettingsID); ApplicationWidget.Instance.EditQualityPresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationWidget.Instance.EditQualityPresetsWindow = null; }; } else { ApplicationWidget.Instance.EditQualityPresetsWindow.ChangeToSlicePresetFromID(ActivePrinterProfile.Instance.ActiveQualitySettingsID); ApplicationWidget.Instance.EditQualityPresetsWindow.BringToFront(); } }; } else if (addMaterialOverlay) { overlay.OverlayColor = materialOverlayColor; clickToEdit.OverlayColor = materialOverlayColor; editButton.Click += (sender, e) => { if (ApplicationWidget.Instance.EditMaterialPresetsWindow == null) { ApplicationWidget.Instance.EditMaterialPresetsWindow = new SlicePresetsWindow(ReloadOptions, "Material", "material", false, ActivePrinterProfile.Instance.GetMaterialSetting(1)); ApplicationWidget.Instance.EditMaterialPresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationWidget.Instance.EditMaterialPresetsWindow = null; }; } else { ApplicationWidget.Instance.EditMaterialPresetsWindow.ChangeToSlicePresetFromID(ActivePrinterProfile.Instance.GetMaterialSetting(1)); ApplicationWidget.Instance.EditMaterialPresetsWindow.BringToFront(); } }; } container.MouseEnterBounds += (sender, e) => { UiThread.RunOnIdle((state) => { overlay.Visible = false; clickToEdit.Visible = true; }); }; container.MouseLeaveBounds += (sender, e) => { UiThread.RunOnIdle((state) => { overlay.Visible = true; clickToEdit.Visible = false; }); }; container.AddChild(overlay); container.AddChild(clickToEdit); } return container; }