public GCodeOptionsPanel(BedConfig sceneContext, PrinterConfig printer, ThemeConfig theme) : base(FlowDirection.TopToBottom) { gcodeOptions = sceneContext.RendererOptions; var buttonPanel = new FlowLayoutWidget() { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit }; var buttonGroup = new ObservableCollection <GuiWidget>(); speedsButton = new RadioIconButton(AggContext.StaticData.LoadIcon("speeds.png", theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroup, Name = "Speeds Button", Checked = gcodeOptions.GCodeLineColorStyle == "Speeds", ToolTipText = "Show Speeds".Localize(), Margin = theme.ButtonSpacing }; speedsButton.Click += SwitchColorModes_Click; buttonGroup.Add(speedsButton); buttonPanel.AddChild(speedsButton); materialsButton = new RadioIconButton(AggContext.StaticData.LoadIcon("materials.png", theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroup, Name = "Materials Button", Checked = gcodeOptions.GCodeLineColorStyle == "Materials", ToolTipText = "Show Materials".Localize(), Margin = theme.ButtonSpacing }; materialsButton.Click += SwitchColorModes_Click; buttonGroup.Add(materialsButton); buttonPanel.AddChild(materialsButton); noColorButton = new RadioIconButton(AggContext.StaticData.LoadIcon("no-color.png", theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroup, Name = "No Color Button", Checked = gcodeOptions.GCodeLineColorStyle == "None", ToolTipText = "No Color".Localize(), Margin = theme.ButtonSpacing }; noColorButton.Click += SwitchColorModes_Click; buttonGroup.Add(noColorButton); buttonPanel.AddChild(noColorButton); this.AddChild( new SettingsItem( "Color View".Localize(), theme, optionalControls: buttonPanel, enforceGutter: false)); buttonPanel = new FlowLayoutWidget() { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit }; // Reset to new button group buttonGroup = new ObservableCollection <GuiWidget>(); solidButton = new RadioIconButton(AggContext.StaticData.LoadIcon("solid.png", theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroup, Name = "Solid Button", Checked = gcodeOptions.GCodeModelView == "Semi-Transparent", ToolTipText = "Show Semi-Transparent Model".Localize(), Margin = theme.ButtonSpacing }; solidButton.Click += SwitchModelModes_Click; buttonGroup.Add(solidButton); buttonPanel.AddChild(solidButton); materialsButton = new RadioIconButton(AggContext.StaticData.LoadIcon("wireframe.png", theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroup, Name = "Wireframe Button", Checked = gcodeOptions.GCodeModelView == "Wireframe", ToolTipText = "Show Wireframe Model".Localize(), Margin = theme.ButtonSpacing }; materialsButton.Click += SwitchModelModes_Click; buttonGroup.Add(materialsButton); buttonPanel.AddChild(materialsButton); noColorButton = new RadioIconButton(AggContext.StaticData.LoadIcon("no-color.png", theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroup, Name = "No Model Button", Checked = gcodeOptions.GCodeModelView == "None", ToolTipText = "No Model".Localize(), Margin = theme.ButtonSpacing }; noColorButton.Click += SwitchModelModes_Click; buttonGroup.Add(noColorButton); buttonPanel.AddChild(noColorButton); this.AddChild( new SettingsItem( "Model View".Localize(), buttonPanel, theme, enforceGutter: false)); gcodeOptions = sceneContext.RendererOptions; var viewOptions = sceneContext.GetBaseViewOptions(); viewOptions.AddRange(new[] { new BoolOption( "Moves".Localize(), () => gcodeOptions.RenderMoves, (value) => gcodeOptions.RenderMoves = value), new BoolOption( "Retractions".Localize(), () => gcodeOptions.RenderRetractions, (value) => gcodeOptions.RenderRetractions = value), new BoolOption( "Extrusion".Localize(), () => gcodeOptions.SimulateExtrusion, (value) => gcodeOptions.SimulateExtrusion = value), new BoolOption( "Transparent".Localize(), () => gcodeOptions.TransparentExtrusion, (value) => gcodeOptions.TransparentExtrusion = value), new BoolOption( "Hide Offsets".Localize(), () => gcodeOptions.HideExtruderOffsets, (value) => gcodeOptions.HideExtruderOffsets = value, () => printer.Settings.GetValue <int>(SettingsKey.extruder_count) > 1), new BoolOption( "Sync To Print".Localize(), () => gcodeOptions.SyncToPrint, (value) => { gcodeOptions.SyncToPrint = value; if (!gcodeOptions.SyncToPrint) { // If we are turning off sync to print, set the slider to full. //layerRenderRatioSlider.SecondValue = 1; } }) }); var optionsContainer = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit }; this.AddChild(optionsContainer); void BuildMenu() { foreach (var option in viewOptions.Where(option => option.IsVisible())) { var settingsItem = new SettingsItem( option.Title, theme, new SettingsItem.ToggleSwitchConfig() { Name = option.Title + " Toggle", Checked = option.IsChecked(), ToggleAction = option.SetValue }, enforceGutter: false); settingsItem.Padding = settingsItem.Padding.Clone(right: 8); optionsContainer.AddChild(settingsItem); } } BuildMenu(); PropertyChangedEventHandler syncProperties = (s, e) => { if (e.PropertyName == nameof(gcodeOptions.RenderBed) || e.PropertyName == nameof(gcodeOptions.RenderBuildVolume)) { optionsContainer.CloseAllChildren(); BuildMenu(); } }; gcodeOptions.PropertyChanged += syncProperties; optionsContainer.Closed += (s, e) => { gcodeOptions.PropertyChanged -= syncProperties; }; }
public ModelOptionsPanel(BedConfig sceneContext, ThemeConfig theme) : base(FlowDirection.TopToBottom) { var buttonPanel = new FlowLayoutWidget() { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit }; var buttonGroup = new ObservableCollection <GuiWidget>(); var shadedViewButton = new RadioIconButton(AggContext.StaticData.LoadIcon("view_shaded.png", theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroup, Name = "Shaded Button", Checked = sceneContext.ViewState.RenderType == RenderTypes.Shaded, ToolTipText = "Shaded".Localize(), Margin = theme.ButtonSpacing }; shadedViewButton.Click += (s, e) => sceneContext.ViewState.RenderType = RenderTypes.Shaded; buttonGroup.Add(shadedViewButton); buttonPanel.AddChild(shadedViewButton); var outlinesViewButton = new RadioIconButton(AggContext.StaticData.LoadIcon("view_outlines.png", theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroup, Name = "Outlines Button", Checked = sceneContext.ViewState.RenderType == RenderTypes.Outlines, ToolTipText = "Outlines".Localize(), Margin = theme.ButtonSpacing }; outlinesViewButton.Click += (s, e) => sceneContext.ViewState.RenderType = RenderTypes.Outlines; buttonGroup.Add(outlinesViewButton); buttonPanel.AddChild(outlinesViewButton); var polygonsViewButton = new RadioIconButton(AggContext.StaticData.LoadIcon("view_polygons.png", theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroup, Name = "Polygons Button", Checked = sceneContext.ViewState.RenderType == RenderTypes.Polygons, ToolTipText = "Polygons".Localize(), Margin = theme.ButtonSpacing }; polygonsViewButton.Click += (s, e) => sceneContext.ViewState.RenderType = RenderTypes.Polygons; buttonGroup.Add(polygonsViewButton); buttonPanel.AddChild(polygonsViewButton); var materialsViewButton = new RadioIconButton(AggContext.StaticData.LoadIcon("view_materials.png"), theme) { SiblingRadioButtonList = buttonGroup, Name = "Materials Button", Checked = sceneContext.ViewState.RenderType == RenderTypes.Materials, ToolTipText = "Materials".Localize(), Margin = theme.ButtonSpacing }; materialsViewButton.Click += (s, e) => sceneContext.ViewState.RenderType = RenderTypes.Materials; buttonGroup.Add(materialsViewButton); buttonPanel.AddChild(materialsViewButton); var overhangViewButton = new RadioIconButton(AggContext.StaticData.LoadIcon("view_overhang.png"), theme) { SiblingRadioButtonList = buttonGroup, Name = "Overhang Button", Checked = sceneContext.ViewState.RenderType == RenderTypes.Overhang, ToolTipText = "Overhang".Localize(), Margin = theme.ButtonSpacing }; overhangViewButton.Click += (s, e) => sceneContext.ViewState.RenderType = RenderTypes.Overhang; buttonGroup.Add(overhangViewButton); buttonPanel.AddChild(overhangViewButton); this.AddChild( new SettingsItem( "View Style".Localize(), buttonPanel, theme, enforceGutter: false) { Border = 0 }); foreach (var option in sceneContext.GetBaseViewOptions()) { if (option.IsVisible()) { this.AddChild( new SettingsItem( option.Title, theme, new SettingsItem.ToggleSwitchConfig() { Name = option.Title + " Toggle", Checked = option.IsChecked(), ToggleAction = option.SetValue }, enforceGutter: false) ); } } }