private GuiWidget CreateDefaultOptions(GuiWidget textField) { var issues = new string[] { "Bad Thermistor", "Bed Dislodged", "Bowden Tube Popped Out", "Computer Crashed", "Computer Slow/Lagging", "Couldn't Resume", "Dislodged From Bed", "Extruder Slipping", "Filament Jam", "Filament Runout", "Filament Snapped", "First Layer Bad Quality", "Flooded Hot End", "Initial Z Height Incorrect", "Layer Shift", "Power Outage", "Print Quality", "Rough Overhangs", "Skipped Layers", "Some Parts Lifted", "Stringing / Poor retractions", "Test Print", "Thermal Runaway - Bed", "Thermal Runaway - Hot End", "Thermal Runaway", "Took Too Long To Heat", "User Error", "Warping", "Wouldn’t Slice Correctly", }; var dropdownList = new MHDropDownList("Standard Issues".Localize(), theme, maxHeight: 300 * GuiWidget.DeviceScale); foreach (var issue in issues) { MenuItem newItem = dropdownList.AddItem(issue); newItem.Selected += (sender, e) => { textField.Text = issue; }; } return(dropdownList); }
private DropDownList CreateDropdown() { var dropDownList = new MHDropDownList(defaultMenuItemText, theme, maxHeight: 300, useLeftIcons: true) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Center, MenuItemsPadding = new BorderDouble(10, 7, 7, 7), }; dropDownList.Name = layerType.ToString() + " DropDown List"; dropDownList.Margin = 0; dropDownList.MinimumSize = new Vector2(dropDownList.LocalBounds.Width, dropDownList.LocalBounds.Height); MenuItem defaultMenuItem = dropDownList.AddItem(defaultMenuItemText, ""); defaultMenuItem.Selected += MenuItem_Selected; var listSource = (layerType == NamedSettingsLayers.Material) ? printer.Settings.MaterialLayers : printer.Settings.QualityLayers; foreach (var layer in listSource.OrderBy(l => l.Name)) { MenuItem menuItem = dropDownList.AddItem(layer.Name, layer.LayerID); menuItem.Name = layer.Name + " Menu"; menuItem.Selected += MenuItem_Selected; } MenuItem addNewPreset = dropDownList.AddItem( AggContext.StaticData.LoadIcon("icon_plus.png", 16, 16), "Add New Setting".Localize() + "...", "new", pointSize: theme.DefaultFontSize); addNewPreset.Selected += (s, e) => { var newLayer = new PrinterSettingsLayer(); if (layerType == NamedSettingsLayers.Quality) { newLayer.Name = "Quality" + printer.Settings.QualityLayers.Count; printer.Settings.QualityLayers.Add(newLayer); printer.Settings.ActiveQualityKey = newLayer.LayerID; } else { newLayer.Name = "Material" + printer.Settings.MaterialLayers.Count; printer.Settings.MaterialLayers.Add(newLayer); printer.Settings.ActiveMaterialKey = newLayer.LayerID; } RebuildDropDownList(); editButton.OnClick(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); }; try { string settingsKey; if (layerType == NamedSettingsLayers.Material) { if (extruderIndex == 0) { settingsKey = printer.Settings.ActiveMaterialKey; } else // try to find the right material based on the extruders temperature { settingsKey = null; var extruderTemp = printer.Settings.GetValue <double>(SettingsKey.temperature1).ToString(); foreach (var materialLayer in printer.Settings.MaterialLayers) { if (materialLayer.TryGetValue(SettingsKey.temperature, out string _temp)) { if (_temp == extruderTemp) { settingsKey = materialLayer.LayerID; } } } } } else { settingsKey = printer.Settings.ActiveQualityKey; } if (!string.IsNullOrEmpty(settingsKey)) { dropDownList.SelectedValue = settingsKey; } } catch (Exception ex) { GuiWidget.BreakInDebugger(ex.Message); } return(dropDownList); }