From 1298163600746570e550363fd18abd71992ab03a Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 21 Apr 2015 14:25:43 -0700 Subject: [PATCH 1/7] Update to latest agg and matter slice --- Submodules/MatterSlice | 2 +- Submodules/agg-sharp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index 94025eb8d..79b23e380 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit 94025eb8da33a2c60caf6ccd28e072b1fdb8d465 +Subproject commit 79b23e380ea3c2b178713bd32d6d309f84e0506a diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 99575fe8b..6155e8669 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 99575fe8b9afea9906135d3ba1235b30b536c092 +Subproject commit 6155e8669daa0ddf1cc1499fbc4133fa05b5a556 From c60643476ec71aee56ca96ab35c7cc4d8d6ea13d Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 21 Apr 2015 16:41:19 -0700 Subject: [PATCH 2/7] Sync toggle switch state on DoPrintLevelingChanged --- ConfigurationPage/PrinterSettings/PrinterSettingsView.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs b/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs index c3b115ae1..e332e3968 100644 --- a/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs +++ b/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs @@ -142,6 +142,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) => { + printLevelingSwitch.SwitchState = ActivePrinterProfile.Instance.DoPrintLeveling; SetPrintLevelButtonVisiblity(); }, ref unregisterEvents); From f3f921ab4f70de0951e776b18c14c3332b4da5df Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 22 Apr 2015 08:43:09 -0700 Subject: [PATCH 3/7] Re-wrote toggle switch to be a view for checkbox. --- .../CloudSettings/CloudSettingsView.cs | 9 ++- .../PrinterSettings/PrinterSettingsView.cs | 30 +++------ ConfigurationPage/SettingsViewBase.cs | 18 ------ ControlElements/ToggleSwitchFactory.cs | 61 ------------------- MatterControl.csproj | 1 - PartPreviewWindow/ViewGcodeBasic.cs | 4 +- PrintHistory/PrintHistoryWidget.cs | 4 +- .../ControlWidgets/ControlWidgetBase.cs | 1 - PrinterControls/ControlWidgets/FanControls.cs | 22 +++---- SlicerConfiguration/SliceSettingsWidget.cs | 2 +- Submodules/agg-sharp | 2 +- 11 files changed, 29 insertions(+), 125 deletions(-) delete mode 100644 ControlElements/ToggleSwitchFactory.cs diff --git a/ConfigurationPage/CloudSettings/CloudSettingsView.cs b/ConfigurationPage/CloudSettings/CloudSettingsView.cs index 8011819c3..7978aa3dd 100644 --- a/ConfigurationPage/CloudSettings/CloudSettingsView.cs +++ b/ConfigurationPage/CloudSettings/CloudSettingsView.cs @@ -217,11 +217,14 @@ namespace MatterHackers.MatterControl.ConfigurationPage levelingSwitchContainer.VAnchor = VAnchor.ParentCenter; levelingSwitchContainer.Margin = new BorderDouble(left: 16); - ToggleSwitch enablePrintNotificationsSwitch = GenerateToggleSwitch(levelingSwitchContainer, UserSettings.Instance.get("PrintNotificationsEnabled") == "true"); - enablePrintNotificationsSwitch.SwitchStateChanged += (sender, e) => + CheckBox enablePrintNotificationsSwitch = new CheckBox(new ToggleSwitchView(60, 24, ActiveTheme.Instance.PrimaryBackgroundColor, new RGBA_Bytes(220, 220, 220), ActiveTheme.Instance.PrimaryAccentColor, ActiveTheme.Instance.PrimaryTextColor)); + enablePrintNotificationsSwitch.VAnchor = VAnchor.ParentCenter; + enablePrintNotificationsSwitch.Checked = UserSettings.Instance.get("PrintNotificationsEnabled") == "true"; + enablePrintNotificationsSwitch.CheckedStateChanged += (sender, e) => { - UserSettings.Instance.set("PrintNotificationsEnabled", enablePrintNotificationsSwitch.SwitchState ? "true" : "false"); + UserSettings.Instance.set("PrintNotificationsEnabled", enablePrintNotificationsSwitch.Checked ? "true" : "false"); }; + levelingSwitchContainer.AddChild(enablePrintNotificationsSwitch); levelingSwitchContainer.SetBoundsToEncloseChildren(); buttonRow.AddChild(levelingIcon); diff --git a/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs b/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs index c3b115ae1..616bd17d1 100644 --- a/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs +++ b/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs @@ -69,11 +69,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Margin = new BorderDouble(0, 4); - Button configureAutoLevelButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper()); - configureAutoLevelButton.Margin = new BorderDouble(left: 6); - configureAutoLevelButton.VAnchor = VAnchor.ParentCenter; - configureAutoLevelButton.Click += new EventHandler(configureAutoLevelButton_Click); - TextWidget notificationSettingsLabel = new TextWidget("Automatic Print Leveling"); notificationSettingsLabel.AutoExpandBoundsToText = true; notificationSettingsLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; @@ -120,17 +115,15 @@ namespace MatterHackers.MatterControl.ConfigurationPage ImageWidget levelingIcon = new ImageWidget(levelingImage); levelingIcon.Margin = new BorderDouble(right: 6); - GuiWidget levelingSwitchContainer = new FlowLayoutWidget(); - levelingSwitchContainer.VAnchor = VAnchor.ParentCenter; - levelingSwitchContainer.Margin = new BorderDouble(left: 16); + CheckBox printLevelingSwitch = new CheckBox(new ToggleSwitchView(60, 24, ActiveTheme.Instance.PrimaryBackgroundColor, new RGBA_Bytes(220, 220, 220), ActiveTheme.Instance.PrimaryAccentColor, ActiveTheme.Instance.PrimaryTextColor)); - ToggleSwitch printLevelingSwitch = GenerateToggleSwitch(levelingSwitchContainer, PrinterSettings.Instance.get("PublishBedImage") == "true"); - printLevelingSwitch.SwitchState = ActivePrinterProfile.Instance.DoPrintLeveling; - printLevelingSwitch.SwitchStateChanged += (sender, e) => + printLevelingSwitch.Checked = ActivePrinterProfile.Instance.DoPrintLeveling; + printLevelingSwitch.VAnchor = VAnchor.ParentCenter; + printLevelingSwitch.Margin = new BorderDouble(left: 16); + printLevelingSwitch.CheckedStateChanged += (sender, e) => { - ActivePrinterProfile.Instance.DoPrintLeveling = printLevelingSwitch.SwitchState; + ActivePrinterProfile.Instance.DoPrintLeveling = printLevelingSwitch.Checked; }; - levelingSwitchContainer.SetBoundsToEncloseChildren(); printLevelingStatusLabel = new TextWidget(""); printLevelingStatusLabel.AutoExpandBoundsToText = true; @@ -143,6 +136,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) => { SetPrintLevelButtonVisiblity(); + printLevelingSwitch.Checked = ActivePrinterProfile.Instance.DoPrintLeveling; }, ref unregisterEvents); buttonRow.AddChild(levelingIcon); @@ -150,7 +144,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage buttonRow.AddChild(editButton); buttonRow.AddChild(new HorizontalSpacer()); buttonRow.AddChild(runPrintLevelingButton); - buttonRow.AddChild(levelingSwitchContainer); + buttonRow.AddChild(printLevelingSwitch); SetPrintLevelButtonVisiblity(); return buttonRow; @@ -338,14 +332,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage }); } - private void configureAutoLevelButton_Click(object sender, EventArgs mouseEvent) - { - UiThread.RunOnIdle((state) => - { - //Do stuff - }); - } - private void openGcodeTerminalButton_Click(object sender, EventArgs mouseEvent) { UiThread.RunOnIdle((state) => diff --git a/ConfigurationPage/SettingsViewBase.cs b/ConfigurationPage/SettingsViewBase.cs index 5a9dec5a5..034c56bb4 100644 --- a/ConfigurationPage/SettingsViewBase.cs +++ b/ConfigurationPage/SettingsViewBase.cs @@ -11,8 +11,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage protected RGBA_Bytes separatorLineColor; protected FlowLayoutWidget mainContainer; - protected ToggleSwitchFactory toggleSwitchFactory = new ToggleSwitchFactory(); - public SettingsViewBase(string title) : base(new TextWidget(title, pointSize: 18, textColor: ActiveTheme.Instance.SecondaryAccentColor)) { @@ -43,21 +41,5 @@ namespace MatterHackers.MatterControl.ConfigurationPage this.linkButtonFactory.fontSize = 11; } - - protected ToggleSwitch GenerateToggleSwitch(GuiWidget parentContainer, bool initiallyChecked) - { - TextWidget toggleLabel = new TextWidget(initiallyChecked ? "On" : "Off", pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor); - toggleLabel.VAnchor = Agg.UI.VAnchor.ParentCenter; - toggleLabel.Margin = new BorderDouble(right: 4); - - ToggleSwitch toggleSwitch = toggleSwitchFactory.GenerateGivenTextWidget(toggleLabel, "On", "Off", initiallyChecked); - toggleSwitch.VAnchor = Agg.UI.VAnchor.ParentCenter; - toggleSwitch.SwitchState = initiallyChecked; - - parentContainer.AddChild(toggleLabel); - parentContainer.AddChild(toggleSwitch); - - return toggleSwitch; - } } } \ No newline at end of file diff --git a/ControlElements/ToggleSwitchFactory.cs b/ControlElements/ToggleSwitchFactory.cs deleted file mode 100644 index 3a8c2f584..000000000 --- a/ControlElements/ToggleSwitchFactory.cs +++ /dev/null @@ -1,61 +0,0 @@ -using MatterHackers.Agg; -using MatterHackers.Agg.UI; - -namespace MatterHackers.MatterControl -{ - public class ToggleSwitchFactory - { - public RGBA_Bytes defaultBackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; - public RGBA_Bytes defaultInteriorColor = new RGBA_Bytes(220, 220, 220); - public RGBA_Bytes defaultThumbColor = ActiveTheme.Instance.PrimaryAccentColor; - public RGBA_Bytes defaultExteriorColor = ActiveTheme.Instance.PrimaryTextColor; - - public double defaultSwitchHeight = 24; - public double defaultSwitchWidth = 60; - - public const string defaultTrueText = "On"; - public const string defaultFalseText = "Off"; - - public ToggleSwitchFactory() - { - } - - public ToggleSwitch Generate(bool value = false) - { - ToggleSwitch toggleSwitch = new ToggleSwitch(defaultSwitchWidth, defaultSwitchHeight, value, defaultBackgroundColor, defaultInteriorColor, defaultThumbColor, defaultExteriorColor); - return toggleSwitch; - } - - public ToggleSwitch GenerateGivenTextWidget(TextWidget assocTextWidget, string trueText = defaultTrueText, string falseText = defaultFalseText, bool value = false) - { - ToggleSwitch toggleSwitch = new ToggleSwitch(assocTextWidget, trueText, falseText, defaultSwitchWidth, defaultSwitchHeight, value, defaultBackgroundColor, defaultInteriorColor, defaultThumbColor, defaultExteriorColor); - return toggleSwitch; - } - - public FlowLayoutWidget GenerateToggleSwitchAndTextWidget(string trueText = defaultTrueText, string falseText = defaultFalseText, bool value = false) - { - FlowLayoutWidget leftToRight = new FlowLayoutWidget(); - // leftToRight.Padding = new BorderDouble(3, 0, 0, 5) * TextWidget.GlobalPointSizeScaleRatio; - - TextWidget textWidget = new TextWidget(defaultFalseText, pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor); - textWidget.VAnchor = VAnchor.ParentCenter; - - ToggleSwitch toggleSwitch = new ToggleSwitch(textWidget, trueText, falseText, defaultSwitchWidth, defaultSwitchHeight, value, defaultBackgroundColor, defaultInteriorColor, defaultThumbColor, defaultExteriorColor); - toggleSwitch.VAnchor = VAnchor.ParentCenter; - setToggleSwitchColors(toggleSwitch); - - leftToRight.AddChild(toggleSwitch); - leftToRight.AddChild(textWidget); - - return leftToRight; - } - - private void setToggleSwitchColors(ToggleSwitch toggleSwitch) - { - toggleSwitch.BackgroundColor = defaultBackgroundColor; - toggleSwitch.InteriorColor = defaultInteriorColor; - toggleSwitch.ThumbColor = defaultThumbColor; - toggleSwitch.ExteriorColor = defaultExteriorColor; - } - } -} \ No newline at end of file diff --git a/MatterControl.csproj b/MatterControl.csproj index e4077c9b7..f9d261873 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -334,7 +334,6 @@ - diff --git a/PartPreviewWindow/ViewGcodeBasic.cs b/PartPreviewWindow/ViewGcodeBasic.cs index d54cf3034..13774c139 100644 --- a/PartPreviewWindow/ViewGcodeBasic.cs +++ b/PartPreviewWindow/ViewGcodeBasic.cs @@ -962,8 +962,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private void AddHandlers() { - expandModelOptions.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(expandModelOptions_CheckedStateChanged); - expandDisplayOptions.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(expandDisplayOptions_CheckedStateChanged); + expandModelOptions.CheckedStateChanged += expandModelOptions_CheckedStateChanged; + expandDisplayOptions.CheckedStateChanged += expandDisplayOptions_CheckedStateChanged; } private void expandModelOptions_CheckedStateChanged(object sender, EventArgs e) diff --git a/PrintHistory/PrintHistoryWidget.cs b/PrintHistory/PrintHistoryWidget.cs index 6aafed784..2e8c3a4ba 100644 --- a/PrintHistory/PrintHistoryWidget.cs +++ b/PrintHistory/PrintHistoryWidget.cs @@ -132,8 +132,8 @@ namespace MatterHackers.MatterControl.PrintHistory private void AddHandlers() { - showOnlyCompletedCheckbox.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(UpdateHistoryFilterShowCompleted); - showTimestampCheckbox.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(UpdateHistoryFilterShowTimestamp); + showOnlyCompletedCheckbox.CheckedStateChanged += UpdateHistoryFilterShowCompleted; + showTimestampCheckbox.CheckedStateChanged += UpdateHistoryFilterShowTimestamp; } private void UpdateHistoryFilterShowCompleted(object sender, EventArgs e) diff --git a/PrinterControls/ControlWidgets/ControlWidgetBase.cs b/PrinterControls/ControlWidgets/ControlWidgetBase.cs index 9bcc24502..700eca6d0 100644 --- a/PrinterControls/ControlWidgets/ControlWidgetBase.cs +++ b/PrinterControls/ControlWidgets/ControlWidgetBase.cs @@ -41,7 +41,6 @@ namespace MatterHackers.MatterControl.PrinterControls } protected TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); - protected ToggleSwitchFactory toggleSwitchFactory = new ToggleSwitchFactory(); private readonly double TallButtonHeight = 25 * TextWidget.GlobalPointSizeScaleRatio; diff --git a/PrinterControls/ControlWidgets/FanControls.cs b/PrinterControls/ControlWidgets/FanControls.cs index 2c275c10d..527fd5a49 100644 --- a/PrinterControls/ControlWidgets/FanControls.cs +++ b/PrinterControls/ControlWidgets/FanControls.cs @@ -41,8 +41,7 @@ namespace MatterHackers.MatterControl.PrinterControls private EditableNumberDisplay fanSpeedDisplay; - private TextWidget fanToggleSwitchText; - private ToggleSwitch toggleSwitch; + private CheckBox toggleSwitch; protected override void AddChildElements() { @@ -115,15 +114,12 @@ namespace MatterHackers.MatterControl.PrinterControls //Matt's test editing to add a on/off toggle switch bool fanActive = PrinterConnectionAndCommunication.Instance.FanSpeed0To255 != 0; - fanToggleSwitchText = new TextWidget(fanActive ? "On" : "Off", pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor); - fanToggleSwitchText.VAnchor = Agg.UI.VAnchor.ParentCenter; - - toggleSwitch = toggleSwitchFactory.GenerateGivenTextWidget(fanToggleSwitchText, "On", "Off", fanActive); - toggleSwitch.VAnchor = Agg.UI.VAnchor.ParentCenter; - toggleSwitch.SwitchStateChanged += new EventHandler(ToggleSwitch_Click); + toggleSwitch = new CheckBox(new ToggleSwitchView(60, 24, ActiveTheme.Instance.PrimaryBackgroundColor, new RGBA_Bytes(220, 220, 220), ActiveTheme.Instance.PrimaryAccentColor, ActiveTheme.Instance.PrimaryTextColor)); + toggleSwitch.Checked = fanActive; + toggleSwitch.VAnchor = VAnchor.ParentCenter; + toggleSwitch.CheckedStateChanged += new EventHandler(ToggleSwitch_Click); toggleSwitch.Margin = new BorderDouble(5, 0); - leftToRight.AddChild(fanToggleSwitchText); leftToRight.AddChild(toggleSwitch); return leftToRight; @@ -141,11 +137,11 @@ namespace MatterHackers.MatterControl.PrinterControls if (printerFanSpeed > 0) { - toggleSwitch.SwitchState = true; + toggleSwitch.Checked = true; } else { - toggleSwitch.SwitchState = false; + toggleSwitch.Checked = false; } doingDisplayUpdateFromPrinter = false; @@ -155,8 +151,8 @@ namespace MatterHackers.MatterControl.PrinterControls { if (!doingDisplayUpdateFromPrinter) { - ToggleSwitch toggleSwitch = (ToggleSwitch)sender; - if (toggleSwitch.SwitchState) + CheckBox toggleSwitch = (CheckBox)sender; + if (toggleSwitch.Checked) { PrinterConnectionAndCommunication.Instance.FanSpeed0To255 = 255; } diff --git a/SlicerConfiguration/SliceSettingsWidget.cs b/SlicerConfiguration/SliceSettingsWidget.cs index 6de85dacb..63ed903d9 100644 --- a/SlicerConfiguration/SliceSettingsWidget.cs +++ b/SlicerConfiguration/SliceSettingsWidget.cs @@ -131,7 +131,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration showHelpBox.Margin = new BorderDouble(right: 3); showHelpBox.VAnchor = VAnchor.ParentCenter; showHelpBox.Cursor = Cursors.Hand; - showHelpBox.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(RebuildSlicerSettings); + showHelpBox.CheckedStateChanged += RebuildSlicerSettings; this.AddChild(showHelpBox); } diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 6155e8669..64fc09991 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 6155e8669daa0ddf1cc1499fbc4133fa05b5a556 +Subproject commit 64fc09991b6034b4e18655932d6e4de466b4e4a9 From 53999cbc53ea5f04ede0bf6893d3e94a105c8975 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 22 Apr 2015 08:45:32 -0700 Subject: [PATCH 4/7] merge fix --- ConfigurationPage/PrinterSettings/PrinterSettingsView.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs b/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs index 0a1be8f90..616bd17d1 100644 --- a/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs +++ b/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs @@ -135,7 +135,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) => { - printLevelingSwitch.SwitchState = ActivePrinterProfile.Instance.DoPrintLeveling; SetPrintLevelButtonVisiblity(); printLevelingSwitch.Checked = ActivePrinterProfile.Instance.DoPrintLeveling; }, ref unregisterEvents); From ddd5ada23c749e664eb811e2775c4534669066e6 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 22 Apr 2015 08:57:55 -0700 Subject: [PATCH 5/7] Made a global function to create toggle check boxes. Made the text localized. --- ConfigurationPage/CloudSettings/CloudSettingsView.cs | 3 +-- .../PrinterSettings/PrinterSettingsView.cs | 12 +++++------- ControlElements/ImageButtonFactory.cs | 8 ++++++++ PrinterControls/ControlWidgets/FanControls.cs | 3 +-- Submodules/agg-sharp | 2 +- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ConfigurationPage/CloudSettings/CloudSettingsView.cs b/ConfigurationPage/CloudSettings/CloudSettingsView.cs index 7978aa3dd..58c6aa4dd 100644 --- a/ConfigurationPage/CloudSettings/CloudSettingsView.cs +++ b/ConfigurationPage/CloudSettings/CloudSettingsView.cs @@ -217,9 +217,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage levelingSwitchContainer.VAnchor = VAnchor.ParentCenter; levelingSwitchContainer.Margin = new BorderDouble(left: 16); - CheckBox enablePrintNotificationsSwitch = new CheckBox(new ToggleSwitchView(60, 24, ActiveTheme.Instance.PrimaryBackgroundColor, new RGBA_Bytes(220, 220, 220), ActiveTheme.Instance.PrimaryAccentColor, ActiveTheme.Instance.PrimaryTextColor)); + CheckBox enablePrintNotificationsSwitch = ImageButtonFactory.CreateToggleSwitch(UserSettings.Instance.get("PrintNotificationsEnabled") == "true"); enablePrintNotificationsSwitch.VAnchor = VAnchor.ParentCenter; - enablePrintNotificationsSwitch.Checked = UserSettings.Instance.get("PrintNotificationsEnabled") == "true"; enablePrintNotificationsSwitch.CheckedStateChanged += (sender, e) => { UserSettings.Instance.set("PrintNotificationsEnabled", enablePrintNotificationsSwitch.Checked ? "true" : "false"); diff --git a/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs b/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs index 616bd17d1..4c0bf5aa4 100644 --- a/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs +++ b/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs @@ -115,9 +115,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage ImageWidget levelingIcon = new ImageWidget(levelingImage); levelingIcon.Margin = new BorderDouble(right: 6); - CheckBox printLevelingSwitch = new CheckBox(new ToggleSwitchView(60, 24, ActiveTheme.Instance.PrimaryBackgroundColor, new RGBA_Bytes(220, 220, 220), ActiveTheme.Instance.PrimaryAccentColor, ActiveTheme.Instance.PrimaryTextColor)); - - printLevelingSwitch.Checked = ActivePrinterProfile.Instance.DoPrintLeveling; + CheckBox printLevelingSwitch = ImageButtonFactory.CreateToggleSwitch(ActivePrinterProfile.Instance.DoPrintLeveling); printLevelingSwitch.VAnchor = VAnchor.ParentCenter; printLevelingSwitch.Margin = new BorderDouble(left: 16); printLevelingSwitch.CheckedStateChanged += (sender, e) => @@ -193,11 +191,11 @@ namespace MatterHackers.MatterControl.ConfigurationPage publishImageSwitchContainer.VAnchor = VAnchor.ParentCenter; publishImageSwitchContainer.Margin = new BorderDouble(left: 16); - ToggleSwitch toggleSwitch = GenerateToggleSwitch(publishImageSwitchContainer, PrinterSettings.Instance.get("PublishBedImage") == "true"); - toggleSwitch.SwitchStateChanged += (sender, e) => + CheckBox toggleSwitch = ImageButtonFactory.CreateToggleSwitch(PrinterSettings.Instance.get("PublishBedImage") == "true"); + toggleSwitch.CheckedStateChanged += (sender, e) => { - ToggleSwitch thisControl = sender as ToggleSwitch; - PrinterSettings.Instance.set("PublishBedImage", thisControl.SwitchState ? "true" : "false"); + CheckBox thisControl = sender as CheckBox; + PrinterSettings.Instance.set("PublishBedImage", thisControl.Checked ? "true" : "false"); }; publishImageSwitchContainer.SetBoundsToEncloseChildren(); diff --git a/ControlElements/ImageButtonFactory.cs b/ControlElements/ImageButtonFactory.cs index fa593f349..d7f8441d7 100644 --- a/ControlElements/ImageButtonFactory.cs +++ b/ControlElements/ImageButtonFactory.cs @@ -32,6 +32,7 @@ using MatterHackers.Agg.ImageProcessing; using MatterHackers.Agg.PlatformAbstract; using MatterHackers.Agg.UI; using MatterHackers.Agg.VertexSource; +using MatterHackers.Localizations; namespace MatterHackers.MatterControl { @@ -39,6 +40,13 @@ namespace MatterHackers.MatterControl { public bool invertImageColor = true; + public static CheckBox CreateToggleSwitch(bool initialState) + { + CheckBox toggleBox = new CheckBox(new ToggleSwitchView("On".Localize(), "Off".Localize(), 60, 24, ActiveTheme.Instance.PrimaryBackgroundColor, new RGBA_Bytes(220, 220, 220), ActiveTheme.Instance.PrimaryAccentColor, ActiveTheme.Instance.PrimaryTextColor)); + toggleBox.Checked = initialState; + return toggleBox; + } + public Button Generate(string normalImageName, string hoverImageName, string pressedImageName = null, string disabledImageName = null) { if (pressedImageName == null) diff --git a/PrinterControls/ControlWidgets/FanControls.cs b/PrinterControls/ControlWidgets/FanControls.cs index 527fd5a49..99c9179d1 100644 --- a/PrinterControls/ControlWidgets/FanControls.cs +++ b/PrinterControls/ControlWidgets/FanControls.cs @@ -114,8 +114,7 @@ namespace MatterHackers.MatterControl.PrinterControls //Matt's test editing to add a on/off toggle switch bool fanActive = PrinterConnectionAndCommunication.Instance.FanSpeed0To255 != 0; - toggleSwitch = new CheckBox(new ToggleSwitchView(60, 24, ActiveTheme.Instance.PrimaryBackgroundColor, new RGBA_Bytes(220, 220, 220), ActiveTheme.Instance.PrimaryAccentColor, ActiveTheme.Instance.PrimaryTextColor)); - toggleSwitch.Checked = fanActive; + toggleSwitch = ImageButtonFactory.CreateToggleSwitch(fanActive); toggleSwitch.VAnchor = VAnchor.ParentCenter; toggleSwitch.CheckedStateChanged += new EventHandler(ToggleSwitch_Click); toggleSwitch.Margin = new BorderDouble(5, 0); diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 64fc09991..8a6ead084 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 64fc09991b6034b4e18655932d6e4de466b4e4a9 +Subproject commit 8a6ead084c8cd15b51d0be8030f001caa7cda016 From cd6b1615f6f163ff667091fbffa204b4cc6384c9 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 22 Apr 2015 18:11:47 -0700 Subject: [PATCH 6/7] Refactor --- ControlElements/ImageButtonFactory.cs | 8 +++++++- StaticData/Translations/Master.txt | 6 ++++++ Submodules/agg-sharp | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ControlElements/ImageButtonFactory.cs b/ControlElements/ImageButtonFactory.cs index d7f8441d7..c2ffa5787 100644 --- a/ControlElements/ImageButtonFactory.cs +++ b/ControlElements/ImageButtonFactory.cs @@ -42,7 +42,13 @@ namespace MatterHackers.MatterControl public static CheckBox CreateToggleSwitch(bool initialState) { - CheckBox toggleBox = new CheckBox(new ToggleSwitchView("On".Localize(), "Off".Localize(), 60, 24, ActiveTheme.Instance.PrimaryBackgroundColor, new RGBA_Bytes(220, 220, 220), ActiveTheme.Instance.PrimaryAccentColor, ActiveTheme.Instance.PrimaryTextColor)); + ToggleSwitchView toggleView = new ToggleSwitchView("On".Localize(), "Off".Localize(), + 60, 24, + ActiveTheme.Instance.PrimaryBackgroundColor, + new RGBA_Bytes(220, 220, 220), + ActiveTheme.Instance.PrimaryAccentColor, + ActiveTheme.Instance.PrimaryTextColor); + CheckBox toggleBox = new CheckBox(toggleView); toggleBox.Checked = initialState; return toggleBox; } diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 390d4b7b8..f9d5d5aa9 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -3167,3 +3167,9 @@ Translated:Reset English:Console Translated:Console +English:On +Translated:On + +English:Off +Translated:Off + diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 8a6ead084..8a2aedc78 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 8a6ead084c8cd15b51d0be8030f001caa7cda016 +Subproject commit 8a2aedc78b6f787a717af9f406513f215d6af119 From 75f8e49060b2377223f8655a0385d4fdce30c79b Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 22 Apr 2015 18:25:17 -0700 Subject: [PATCH 7/7] latest agg --- Submodules/agg-sharp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 8a2aedc78..1956e1296 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 8a2aedc78b6f787a717af9f406513f215d6af119 +Subproject commit 1956e129608bb7dd5c0c942ca35791c2f50f411e