public ModelChooser(string manufacturer) { string defaultModelDropDownLabel = LocalizedString.Get("Select Model"); string defaultModelDropDownLabelFull = string.Format("- {0} -", defaultModelDropDownLabel); ModelDropList = new StyledDropDownList(defaultModelDropDownLabelFull, maxHeight: 200); ModelDropList.Name = defaultModelDropDownLabel; string pathToModels = Path.Combine("PrinterSettings", manufacturer); if (StaticData.Instance.DirectoryExists((pathToModels))) { foreach (string manufacturerDirectory in StaticData.Instance.GetDirectories(pathToModels)) { string model = Path.GetFileName(manufacturerDirectory); ModelDropList.AddItem(model); countOfModels += 1; } } ModelDropList.AddItem(LocalizedString.Get("Other")); AddChild(ModelDropList); HAnchor = HAnchor.FitToChildren; VAnchor = VAnchor.FitToChildren; }
public PrinterChooser(string selectedMake = null) { string defaultManufacturerLbl = new LocalizedString("Select Make").Translated; string defaultManufacturerLblFull = string.Format("- {0} -", defaultManufacturerLbl); ManufacturerDropList = new StyledDropDownList(defaultManufacturerLblFull); bool addOther = false; string pathToWhitelist = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "OEMSettings", "PrinterSettingsWhitelist.txt"); string[] folderWhitelist = File.ReadAllLines(pathToWhitelist); string pathToManufacturers = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "PrinterSettings"); if (Directory.Exists(pathToManufacturers)) { int index = 0; int preselectIndex = -1; foreach (string manufacturerDirectory in Directory.EnumerateDirectories(pathToManufacturers)) { string folderName = new System.IO.DirectoryInfo(manufacturerDirectory).Name; if (folderWhitelist.Contains(folderName)) { string manufacturer = Path.GetFileName(manufacturerDirectory); if (manufacturer == "Other") { addOther = true; } else { ManufacturerDropList.AddItem(manufacturer); if (selectedMake != null) { if (manufacturer == selectedMake) { preselectIndex = index; } } index++; } } } if (addOther) { if (selectedMake != null && preselectIndex == -1) { preselectIndex = index; } ManufacturerDropList.AddItem(new LocalizedString("Other").Translated); } if (preselectIndex != -1) { ManufacturerDropList.SelectedIndex = preselectIndex; } } AddChild(ManufacturerDropList); HAnchor = HAnchor.FitToChildren; VAnchor = VAnchor.FitToChildren; }
StyledDropDownList CreateSliceEngineDropdown() { StyledDropDownList engineMenuDropList = new StyledDropDownList("Engine "); engineMenuDropList.Margin = new BorderDouble(top: 3, left: 0); { MenuItem slic3rMenuItem = engineMenuDropList.AddItem(PrinterCommunication.SlicingEngine.Slic3r.ToString()); slic3rMenuItem.Selected += (sender, e) => { PrinterCommunication.Instance.ActiveSliceEngine = PrinterCommunication.SlicingEngine.Slic3r; MainSlidePanel.Instance.ReloadBackPanel(); }; MenuItem curaEnginMenuItem = engineMenuDropList.AddItem(PrinterCommunication.SlicingEngine.CuraEngine.ToString()); curaEnginMenuItem.Selected += (sender, e) => { PrinterCommunication.Instance.ActiveSliceEngine = PrinterCommunication.SlicingEngine.CuraEngine; MainSlidePanel.Instance.ReloadBackPanel(); }; #if false MenuItem matterSliceMenuItem = engineMenuDropList.AddItem(PrinterCommunication.SlicingEngine.MatterSlice.ToString()); matterSliceMenuItem.Selected += (sender, e) => { PrinterCommunication.Instance.ActiveSliceEngine = PrinterCommunication.SlicingEngine.MatterSlice; MainSlidePanel.Instance.ReloadBackPanel(); }; #endif engineMenuDropList.SelectedValue = PrinterCommunication.Instance.ActiveSliceEngine.ToString(); } engineMenuDropList.MinimumSize = new Vector2(engineMenuDropList.LocalBounds.Width, engineMenuDropList.LocalBounds.Height); return(engineMenuDropList); }
public PrinterChooser(string selectedMake = null) { string defaultManufacturerLbl = new LocalizedString ("Select Make").Translated; string defaultManufacturerLblFull = string.Format ("- {0} -", defaultManufacturerLbl); ManufacturerDropList = new StyledDropDownList(defaultManufacturerLblFull); bool addOther = false; string pathToWhitelist = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "OEMSettings", "PrinterSettingsWhitelist.txt"); string[] folderWhitelist = File.ReadAllLines(pathToWhitelist); string pathToManufacturers = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "PrinterSettings"); if (Directory.Exists(pathToManufacturers)) { int index = 0; int preselectIndex = -1; foreach (string manufacturerDirectory in Directory.EnumerateDirectories(pathToManufacturers)) { string folderName = new System.IO.DirectoryInfo(manufacturerDirectory).Name; if (folderWhitelist.Contains(folderName)) { string manufacturer = Path.GetFileName(manufacturerDirectory); if (manufacturer == "Other") { addOther = true; } else { ManufacturerDropList.AddItem(manufacturer); if (selectedMake != null) { if (manufacturer == selectedMake) { preselectIndex = index; } } index++; } } } if (addOther) { if (selectedMake != null && preselectIndex == -1) { preselectIndex = index; } ManufacturerDropList.AddItem(new LocalizedString("Other").Translated); } if (preselectIndex != -1) { ManufacturerDropList.SelectedIndex = preselectIndex; } } AddChild(ManufacturerDropList); HAnchor = HAnchor.FitToChildren; VAnchor = VAnchor.FitToChildren; }
public void AddReleaseOptions(FlowLayoutWidget controlsTopToBottom) { AltGroupBox releaseOptionsGroupBox = new AltGroupBox(LocalizedString.Get("Update Feed")); releaseOptionsGroupBox.Margin = new BorderDouble(0); releaseOptionsGroupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor; releaseOptionsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor; releaseOptionsGroupBox.HAnchor = Agg.UI.HAnchor.ParentLeftRight; releaseOptionsGroupBox.VAnchor = Agg.UI.VAnchor.ParentTop; releaseOptionsGroupBox.Height = 68; FlowLayoutWidget controlsContainer = new FlowLayoutWidget(); controlsContainer.HAnchor |= HAnchor.ParentCenter; var releaseOptionsDropList = new StyledDropDownList("Development"); releaseOptionsDropList.Margin = new BorderDouble(0, 3); MenuItem releaseOptionsDropDownItem = releaseOptionsDropList.AddItem("Release", "release"); releaseOptionsDropDownItem.Selected += new EventHandler(FixTabDot); MenuItem preReleaseDropDownItem = releaseOptionsDropList.AddItem("Pre-Release", "pre-release"); preReleaseDropDownItem.Selected += new EventHandler(FixTabDot); MenuItem developmentDropDownItem = releaseOptionsDropList.AddItem("Development", "development"); developmentDropDownItem.Selected += new EventHandler(FixTabDot); releaseOptionsDropList.MinimumSize = new Vector2(releaseOptionsDropList.LocalBounds.Width, releaseOptionsDropList.LocalBounds.Height); List <string> acceptableUpdateFeedTypeValues = new List <string>() { "release", "pre-release", "development" }; string currentUpdateFeedType = UserSettings.Instance.get("UpdateFeedType"); if (acceptableUpdateFeedTypeValues.IndexOf(currentUpdateFeedType) == -1) { UserSettings.Instance.set("UpdateFeedType", "release"); } releaseOptionsDropList.SelectedValue = UserSettings.Instance.get("UpdateFeedType"); releaseOptionsDropList.SelectionChanged += new EventHandler(ReleaseOptionsDropList_SelectionChanged); controlsContainer.AddChild(releaseOptionsDropList); releaseOptionsGroupBox.AddChild(controlsContainer); controlsTopToBottom.AddChild(releaseOptionsGroupBox); }
public ModelChooser(string manufacturer) { string defaultModelDropDownLbl = new LocalizedString("Select Model").Translated; string defaultModelDropDownLblFull = string.Format("- {0} -", defaultModelDropDownLbl); ModelDropList = new StyledDropDownList(defaultModelDropDownLblFull); string pathToModels = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "PrinterSettings", manufacturer); if (Directory.Exists(pathToModels)) { foreach (string manufacturerDirectory in Directory.EnumerateDirectories(pathToModels)) { string model = Path.GetFileName(manufacturerDirectory); ModelDropList.AddItem(model); } } ModelDropList.AddItem(new LocalizedString("Other").Translated); AddChild(ModelDropList); HAnchor = HAnchor.FitToChildren; VAnchor = VAnchor.FitToChildren; }
public PrinterChooser(string selectedMake = null) { string defaultManufacturerLabel = LocalizedString.Get("Select Make"); string defaultManufacturerLabelFull = string.Format("- {0} -", defaultManufacturerLabel); ManufacturerDropList = new StyledDropDownList(defaultManufacturerLabelFull, maxHeight: 200); ManufacturerDropList.Name = "Select Make"; bool addOther = false; string[] printerWhiteListStrings = OemSettings.Instance.PrinterWhiteList.ToArray(); List <ManufacturerNameMapping> manufacturerNameMappings = OemSettings.Instance.ManufacturerNameMappings; string pathToManufacturers = "PrinterSettings"; if (StaticData.Instance.DirectoryExists(pathToManufacturers)) { int index = 0; int preselectIndex = -1; foreach (string manufacturerDirectory in StaticData.Instance.GetDirectories(pathToManufacturers)) { string folderName = Path.GetFileName(manufacturerDirectory.TrimEnd(new[] { '/', '\\' })); // Apply whitelist if (!printerWhiteListStrings.Contains(folderName)) { continue; } // Set manufacturer name to the directory name this.manufacturer = Path.GetFileName(manufacturerDirectory); // Override the manufacturer name if a manufacturerNameMappings exists foreach (ManufacturerNameMapping nameMapping in manufacturerNameMappings) { if (nameMapping.NameOnDisk == folderName) { this.manufacturer = nameMapping.NameToDisplay; break; } } if (this.manufacturer == "Other") { addOther = true; } else { ManufacturerDropList.AddItem(manufacturer, folderName); if (selectedMake != null) { if (this.manufacturer == selectedMake) { preselectIndex = index; } } index++; } countOfMakes += 1; } if (addOther) { if (selectedMake != null && preselectIndex == -1) { preselectIndex = index; } ManufacturerDropList.AddItem(LocalizedString.Get("Other")); } if (preselectIndex != -1) { ManufacturerDropList.SelectedIndex = preselectIndex; } } if (ManufacturerDropList.MenuItems.Count == 1) { ManufacturerDropList.SelectedIndex = 0; } AddChild(ManufacturerDropList); HAnchor = HAnchor.FitToChildren; VAnchor = VAnchor.FitToChildren; }
public PrinterChooser(string selectedMake = null) { string defaultManufacturerLabel = LocalizedString.Get("Select Make"); string defaultManufacturerLabelFull = string.Format("- {0} -", defaultManufacturerLabel); ManufacturerDropList = new StyledDropDownList(defaultManufacturerLabelFull, maxHeight: 200); ManufacturerDropList.Name = "Select Make"; bool addOther = false; string[] printerWhiteListStrings = OemSettings.Instance.PrinterWhiteList.ToArray(); List<ManufacturerNameMapping> manufacturerNameMappings = OemSettings.Instance.ManufacturerNameMappings; string pathToManufacturers = "PrinterSettings"; if (StaticData.Instance.DirectoryExists(pathToManufacturers)) { int index = 0; int preselectIndex = -1; foreach (string manufacturerDirectory in StaticData.Instance.GetDirectories(pathToManufacturers)) { string folderName = Path.GetFileName(manufacturerDirectory.TrimEnd(new[] { '/', '\\' })); // Apply whitelist if (!printerWhiteListStrings.Contains(folderName)) { continue; } // Set manufacturer name to the directory name this.manufacturer = Path.GetFileName(manufacturerDirectory); // Override the manufacturer name if a manufacturerNameMappings exists foreach (ManufacturerNameMapping nameMapping in manufacturerNameMappings) { if(nameMapping.NameOnDisk == folderName) { this.manufacturer = nameMapping.NameToDisplay; break; } } if (this.manufacturer == "Other") { addOther = true; } else { ManufacturerDropList.AddItem(manufacturer); if (selectedMake != null) { if (this.manufacturer == selectedMake) { preselectIndex = index; } } index++; } countOfMakes += 1; } if (addOther) { if (selectedMake != null && preselectIndex == -1) { preselectIndex = index; } ManufacturerDropList.AddItem(LocalizedString.Get("Other")); } if (preselectIndex != -1) { ManufacturerDropList.SelectedIndex = preselectIndex; } } if (ManufacturerDropList.MenuItems.Count == 1) { ManufacturerDropList.SelectedIndex = 0; } AddChild(ManufacturerDropList); HAnchor = HAnchor.FitToChildren; VAnchor = VAnchor.FitToChildren; }
public ModelChooser(string manufacturer) { string defaultModelDropDownLabel = LocalizedString.Get("Select Model"); string defaultModelDropDownLabelFull = string.Format("- {0} -", defaultModelDropDownLabel); ModelDropList = new StyledDropDownList(defaultModelDropDownLabelFull, maxHeight: 200); ModelDropList.Name = defaultModelDropDownLabel; string pathToModels = Path.Combine("PrinterSettings", manufacturer); if (StaticData.Instance.DirectoryExists((pathToModels))) { foreach (string manufacturerDirectory in StaticData.Instance.GetDirectories(pathToModels)) { string model = Path.GetFileName(manufacturerDirectory); ModelDropList.AddItem(model); countOfModels += 1; } } ModelDropList.AddItem(LocalizedString.Get("Other")); AddChild(ModelDropList); HAnchor = HAnchor.FitToChildren; VAnchor = VAnchor.FitToChildren; }
void AddChildElements() { FlowLayoutWidget settingsStatusLabelContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); settingsStatusLabelContainer.VAnchor |= VAnchor.ParentTop; settingsStatusLabelContainer.Margin = new BorderDouble(0); { string activeSettingsLabelText = new LocalizedString("Active Settings").Translated; string activeSettingsLabelTextFull = string.Format("{0}:", activeSettingsLabelText); TextWidget settingsStatusLabel = new TextWidget(string.Format(activeSettingsLabelTextFull), pointSize: 10); settingsStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; settingsStatusDescription = new TextWidget("", pointSize: 14); settingsStatusDescription.Margin = new BorderDouble(top: 4); settingsStatusDescription.AutoExpandBoundsToText = true; settingsStatusDescription.TextColor = ActiveTheme.Instance.PrimaryTextColor; string unsavedChangesTxtBeg = new LocalizedString("unsaved changes").Translated; string unsavedChangesTxtFull = string.Format("({0})", unsavedChangesTxtBeg); unsavedChangesIndicator = new TextWidget(unsavedChangesTxtFull, pointSize: 10); unsavedChangesIndicator.AutoExpandBoundsToText = true; unsavedChangesIndicator.Visible = false; unsavedChangesIndicator.Margin = new BorderDouble(left: 4); unsavedChangesIndicator.TextColor = ActiveTheme.Instance.PrimaryTextColor; settingsStatusLabelContainer.AddChild(settingsStatusLabel); settingsStatusLabelContainer.AddChild(settingsStatusDescription); settingsStatusLabelContainer.AddChild(unsavedChangesIndicator); } saveButton = textImageButtonFactory.Generate(new LocalizedString("Save").Translated); saveButton.VAnchor = VAnchor.ParentTop; saveButton.Visible = false; saveButton.Margin = new BorderDouble(0, 0, 0, 10); saveButton.Click += new ButtonBase.ButtonEventHandler(saveButton_Click); revertbutton = textImageButtonFactory.Generate(new LocalizedString("Revert").Translated); revertbutton.VAnchor = VAnchor.ParentTop; revertbutton.Visible = false; revertbutton.Margin = new BorderDouble(0, 0, 0, 10); revertbutton.Click += new ButtonBase.ButtonEventHandler(revertbutton_Click); SliceOptionsMenuDropList = new DropDownMenu(new LocalizedString("Options ").Translated); SliceOptionsMenuDropList.Margin = new BorderDouble(top: 11); SliceOptionsMenuDropList.VAnchor |= VAnchor.ParentTop; SliceOptionsMenuDropList.HoverColor = new RGBA_Bytes(0, 0, 0, 50); SliceOptionsMenuDropList.NormalColor = new RGBA_Bytes(0, 0, 0, 0); SliceOptionsMenuDropList.BorderColor = new RGBA_Bytes(0, 0, 0, 0); SliceOptionsMenuDropList.BackgroundColor = new RGBA_Bytes(0, 0, 0, 0); this.SliceOptionsMenuDropList.SelectionChanged += new EventHandler(MenuDropList_SelectionChanged); SetMenuItems(); FlowLayoutWidget sliceEngineContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); sliceEngineContainer.Margin = new BorderDouble(0, 0, 10, 0); sliceEngineContainer.VAnchor |= VAnchor.ParentTop; { string sliceEngineLabelText = new LocalizedString("Slice Engine").Translated; string sliceEngineLabelTextFull = string.Format("{0}:", sliceEngineLabelText); TextWidget sliceEngineLabel = new TextWidget(string.Format(sliceEngineLabelTextFull), pointSize: 10); sliceEngineLabel.Margin = new BorderDouble(0); sliceEngineLabel.HAnchor = HAnchor.ParentLeft; sliceEngineLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; EngineMenuDropList = CreateSliceEngineDropdown(); sliceEngineContainer.AddChild(sliceEngineLabel); sliceEngineContainer.AddChild(EngineMenuDropList); } this.AddChild(sliceEngineContainer); this.AddChild(settingsStatusLabelContainer); GuiWidget spacer = new GuiWidget(HAnchor.ParentLeftRight); this.AddChild(spacer); this.AddChild(saveButton); this.AddChild(revertbutton); this.AddChild(SliceOptionsMenuDropList); SetStatusDisplay(); }
public ModelChooser(string manufacturer) { string defaultModelDropDownLbl = new LocalizedString("Select Model").Translated; string defaultModelDropDownLblFull = string.Format("- {0} -", defaultModelDropDownLbl); ModelDropList = new StyledDropDownList(defaultModelDropDownLblFull); string pathToModels = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "PrinterSettings", manufacturer); if (Directory.Exists(pathToModels)) { foreach (string manufacturerDirectory in Directory.EnumerateDirectories(pathToModels)) { string model = Path.GetFileName(manufacturerDirectory); ModelDropList.AddItem(model); } } ModelDropList.AddItem(new LocalizedString("Other").Translated); AddChild(ModelDropList); HAnchor = HAnchor.FitToChildren; VAnchor = VAnchor.FitToChildren; }
public PrinterChooser(string selectedMake = null) { string defaultManufacturerLabel = LocalizedString.Get("Select Make"); string defaultManufacturerLabelFull = string.Format("- {0} -", defaultManufacturerLabel); ManufacturerDropList = new StyledDropDownList(defaultManufacturerLabelFull, maxHeight: 200); bool addOther = false; string[] printerWhiteListStrings = OemSettings.Instance.PrinterWhiteList.ToArray(); string pathToManufacturers = "PrinterSettings"; if (StaticData.Instance.DirectoryExists(pathToManufacturers)) { int index = 0; int preselectIndex = -1; foreach (string manufacturerDirectory in StaticData.Instance.GetDirectories(pathToManufacturers)) { string folderName = Path.GetFileName(manufacturerDirectory.TrimEnd(new[] { '/', '\\' })); if (printerWhiteListStrings.Contains(folderName)) { string manufacturer = Path.GetFileName(manufacturerDirectory); if (manufacturer == "Other") { addOther = true; } else { ManufacturerDropList.AddItem(manufacturer); if (selectedMake != null) { if (manufacturer == selectedMake) { preselectIndex = index; } } index++; } countOfMakes += 1; } } if (addOther) { if (selectedMake != null && preselectIndex == -1) { preselectIndex = index; } ManufacturerDropList.AddItem(LocalizedString.Get("Other")); } if (preselectIndex != -1) { ManufacturerDropList.SelectedIndex = preselectIndex; } } if (ManufacturerDropList.MenuItems.Count == 1) { ManufacturerDropList.SelectedIndex = 0; } AddChild(ManufacturerDropList); HAnchor = HAnchor.FitToChildren; VAnchor = VAnchor.FitToChildren; }
private GuiWidget CreateSettingInfoUIControls(OrganizerSettingsData settingData, double minSettingNameWidth) { FlowLayoutWidget leftToRightLayout = new FlowLayoutWidget(); 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, 5); leftToRightLayout.HAnchor |= Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; if (settingData.DataEditType != OrganizerSettingsData.DataEditTypes.MULTI_LINE_TEXT) { string convertedNewLines = settingData.PresentationName.Replace("\\n ", "\n"); convertedNewLines = convertedNewLines.Replace("\\n", "\n"); convertedNewLines = new LocalizedString(convertedNewLines).Translated; TextWidget settingName = new TextWidget(convertedNewLines); settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor; 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.POSITVE_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", Direction.Up); selectableOptions.Margin = new BorderDouble(); string[] listItems = settingData.ExtraSettings.Split(','); foreach (string listItem in listItems) { MenuItem newItem = selectableOptions.AddItem(listItem); if (newItem.Text == sliceSettingValue) { selectableOptions.SelectedValue = 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; } return(leftToRightLayout); }