diff --git a/ConfigurationPage/CalibrationSettings/CalibrationControls.cs b/ConfigurationPage/CalibrationSettings/CalibrationControls.cs index e0964be03..6a090d95f 100644 --- a/ConfigurationPage/CalibrationSettings/CalibrationControls.cs +++ b/ConfigurationPage/CalibrationSettings/CalibrationControls.cs @@ -67,9 +67,12 @@ namespace MatterHackers.MatterControl.PrinterControls autoLevelRow.AddChild(runWizardButton); // put in the switch - CheckBox printLevelingSwitch = ImageButtonFactory.CreateToggleSwitch(printer.Settings.GetValue(SettingsKey.print_leveling_enabled)); - printLevelingSwitch.VAnchor = VAnchor.Center; - printLevelingSwitch.Margin = new BorderDouble(left: 16); + var printLevelingSwitch = new RoundedToggleSwitch(theme) + { + VAnchor = VAnchor.Center, + Margin = new BorderDouble(left: 16), + Checked = printer.Settings.GetValue(SettingsKey.print_leveling_enabled) + }; printLevelingSwitch.CheckedStateChanged += (sender, e) => { printer.Settings.Helpers.DoPrintLeveling(printLevelingSwitch.Checked); diff --git a/ControlElements/ImageButtonFactory.cs b/ControlElements/ImageButtonFactory.cs index a66b1444e..21b119933 100644 --- a/ControlElements/ImageButtonFactory.cs +++ b/ControlElements/ImageButtonFactory.cs @@ -41,59 +41,6 @@ namespace MatterHackers.MatterControl { public bool InvertImageColor { get; set; } = true; - public static CheckBox CreateToggleSwitch(bool initialState) - { - return CreateToggleSwitch(initialState, ActiveTheme.Instance.PrimaryTextColor); - } - - public static CheckBox CreateToggleSwitch(bool initialState, Color textColor, bool useStandardLabels = true) - { - return CreateToggleSwitch( - initialState, - textColor, - 60 * GuiWidget.DeviceScale, - 24 * GuiWidget.DeviceScale, - useStandardLabels); - } - - public static CheckBox CreateToggleSwitch(bool initialState, Color textColor, double pixelWidth, double pixelHeight, bool useStandardLabels = true) - { - return CreateToggleSwitch( - initialState, - textColor, - new Color(textColor, 70), - pixelWidth, - pixelHeight, - useStandardLabels); - } - - public static CheckBox CreateToggleSwitch(bool initialState, Color textColor, Color borderColor, double pixelWidth, double pixelHeight, bool useStandardLabels = true) - { - string on = "On".Localize(); - string off = "Off".Localize(); - - if (!useStandardLabels) - { - on = ""; - off = ""; - } - - return new CheckBox( - new ToggleSwitchView( - on, - off, - pixelWidth, - pixelHeight, - ActiveTheme.Instance.PrimaryBackgroundColor, - new Color(220, 220, 220), - ActiveTheme.Instance.PrimaryAccentColor, - textColor, - borderColor)) - { - Checked = initialState, - }; - } - public Button Generate(ImageBuffer normalImage, ImageBuffer hoverImage, ImageBuffer pressedImage = null, ImageBuffer disabledImage = null) { if(hoverImage == null) diff --git a/PrinterControls/ControlWidgets/FanControls.cs b/PrinterControls/ControlWidgets/FanControls.cs index d21c24b02..69da8079a 100644 --- a/PrinterControls/ControlWidgets/FanControls.cs +++ b/PrinterControls/ControlWidgets/FanControls.cs @@ -43,7 +43,7 @@ namespace MatterHackers.MatterControl.PrinterControls private EditableNumberDisplay fanSpeedDisplay; - private CheckBox toggleSwitch; + private ICheckbox toggleSwitch; private FanControls(PrinterConnection printerConnection, ThemeConfig theme) : base(FlowDirection.TopToBottom) @@ -60,9 +60,12 @@ namespace MatterHackers.MatterControl.PrinterControls bool fanActive = printerConnection.FanSpeed0To255 != 0; Stopwatch timeSinceLastManualSend = new Stopwatch(); - toggleSwitch = ImageButtonFactory.CreateToggleSwitch(fanActive); - toggleSwitch.Margin = new BorderDouble(5, 0); - toggleSwitch.VAnchor = VAnchor.Center; + + var toggleSwitch = new RoundedToggleSwitch(theme) + { + Margin = new BorderDouble(5, 0), + VAnchor = VAnchor.Center + }; toggleSwitch.CheckedStateChanged += (s, e) => { if (!timeSinceLastManualSend.IsRunning