From 1efe8dec4fd0b4c2e4e764327c136b2e968be7b5 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 3 Aug 2017 18:35:50 -0700 Subject: [PATCH] Use existing button factory --- .../ControlWidgets/MacroControls.cs | 54 ++++++------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/PrinterControls/ControlWidgets/MacroControls.cs b/PrinterControls/ControlWidgets/MacroControls.cs index ca68f7d95..13c083a01 100644 --- a/PrinterControls/ControlWidgets/MacroControls.cs +++ b/PrinterControls/ControlWidgets/MacroControls.cs @@ -60,25 +60,10 @@ namespace MatterHackers.MatterControl.PrinterControls public class ActionControlsWidget : FlowLayoutWidget { - protected string editWindowLabel; - protected string label; - protected FlowLayoutWidget presetButtonsContainer; - protected TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); - public ActionControlsWidget() : base(FlowDirection.TopToBottom) { - this.textImageButtonFactory.Options.Normal.FillColor = RGBA_Bytes.White; - this.textImageButtonFactory.Options.FixedHeight = 24 * GuiWidget.DeviceScale; - this.textImageButtonFactory.Options.FontSize = 12; - this.textImageButtonFactory.Options.BorderWidth = 1; - this.textImageButtonFactory.Options.Normal.BorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200); - this.textImageButtonFactory.Options.Hover.BorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200); - - this.textImageButtonFactory.Options.Disabled.TextColor = RGBA_Bytes.Gray; - this.textImageButtonFactory.Options.Hover.TextColor = ActiveTheme.Instance.PrimaryTextColor; - this.textImageButtonFactory.Options.Normal.TextColor = RGBA_Bytes.Black; - this.textImageButtonFactory.Options.Pressed.TextColor = ActiveTheme.Instance.PrimaryTextColor; + var buttonFactory = ApplicationController.Instance.Theme.HomingButtons; this.HAnchor = HAnchor.ParentLeftRight; @@ -97,36 +82,27 @@ namespace MatterHackers.MatterControl.PrinterControls FlowLayoutWidget controlRow = new FlowLayoutWidget(Agg.UI.FlowDirection.TopToBottom); controlRow.Margin = new BorderDouble(top: 5); controlRow.HAnchor |= HAnchor.ParentLeftRight; - { - this.presetButtonsContainer = GetMacroButtonContainer(); - controlRow.AddChild(this.presetButtonsContainer); - } - - groupBox.AddChild(controlRow); - this.AddChild(groupBox); - } - - private FlowLayoutWidget GetMacroButtonContainer() - { - FlowLayoutWidget macroButtonContainer = new FlowLayoutWidget(); + + var macroButtonContainer = new FlowLayoutWidget(); macroButtonContainer.Margin = new BorderDouble(0, 0, 3, 0); macroButtonContainer.Padding = new BorderDouble(0, 3, 3, 3); - if (ActiveSliceSettings.Instance?.ActionMacros().Any() != true) + if (ActiveSliceSettings.Instance?.ActionMacros().Any() == true) { - return macroButtonContainer; + foreach (GCodeMacro macro in ActiveSliceSettings.Instance.ActionMacros()) + { + Button macroButton = buttonFactory.Generate(GCodeMacro.FixMacroName(macro.Name)); + macroButton.Margin = new BorderDouble(right: 5); + macroButton.Click += (s, e) => macro.Run(); + + macroButtonContainer.AddChild(macroButton); + } } - foreach (GCodeMacro macro in ActiveSliceSettings.Instance.ActionMacros()) - { - Button macroButton = textImageButtonFactory.Generate(GCodeMacro.FixMacroName(macro.Name)); - macroButton.Margin = new BorderDouble(right: 5); - macroButton.Click += (s, e) => macro.Run(); + controlRow.AddChild(macroButtonContainer); - macroButtonContainer.AddChild(macroButton); - } - - return macroButtonContainer; + groupBox.AddChild(controlRow); + this.AddChild(groupBox); } }