diff --git a/ConfigurationPage/CalibrationSettings/CalibrationSettingsView.cs b/ConfigurationPage/CalibrationSettings/CalibrationSettingsView.cs index 421203579..a61989fb4 100644 --- a/ConfigurationPage/CalibrationSettings/CalibrationSettingsView.cs +++ b/ConfigurationPage/CalibrationSettings/CalibrationSettingsView.cs @@ -20,10 +20,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage private TextImageButtonFactory buttonFactory; private PrinterConfig printer; - public CalibrationSettingsWidget(PrinterConfig printer, TextImageButtonFactory buttonFactory, int headingPointSize) + public CalibrationSettingsWidget(PrinterConfig printer, ThemeConfig theme) { this.printer = printer; - this.buttonFactory = buttonFactory; + this.buttonFactory = theme.ButtonFactory; var container = new FlowLayoutWidget(FlowDirection.TopToBottom) { @@ -55,8 +55,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage this.AddChild( new SectionWidget( "Calibration".Localize(), - ActiveTheme.Instance.PrimaryAccentColor, container, + theme, editButton)); if (!printer.Settings.GetValue(SettingsKey.has_hardware_leveling)) diff --git a/CustomWidgets/PrintingWindow/BasicBody.cs b/CustomWidgets/PrintingWindow/BasicBody.cs index 8b2560bba..fc646c954 100644 --- a/CustomWidgets/PrintingWindow/BasicBody.cs +++ b/CustomWidgets/PrintingWindow/BasicBody.cs @@ -220,7 +220,7 @@ namespace MatterHackers.MatterControl.CustomWidgets // ZControls { - var widget = new ZAxisControls(printer, smallScreen) + var widget = new ZAxisControls(printer, ApplicationController.Instance.Theme, smallScreen) { Margin = new BorderDouble(left: 50), VAnchor = VAnchor.Center, diff --git a/CustomWidgets/PrintingWindow/ZAxisControls.cs b/CustomWidgets/PrintingWindow/ZAxisControls.cs index f2a498316..75348e4d4 100644 --- a/CustomWidgets/PrintingWindow/ZAxisControls.cs +++ b/CustomWidgets/PrintingWindow/ZAxisControls.cs @@ -39,22 +39,12 @@ namespace MatterHackers.MatterControl.CustomWidgets { public class ZAxisControls : FlowLayoutWidget { - /* - private static TextImageButtonFactory buttonFactory = new TextImageButtonFactory() - { - fontSize = 13, - invertImageLocation = false, - hoverFillColor = ActiveTheme.Instance.PrimaryAccentColor, - //pressedFillColor = ActiveTheme.Instance.PrimaryAccentColor.AdjustLightness(0.8).ToColor() - }; - */ - private MoveButtonFactory buttonFactory = new MoveButtonFactory() { FontSize = 13, }; - public ZAxisControls(PrinterConfig printer, bool smallScreen) : + public ZAxisControls(PrinterConfig printer, ThemeConfig theme, bool smallScreen) : base(FlowDirection.TopToBottom) { buttonFactory.Colors.Fill.Normal = ActiveTheme.Instance.PrimaryAccentColor; @@ -73,7 +63,7 @@ namespace MatterHackers.MatterControl.CustomWidgets this.AddChild(CreateZMoveButton(printer, .02, smallScreen)); - this.AddChild(new ZTuningWidget(printer.Settings, false) + this.AddChild(new ZTuningWidget(printer.Settings, theme) { HAnchor = HAnchor.Center | HAnchor.Fit, Margin = 10 diff --git a/CustomWidgets/SolidSlider.cs b/CustomWidgets/SolidSlider.cs index c2b49f80e..2f886c241 100644 --- a/CustomWidgets/SolidSlider.cs +++ b/CustomWidgets/SolidSlider.cs @@ -27,12 +27,12 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ +using System; using MatterHackers.Agg; using MatterHackers.Agg.Font; using MatterHackers.Agg.UI; using MatterHackers.Agg.VertexSource; using MatterHackers.VectorMath; -using System; namespace MatterHackers.MatterControl { diff --git a/PartPreviewWindow/GCode3DWidget.cs b/PartPreviewWindow/GCode3DWidget.cs index 91120f0d5..0af3863c5 100644 --- a/PartPreviewWindow/GCode3DWidget.cs +++ b/PartPreviewWindow/GCode3DWidget.cs @@ -82,22 +82,22 @@ namespace MatterHackers.MatterControl.PartPreviewWindow gcodeResultsPanel.AddChild( new SectionWidget( "Details".Localize(), - ActiveTheme.Instance.PrimaryTextColor, new GCodeDetailsView(new GCodeDetails(printer, printer.Bed.LoadedGCode), theme.FontSize12, theme.FontSize9) { HAnchor = HAnchor.Fit, Margin = new BorderDouble(bottom: 3) - })); + }, + theme)); gcodeResultsPanel.AddChild( new SectionWidget( "Speeds".Localize(), - ActiveTheme.Instance.PrimaryTextColor, new SpeedsLegend(sceneContext.LoadedGCode, theme, pointSize: theme.FontSize12) { HAnchor = HAnchor.Stretch, Visible = sceneContext.RendererOptions.RenderSpeeds, - })); + }, + theme)); } this.Invalidate(); diff --git a/PartPreviewWindow/MaterialControls.cs b/PartPreviewWindow/MaterialControls.cs index 7ccbf879d..e5f5be069 100644 --- a/PartPreviewWindow/MaterialControls.cs +++ b/PartPreviewWindow/MaterialControls.cs @@ -29,7 +29,6 @@ either expressed or implied, of the FreeBSD Project. using System; using System.Collections.ObjectModel; -using System.Linq; using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; diff --git a/PartPreviewWindow/SectionWidget.cs b/PartPreviewWindow/SectionWidget.cs index 5820b4cb6..397de1f94 100644 --- a/PartPreviewWindow/SectionWidget.cs +++ b/PartPreviewWindow/SectionWidget.cs @@ -10,13 +10,12 @@ namespace MatterHackers.MatterControl.CustomWidgets { private Color borderColor; - public SectionWidget(string sectionTitle, Color textColor, GuiWidget sectionContent, GuiWidget rightAlignedContent = null, int headingPointSize = -1, bool expandingContent = true, bool expanded = true) + public SectionWidget(string sectionTitle, GuiWidget sectionContent, ThemeConfig theme, GuiWidget rightAlignedContent = null, int headingPointSize = -1, bool expandingContent = true, bool expanded = true) : base (FlowDirection.TopToBottom) { this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Fit; - - var theme = ApplicationController.Instance.Theme; + this.Border = new BorderDouble(bottom: 1); borderColor = new Color(theme.Colors.SecondaryTextColor, 50); @@ -33,20 +32,20 @@ namespace MatterHackers.MatterControl.CustomWidgets { HAnchor = HAnchor.Stretch, Checked = expanded, - BorderColor = (expanded) ? Color.Transparent : borderColor, - Border = new BorderDouble(bottom: 1), }; checkbox.CheckedStateChanged += (s, e) => { ContentPanel.Visible = checkbox.Checked; - checkbox.BorderColor = (checkbox.Checked) ? Color.Transparent : borderColor; + this.BorderColor = (checkbox.Checked) ? Color.Transparent : borderColor; }; + this.BorderColor = BorderColor = (expanded) ? Color.Transparent : borderColor; + heading = checkbox; } else { - heading = new TextWidget(sectionTitle, pointSize: pointSize, textColor: textColor); + heading = new TextWidget(sectionTitle, pointSize: pointSize, textColor: theme.Colors.PrimaryTextColor); } heading.Padding = new BorderDouble(0, 3, 0, 6); diff --git a/PartPreviewWindow/SelectedObjectPanel.cs b/PartPreviewWindow/SelectedObjectPanel.cs index c2c4463d1..52ba9bcfc 100644 --- a/PartPreviewWindow/SelectedObjectPanel.cs +++ b/PartPreviewWindow/SelectedObjectPanel.cs @@ -169,7 +169,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow Padding = 6 }); - editorSection = new SectionWidget("Editor", ActiveTheme.Instance.PrimaryTextColor, editorColumn); + editorSection = new SectionWidget("Editor", editorColumn, theme); scrollableContent.AddChild(editorSection); // TODO: Implements @@ -177,25 +177,25 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // && this.scene.SelectedItem is SelectionGroup // && this.scene.SelectedItem.Children.Count > 1; - var alignSection = new SectionWidget("Align".Localize(), ActiveTheme.Instance.PrimaryTextColor, new AlignControls(scene, theme), expanded: false) + var alignSection = new SectionWidget("Align".Localize(), new AlignControls(scene, theme), theme, expanded: false) { Name = "Align Panel", }; scrollableContent.AddChild(alignSection); - var mirrorSection = new SectionWidget("Mirror".Localize(), ActiveTheme.Instance.PrimaryTextColor, new MirrorControls(scene, theme), expanded: false) + var mirrorSection = new SectionWidget("Mirror".Localize(), new MirrorControls(scene, theme), theme, expanded: false) { Name = "Mirror Panel", }; scrollableContent.AddChild(mirrorSection); - var scaleSection = new SectionWidget("Scale".Localize(), ActiveTheme.Instance.PrimaryTextColor, new ScaleControls(scene, theme), expanded: false) + var scaleSection = new SectionWidget("Scale".Localize(), new ScaleControls(scene, theme), theme, expanded: false) { Name = "Scale Panel", }; scrollableContent.AddChild(scaleSection); - var materialsSection = new SectionWidget("Materials".Localize(), ActiveTheme.Instance.PrimaryTextColor, new MaterialControls(scene, theme), expanded: false) + var materialsSection = new SectionWidget("Materials".Localize(), new MaterialControls(scene, theme), theme, expanded: false) { Name = "Materials Panel", }; diff --git a/PrinterControls/ControlWidgets/AdjustmentControls.cs b/PrinterControls/ControlWidgets/AdjustmentControls.cs index b00fb421f..04daf52de 100644 --- a/PrinterControls/ControlWidgets/AdjustmentControls.cs +++ b/PrinterControls/ControlWidgets/AdjustmentControls.cs @@ -53,7 +53,7 @@ namespace MatterHackers.MatterControl.PrinterControls private EventHandler unregisterEvents; - public AdjustmentControls(PrinterConfig printer, int headingPointSize) + public AdjustmentControls(PrinterConfig printer, ThemeConfig theme) { var topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom) { @@ -199,8 +199,8 @@ namespace MatterHackers.MatterControl.PrinterControls this.AddChild( new SectionWidget( "Tuning Adjustment".Localize(), - ActiveTheme.Instance.PrimaryAccentColor, - topToBottom)); + topToBottom, + theme)); ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) => { diff --git a/PrinterControls/ControlWidgets/FanControls.cs b/PrinterControls/ControlWidgets/FanControls.cs index 93dd0f0a9..800200082 100644 --- a/PrinterControls/ControlWidgets/FanControls.cs +++ b/PrinterControls/ControlWidgets/FanControls.cs @@ -45,11 +45,8 @@ namespace MatterHackers.MatterControl.PrinterControls private CheckBox toggleSwitch; - PrinterConnection printerConnection; - - public FanControls(PrinterConnection printerConnection, int headingPointSize) + public FanControls(PrinterConnection printerConnection, ThemeConfig theme) { - this.printerConnection = printerConnection; this.HAnchor = HAnchor.Stretch; this.HAnchor = HAnchor.Stretch; @@ -108,8 +105,8 @@ namespace MatterHackers.MatterControl.PrinterControls this.AddChild( new SectionWidget( "Fan".Localize(), - ActiveTheme.Instance.PrimaryAccentColor, - leftToRight)); + leftToRight, + theme)); // CreateFanControls printerConnection.FanSpeedSet.RegisterEvent((s, e) => diff --git a/PrinterControls/ControlWidgets/MacroControls.cs b/PrinterControls/ControlWidgets/MacroControls.cs index bfe8ddfaf..dbca2d04f 100644 --- a/PrinterControls/ControlWidgets/MacroControls.cs +++ b/PrinterControls/ControlWidgets/MacroControls.cs @@ -39,19 +39,18 @@ namespace MatterHackers.MatterControl.PrinterControls { public class MacroControls : ControlWidgetBase { - public MacroControls(PrinterConfig printer, int headingPointSize) + public MacroControls(PrinterConfig printer, ThemeConfig theme) { - this.AddChild(new MacroControlsWidget(printer, headingPointSize)); + this.AddChild(new MacroControlsWidget(printer, theme)); } } public class MacroControlsWidget : FlowLayoutWidget { - private PrinterConfig printer; - public MacroControlsWidget(PrinterConfig printer, int headingPointSize) + //private PrinterConfig printer; + public MacroControlsWidget(PrinterConfig printer, ThemeConfig theme) : base(FlowDirection.TopToBottom) { - this.printer = printer; this.HAnchor = HAnchor.Stretch; var buttonFactory = ApplicationController.Instance.Theme.HomingButtons; @@ -66,12 +65,12 @@ namespace MatterHackers.MatterControl.PrinterControls this.AddChild( new SectionWidget( "Macros".Localize(), - ActiveTheme.Instance.PrimaryAccentColor, - GetMacroButtonContainer(buttonFactory), + GetMacroButtonContainer(buttonFactory, printer), + theme, editButton)); } - private FlowLayoutWidget GetMacroButtonContainer(TextImageButtonFactory buttonFactory) + private FlowLayoutWidget GetMacroButtonContainer(TextImageButtonFactory buttonFactory, PrinterConfig printer) { var macroContainer = new FlowLeftRightWithWrapping(); @@ -103,7 +102,7 @@ namespace MatterHackers.MatterControl.PrinterControls noMacrosFound.Visible = macroContainer.Children.Count == 0; } }; - + return macroContainer; } } diff --git a/PrinterControls/ControlWidgets/MovementControls.cs b/PrinterControls/ControlWidgets/MovementControls.cs index e02016630..bbba50d71 100644 --- a/PrinterControls/ControlWidgets/MovementControls.cs +++ b/PrinterControls/ControlWidgets/MovementControls.cs @@ -44,6 +44,7 @@ namespace MatterHackers.MatterControl.PrinterControls public class MovementControls : ControlWidgetBase { private PrinterConfig printer; + private ThemeConfig theme; public FlowLayoutWidget manualControlsLayout; private Button disableMotors; private EditManualMovementSpeedsWindow editManualMovementSettingsWindow; @@ -86,10 +87,12 @@ namespace MatterHackers.MatterControl.PrinterControls return container; } - public MovementControls(PrinterConfig printer, int headingPointSize) + public MovementControls(PrinterConfig printer, ThemeConfig theme) { this.printer = printer; - var buttonFactory = ApplicationController.Instance.Theme.DisableableControlBase; + this.theme = theme; + + var buttonFactory = theme.DisableableControlBase; Button editButton = buttonFactory.GenerateIconButton(AggContext.StaticData.LoadIcon("icon_edit.png", 16, 16, IconColor.Theme)); editButton.Click += (sender, e) => @@ -129,8 +132,8 @@ namespace MatterHackers.MatterControl.PrinterControls this.AddChild( new SectionWidget( "Movement".Localize(), - ActiveTheme.Instance.PrimaryAccentColor, manualControlsLayout, + theme, editButton)); } @@ -150,8 +153,8 @@ namespace MatterHackers.MatterControl.PrinterControls homeButtonBar.Margin = new BorderDouble(0); homeButtonBar.Padding = new BorderDouble(0); - var homingButtonFactory = ApplicationController.Instance.Theme.HomingButtons; - var commonButtonFactory = ApplicationController.Instance.Theme.ButtonFactory; + var homingButtonFactory = theme.HomingButtons; + var commonButtonFactory = theme.ButtonFactory; var homeIconImageWidget = new ImageWidget(AggContext.StaticData.LoadIcon("icon_home_white_24x24.png", 24, 24, IconColor.Theme)); homeIconImageWidget.Margin = new BorderDouble(0, 0, 6, 0); @@ -202,9 +205,9 @@ namespace MatterHackers.MatterControl.PrinterControls }; homeButtonBar.AddChild(offsetStreamLabel); - var ztuningWidget = new ZTuningWidget(printer.Settings); + var ztuningWidget = new ZTuningWidget(printer.Settings, theme); homeButtonBar.AddChild(ztuningWidget); - + homeButtonBar.AddChild(new HorizontalSpacer()); homeButtonBar.AddChild(disableMotors); @@ -295,7 +298,7 @@ namespace MatterHackers.MatterControl.PrinterControls private bool allowRemoveButton; PrinterSettings printerSettings; - public ZTuningWidget(PrinterSettings printerSettings, bool allowRemoveButton = true) + public ZTuningWidget(PrinterSettings printerSettings, ThemeConfig theme, bool allowRemoveButton = true) { this.printerSettings = printerSettings; this.allowRemoveButton = allowRemoveButton; @@ -331,7 +334,7 @@ namespace MatterHackers.MatterControl.PrinterControls }; zOffsetStreamContainer.AddChild(zOffsetStreamDisplay); - clearZOffsetButton = ApplicationController.Instance.Theme.CreateSmallResetButton(); + clearZOffsetButton = theme.CreateSmallResetButton(); clearZOffsetButton.Name = "Clear ZOffset button"; clearZOffsetButton.ToolTipText = "Clear ZOffset".Localize(); clearZOffsetButton.Visible = allowRemoveButton && zoffset != 0; diff --git a/PrinterControls/ManualPrinterControls.cs b/PrinterControls/ManualPrinterControls.cs index 5f79e4d2b..91b51e9d6 100644 --- a/PrinterControls/ManualPrinterControls.cs +++ b/PrinterControls/ManualPrinterControls.cs @@ -103,17 +103,17 @@ namespace MatterHackers.MatterControl }; this.AddChild(controlsTopToBottomLayout); - movementControlsContainer = new MovementControls(printer, headingPointSize); + movementControlsContainer = new MovementControls(printer, theme); movementControlsContainer.Margin = new BorderDouble(top: 6); controlsTopToBottomLayout.AddChild(movementControlsContainer); if (!printer.Settings.GetValue(SettingsKey.has_hardware_leveling)) { - calibrationControlsContainer = new CalibrationSettingsWidget(printer, theme.ButtonFactory, headingPointSize); + calibrationControlsContainer = new CalibrationSettingsWidget(printer, theme); controlsTopToBottomLayout.AddChild(calibrationControlsContainer); } - macroControlsContainer = new MacroControls(printer, headingPointSize); + macroControlsContainer = new MacroControls(printer, theme); controlsTopToBottomLayout.AddChild(macroControlsContainer); var linearPanel = new FlowLayoutWidget() @@ -122,7 +122,7 @@ namespace MatterHackers.MatterControl }; controlsTopToBottomLayout.AddChild(linearPanel); - fanControlsContainer = new FanControls(printer.Connection, headingPointSize); + fanControlsContainer = new FanControls(printer.Connection, theme); if (printer.Settings.GetValue(SettingsKey.has_fan)) { controlsTopToBottomLayout.AddChild(fanControlsContainer); @@ -131,7 +131,7 @@ namespace MatterHackers.MatterControl #if !__ANDROID__ controlsTopToBottomLayout.AddChild(new PowerControls(printer, headingPointSize)); #endif - tuningAdjustmentControlsContainer = new AdjustmentControls(printer, headingPointSize); + tuningAdjustmentControlsContainer = new AdjustmentControls(printer, theme); controlsTopToBottomLayout.AddChild(tuningAdjustmentControlsContainer); // HACK: this is a hack to make the layout engine fire again for this control diff --git a/SlicerConfiguration/SliceSettingsWidget.cs b/SlicerConfiguration/SliceSettingsWidget.cs index b8257734c..0d81c6616 100644 --- a/SlicerConfiguration/SliceSettingsWidget.cs +++ b/SlicerConfiguration/SliceSettingsWidget.cs @@ -238,7 +238,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration string groupName = (group.Name.Contains("!hidden")) ? "" : group.Name; - var sectionWidget = new SectionWidget(groupName, ActiveTheme.Instance.PrimaryTextColor, groupPanel, headingPointSize: theme.FontSize12) + var sectionWidget = new SectionWidget(groupName, groupPanel, theme) { Margin = new BorderDouble(bottom: 8), };