From ab7f2dc4923c3fb36db4ecc0bf0d9d23140788a7 Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Sun, 17 May 2020 13:28:35 -0700 Subject: [PATCH] adding user dialog showing prefs to settings --- .../ApplicationView/ApplicationController.cs | 8 +- .../ApplicationSettingsPage.cs | 194 ++++++++++++++---- .../SettingsManagement/UserSettings.cs | 2 +- MatterControlLib/SetupWizard/WelcomePage.cs | 6 +- Program.cs | 2 +- StaticData/OEMSettings/Printers.json | 4 + Submodules/agg-sharp | 2 +- 7 files changed, 168 insertions(+), 50 deletions(-) diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index f110bde66..c93489d36 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -3243,17 +3243,17 @@ Support and tutorials: TextColor = AppContext.Theme.TextColor, Margin = new BorderDouble(top: 6, left: 6), HAnchor = Agg.UI.HAnchor.Left, - Checked = ApplicationSettings.Instance.get(userKey) == "false" + Checked = UserSettings.Instance.get(userKey) == "false" }; hideAfterPrintMessage.Click += (s, e1) => { if (hideAfterPrintMessage.Checked) { - ApplicationSettings.Instance.set(userKey, "false"); + UserSettings.Instance.set(userKey, "false"); } else { - ApplicationSettings.Instance.set(userKey, "true"); + UserSettings.Instance.set(userKey, "true"); } }; @@ -4197,7 +4197,7 @@ Support and tutorials: } - if (ApplicationSettings.Instance.get(UserSettingsKey.ShownWelcomeMessage) != "false") + if (UserSettings.Instance.get(UserSettingsKey.ShownWelcomeMessage) != "false") { UiThread.RunOnIdle(() => { diff --git a/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs b/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs index 5f99900e8..7b67666ec 100644 --- a/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs +++ b/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs @@ -32,14 +32,15 @@ using System.Diagnostics; using System.IO; using System.Linq; using MatterHackers.Agg; +using MatterHackers.Agg.Image; using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.MatterControl.ConfigurationPage; using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.DataStorage; -using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.VectorMath; + namespace MatterHackers.MatterControl { public partial class ApplicationSettingsPage : DialogPage @@ -54,7 +55,49 @@ namespace MatterHackers.MatterControl contentRow.Padding = theme.DefaultContainerPadding; contentRow.Padding = 0; contentRow.BackgroundColor = Color.Transparent; + GuiWidget settingsColumn; + { + var settingsAreaScrollBox = new ScrollableWidget(true); + settingsAreaScrollBox.ScrollArea.HAnchor |= HAnchor.Stretch; + settingsAreaScrollBox.AnchorAll(); + settingsAreaScrollBox.BackgroundColor = theme.MinimalShade; + contentRow.AddChild(settingsAreaScrollBox); + + settingsColumn = new FlowLayoutWidget(FlowDirection.TopToBottom) + { + HAnchor = HAnchor.MaxFitOrStretch + }; + + settingsAreaScrollBox.AddChild(settingsColumn); + } + + AddGeneralPannel(settingsColumn); + + AddUsserOptionsPannel(settingsColumn); + + AddAdvancedPannel(settingsColumn); + + // Enforce consistent SectionWidget spacing and last child borders + foreach (var section in settingsColumn.Children()) + { + section.Margin = new BorderDouble(0, 10, 0, 0); + + if (section.ContentPanel.Children.LastOrDefault() is SettingsItem lastRow) + { + // If we're in a contentPanel that has SettingsItems... + + // Clear the last items bottom border + lastRow.Border = lastRow.Border.Clone(bottom: 0); + + // Set a common margin on the parent container + section.ContentPanel.Margin = new BorderDouble(2, 0); + } + } + } + + private void AddGeneralPannel(GuiWidget settingsColumn) + { var generalPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, @@ -69,7 +112,7 @@ namespace MatterHackers.MatterControl HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; - contentRow.AddChild(generalSection); + settingsColumn.AddChild(generalSection); theme.ApplyBoxStyle(generalSection); @@ -145,7 +188,7 @@ namespace MatterHackers.MatterControl }, configureNotificationsButton, AggContext.StaticData.LoadIcon("notify-24x24.png", 16, 16, theme.InvertIcons)), - generalPanel); + generalPanel); // LanguageControl var languageSelector = new LanguageSelector(theme); @@ -246,7 +289,7 @@ namespace MatterHackers.MatterControl double sliderThumbWidth = 10 * GuiWidget.DeviceScale; double sliderWidth = 100 * GuiWidget.DeviceScale; - var textSizeSlider = new SolidSlider(new Vector2(), sliderThumbWidth, theme, .7, 2.5) + var textSizeSlider = new SolidSlider(default(Vector2), sliderThumbWidth, theme, .7, 2.5) { Name = "Text Size Slider", Margin = new BorderDouble(5, 0), @@ -298,9 +341,12 @@ namespace MatterHackers.MatterControl this.AddSettingsRow(textSizeRow, generalPanel); var themeSection = CreateThemePanel(theme); - contentRow.AddChild(themeSection); + settingsColumn.AddChild(themeSection); theme.ApplyBoxStyle(themeSection); + } + private void AddAdvancedPannel(GuiWidget settingsColumn) + { var advancedPanel = new FlowLayoutWidget(FlowDirection.TopToBottom); var advancedSection = new SectionWidget("Advanced".Localize(), advancedPanel, theme, serializationKey: "ApplicationSettings-Advanced", expanded: false) @@ -310,7 +356,7 @@ namespace MatterHackers.MatterControl VAnchor = VAnchor.Fit, Margin = 0 }; - contentRow.AddChild(advancedSection); + settingsColumn.AddChild(advancedSection); theme.ApplyBoxStyle(advancedSection); @@ -334,28 +380,11 @@ namespace MatterHackers.MatterControl }), advancedPanel); - // Touch Screen Mode - this.AddSettingsRow( - new SettingsItem( - "Utilize High Res Monitors".Localize(), - theme, - new SettingsItem.ToggleSwitchConfig() - { - Checked = UserSettings.Instance.get(UserSettingsKey.ApplicationDpiAwareness) == "PerMonitorAware", - ToggleAction = (itemChecked) => - { - string dpiAwareness = itemChecked ? "PerMonitorAware" : "None"; - if (dpiAwareness != UserSettings.Instance.get(UserSettingsKey.ApplicationDpiAwareness)) - { - UserSettings.Instance.set(UserSettingsKey.ApplicationDpiAwareness, dpiAwareness); - StyledMessageBox.ShowMessageBox( - "To finish changing your monitor settings you need to restart MatterControl. If after changing your fonts are too small you can adjust Text Size.".Localize(), - "Restart Required".Localize()); - UiThread.RunOnIdle(() => ApplicationController.Instance.ReloadAll().ConfigureAwait(false)); - } - } - }), - advancedPanel); + AddUserBoolToggle(advancedPanel, + "Utilize High Res Monitors".Localize(), + UserSettingsKey.ApplicationUseHeigResDisplays, + true, + false); var openCacheButton = new IconButton(AggContext.StaticData.LoadIcon("fa-link_16.png", 16, 16, theme.InvertIcons), theme) { @@ -390,6 +419,8 @@ namespace MatterHackers.MatterControl advancedPanel); #if DEBUG + var configureIcon = AggContext.StaticData.LoadIcon("fa-cog_16.png", 16, 16, theme.InvertIcons); + var configurePluginsButton = new IconButton(configureIcon, theme) { ToolTipText = "Configure Plugins".Localize(), @@ -412,23 +443,106 @@ namespace MatterHackers.MatterControl #endif advancedPanel.Children().First().Border = new BorderDouble(0, 1); + } - // Enforce consistent SectionWidget spacing and last child borders - foreach (var section in contentRow.Children()) + private void AddUsserOptionsPannel(GuiWidget settingsColumn) + { + var optionsPanel = new FlowLayoutWidget(FlowDirection.TopToBottom); + + var optionsSection = new SectionWidget("Options".Localize(), optionsPanel, theme, serializationKey: "ApplicationSettings-Options", expanded: false) { - section.Margin = new BorderDouble(0, 10, 0, 0); + Name = "Options Section", + HAnchor = HAnchor.Stretch, + VAnchor = VAnchor.Fit, + Margin = 0 + }; + settingsColumn.AddChild(optionsSection); - if (section.ContentPanel.Children.LastOrDefault() is SettingsItem lastRow) - { - // If we're in a contentPanel that has SettingsItems... + theme.ApplyBoxStyle(optionsSection); - // Clear the last items bottom border - lastRow.Border = lastRow.Border.Clone(bottom: 0); + AddUserBoolToggle(optionsPanel, + "Shown Welcome Message".Localize(), + UserSettingsKey.ShownWelcomeMessage, + false, + false); - // Set a common margin on the parent container - section.ContentPanel.Margin = new BorderDouble(2, 0); - } - } + AddUserBoolToggle(optionsPanel, + "Shown Print Canceled Message".Localize(), + UserSettingsKey.ShownPrintCanceledMessage, + false, + false); + + AddUserBoolToggle(optionsPanel, + "Shown Print Complete Message".Localize(), + UserSettingsKey.ShownPrintCompleteMessage, + false, + false); + + optionsPanel.Children().First().Border = new BorderDouble(0, 1); + } + + private void AddUserBoolToggle(FlowLayoutWidget advancedPanel, string title, string boolKey, bool requiresRestart, bool reloadAll) + { + this.AddSettingsRow( + new SettingsItem( + title, + theme, + new SettingsItem.ToggleSwitchConfig() + { + Checked = UserSettings.Instance.get(boolKey) != "false", + ToggleAction = (itemChecked) => + { + string boolValue = itemChecked ? "true" : "false"; + if (boolValue != UserSettings.Instance.get(boolKey)) + { + UserSettings.Instance.set(boolKey, boolValue); + if (requiresRestart) + { + StyledMessageBox.ShowMessageBox( + "To finish changing your monitor settings you need to restart MatterControl. If after changing your fonts are too small you can adjust Text Size.".Localize(), + "Restart Required".Localize()); + } + + if (reloadAll) + { + UiThread.RunOnIdle(() => ApplicationController.Instance.ReloadAll().ConfigureAwait(false)); + } + } + } + }), + advancedPanel); + } + + private void AddApplicationBoolToggle(FlowLayoutWidget advancedPanel, string title, string boolKey, bool requiresRestart, bool reloadAll) + { + this.AddSettingsRow( + new SettingsItem( + title, + theme, + new SettingsItem.ToggleSwitchConfig() + { + Checked = ApplicationSettings.Instance.get(boolKey) == "true", + ToggleAction = (itemChecked) => + { + string boolValue = itemChecked ? "true" : "false"; + if (boolValue != UserSettings.Instance.get(boolKey)) + { + ApplicationSettings.Instance.set(boolKey, boolValue); + if (requiresRestart) + { + StyledMessageBox.ShowMessageBox( + "To finish changing your monitor settings you need to restart MatterControl. If after changing your fonts are too small you can adjust Text Size.".Localize(), + "Restart Required".Localize()); + } + + if (reloadAll) + { + UiThread.RunOnIdle(() => ApplicationController.Instance.ReloadAll().ConfigureAwait(false)); + } + } + } + }), + advancedPanel); } public static SectionWidget CreateThemePanel(ThemeConfig theme) diff --git a/MatterControlLib/SettingsManagement/UserSettings.cs b/MatterControlLib/SettingsManagement/UserSettings.cs index dfdda5ea5..c6e0fc5dd 100644 --- a/MatterControlLib/SettingsManagement/UserSettings.cs +++ b/MatterControlLib/SettingsManagement/UserSettings.cs @@ -17,7 +17,7 @@ namespace MatterHackers.MatterControl public const string AfterPrintFinishedSendEmail = nameof(AfterPrintFinishedSendEmail); public const string AfterPrintFinishedSendTextMessage = nameof(AfterPrintFinishedSendTextMessage); public const string ApplicationDisplayMode = nameof(ApplicationDisplayMode); - public const string ApplicationDpiAwareness = nameof(ApplicationDpiAwareness); + public const string ApplicationUseHeigResDisplays = nameof(ApplicationUseHeigResDisplays); public const string ApplicationTextSize = nameof(ApplicationTextSize); public const string ColorPanelExpanded = nameof(ColorPanelExpanded); public const string ConfigurePrinter_CurrentTab = nameof(ConfigurePrinter_CurrentTab); diff --git a/MatterControlLib/SetupWizard/WelcomePage.cs b/MatterControlLib/SetupWizard/WelcomePage.cs index d7fe889cc..dbd1cdac3 100644 --- a/MatterControlLib/SetupWizard/WelcomePage.cs +++ b/MatterControlLib/SetupWizard/WelcomePage.cs @@ -63,17 +63,17 @@ namespace MatterHackers.MatterControl.Tour TextColor = theme.TextColor, Margin = new BorderDouble(top: 6, left: 6), HAnchor = Agg.UI.HAnchor.Left, - Checked = ApplicationSettings.Instance.get(UserSettingsKey.ShownWelcomeMessage) == "false" + Checked = UserSettings.Instance.get(UserSettingsKey.ShownWelcomeMessage) == "false" }; showWelcomePageCheckBox.Click += (sender, e) => { if (showWelcomePageCheckBox.Checked) { - ApplicationSettings.Instance.set(UserSettingsKey.ShownWelcomeMessage, "false"); + UserSettings.Instance.set(UserSettingsKey.ShownWelcomeMessage, "false"); } else { - ApplicationSettings.Instance.set(UserSettingsKey.ShownWelcomeMessage, "true"); + UserSettings.Instance.set(UserSettingsKey.ShownWelcomeMessage, "true"); } }; contentRow.AddChild(showWelcomePageCheckBox); diff --git a/Program.cs b/Program.cs index 8c9cdb182..cab73acaa 100644 --- a/Program.cs +++ b/Program.cs @@ -168,7 +168,7 @@ namespace MatterHackers.MatterControl Datastore.Instance.Initialize(DesktopSqlite.CreateInstance()); - if (UserSettings.Instance.get(UserSettingsKey.ApplicationDpiAwareness) == "PerMonitorAware") + if (UserSettings.Instance.get(UserSettingsKey.ApplicationUseHeigResDisplays) == "true") { SetProcessDpiAwareness((int)DpiAwareness.PerMonitorAware); } diff --git a/StaticData/OEMSettings/Printers.json b/StaticData/OEMSettings/Printers.json index 481942b62..0ea207bfa 100644 --- a/StaticData/OEMSettings/Printers.json +++ b/StaticData/OEMSettings/Printers.json @@ -1,10 +1,14 @@ { + "Airwolf 3D-Axiom": { "SID": "ML3DTSYL" }, + "Airwolf 3D-HD": { "SID": "MW46VP7T" }, "BCN-Sigma": { "SID": "MCN1YNVE" }, "BCN3D-Sigma": { "SID": "MCN1YNVE" }, "Creality-CR-10 300": { "AltInfoUrl": "https://www.matterhackers.com/store/c/creality-3d-printers" }, "Creality-CR-10 400": { "AltInfoUrl": "https://www.matterhackers.com/store/c/creality-3d-printers" }, "Creality-CR-10 500": { "AltInfoUrl": "https://www.matterhackers.com/store/c/creality-3d-printers" }, + "Creality-CR-10 S": { "SID": "MDDVR1KC" }, "Creality-CR-20": { "SID": "MN6SPN76" }, + "Creality-Ender 3": { "SID": "M34AK4ZG" }, "FlashForge-Creator Dual": { "AltInfoUrl": "https://www.matterhackers.com/s/store?q=FlashForge" }, "FlashForge-Creator Pro Dual": { "SID": "MW7Z2YD3" }, "FlashForge-Creator X Dual": { "AltInfoUrl": "https://www.matterhackers.com/s/store?q=FlashForge" }, diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 607eb087a..078dd0e96 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 607eb087a5170d299b8af1ef4161b9cf9843154c +Subproject commit 078dd0e962a0f0a9b0ec19499b53dd228c20f897