From c63173f199dae102f5a1613e8918683c955fa129 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 18 Apr 2018 14:38:09 -0700 Subject: [PATCH 1/4] Moving all user settings test strings into UserSettingsKey prototyping user tips system --- ApplicationView/ApplicationController.cs | 22 ++++- ApplicationView/PrinterModels.cs | 36 ++++---- .../ApplicationSettingsView.cs | 8 +- ConfigurationPage/LanguageSelector.cs | 2 +- .../CalibrateProbeLastPagelInstructions.cs | 2 +- .../WizardPages/LastPagelInstructions.cs | 9 ++ History/PrintHistoryData.cs | 2 +- Library/Widgets/PrintLibraryWidget.cs | 6 +- MatterControl.csproj | 3 +- PartPreviewWindow/PrinterTabPage.cs | 4 +- .../ControlWidgets}/CalibrationControls.cs | 0 SettingsManagement/UserSettings.cs | 59 +++++++++---- SetupWizard/LicenseAgreementPage.cs | 2 +- SetupWizard/UserTipManager.cs | 83 +++++++++++++++++++ Submodules/agg-sharp | 2 +- 15 files changed, 185 insertions(+), 55 deletions(-) rename {ConfigurationPage/CalibrationSettings => PrinterControls/ControlWidgets}/CalibrationControls.cs (100%) create mode 100644 SetupWizard/UserTipManager.cs diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index 45ca1a2fd..1a9f33c52 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -65,6 +65,7 @@ namespace MatterHackers.MatterControl using MatterHackers.MatterControl.PartPreviewWindow; using MatterHackers.MatterControl.PartPreviewWindow.View3D; using MatterHackers.MatterControl.PrinterControls.PrinterConnections; + using MatterHackers.MatterControl.SetupWizard; using MatterHackers.PolygonMesh; using MatterHackers.RenderOpenGl; using MatterHackers.SerialPortCommunication; @@ -904,7 +905,7 @@ namespace MatterHackers.MatterControl var printer = ApplicationController.Instance.ActivePrinters.Where(p => p.Connection == s).FirstOrDefault(); if (printer != null) { - ApplicationController.Instance.RunAnyRequiredCalibration(printer, this.Theme); + ApplicationController.Instance.RunAnyRequiredPrinterSetup(printer, this.Theme); } }, ref unregisterEvents); @@ -926,7 +927,7 @@ namespace MatterHackers.MatterControl } } - public bool RunAnyRequiredCalibration(PrinterConfig printer, ThemeConfig theme) + public bool RunAnyRequiredPrinterSetup(PrinterConfig printer, ThemeConfig theme) { if (PrintLevelingData.NeedsToBeRun(printer)) { @@ -948,6 +949,19 @@ namespace MatterHackers.MatterControl return true; } + // tell the user about loading filament if they have not already been told + if(UserSettings.Instance.get(UserSettingsKey.DisplayedTip_LoadFilament) != "1") + { + var widgetName = "Hotend 0"; + + string extruder0TipMessage = "Extruder Controls can be fonud here.".Localize() + "\n" + + "They include".Localize() + ":\n" + + "\t• " + "Select Material".Localize() + "\n" + + "\t• " + "Set Temperature".Localize() + "\n" + + "\t• " + "Load and Unload Filament".Localize() + "\n"; + UserTipManager.Instance.ShowTip(AppContext.RootSystemWindow, widgetName, extruder0TipMessage); + } + return false; } @@ -1267,7 +1281,7 @@ namespace MatterHackers.MatterControl if (AggContext.OperatingSystem == OSType.Android) { // show this last so it is on top - if (UserSettings.Instance.get("SoftwareLicenseAccepted") != "true") + if (UserSettings.Instance.get(UserSettingsKey.SoftwareLicenseAccepted) != "true") { UiThread.RunOnIdle(() => DialogWindow.Show()); } @@ -1550,7 +1564,7 @@ namespace MatterHackers.MatterControl try { // If leveling is required or is currently on - if(ApplicationController.Instance.RunAnyRequiredCalibration(printer, this.Theme)) + if(ApplicationController.Instance.RunAnyRequiredPrinterSetup(printer, this.Theme)) { // We need to calibrate. So, don't print this part. return; diff --git a/ApplicationView/PrinterModels.cs b/ApplicationView/PrinterModels.cs index 47f5ab3e0..280dffd3c 100644 --- a/ApplicationView/PrinterModels.cs +++ b/ApplicationView/PrinterModels.cs @@ -919,7 +919,7 @@ namespace MatterHackers.MatterControl { get { - string value = UserSettings.Instance.get("GcodeViewerRenderGrid"); + string value = UserSettings.Instance.get(UserSettingsKey.GcodeViewerRenderGrid); if (value == null) { return true; @@ -930,7 +930,7 @@ namespace MatterHackers.MatterControl { if (this.RenderBed != value) { - UserSettings.Instance.set("GcodeViewerRenderGrid", value.ToString()); + UserSettings.Instance.set(UserSettingsKey.GcodeViewerRenderGrid, value.ToString()); this.IsDirty = true; this.OnPropertyChanged(nameof(RenderBed)); } @@ -939,12 +939,12 @@ namespace MatterHackers.MatterControl public bool RenderMoves { - get => UserSettings.Instance.get("GcodeViewerRenderMoves") == "True"; + get => UserSettings.Instance.get(UserSettingsKey.GcodeViewerRenderMoves) == "True"; set { if (this.RenderMoves != value) { - UserSettings.Instance.set("GcodeViewerRenderMoves", value.ToString()); + UserSettings.Instance.set(UserSettingsKey.GcodeViewerRenderMoves, value.ToString()); this.IsDirty = true; this.OnPropertyChanged(nameof(RenderMoves)); } @@ -953,12 +953,12 @@ namespace MatterHackers.MatterControl public bool RenderRetractions { - get => UserSettings.Instance.get("GcodeViewerRenderRetractions") == "True"; + get => UserSettings.Instance.get(UserSettingsKey.GcodeViewerRenderRetractions) == "True"; set { if (this.RenderRetractions != value) { - UserSettings.Instance.set("GcodeViewerRenderRetractions", value.ToString()); + UserSettings.Instance.set(UserSettingsKey.GcodeViewerRenderRetractions, value.ToString()); this.IsDirty = true; this.OnPropertyChanged(nameof(RenderRetractions)); } @@ -967,12 +967,12 @@ namespace MatterHackers.MatterControl public string GCodeModelView { - get => UserSettings.Instance.get("GcodeModelView"); + get => UserSettings.Instance.get(UserSettingsKey.GcodeModelView); set { if (this.GCodeModelView != value) { - UserSettings.Instance.set("GcodeModelView", value); + UserSettings.Instance.set(UserSettingsKey.GcodeModelView, value); this.IsDirty = true; this.OnPropertyChanged(nameof(GCodeModelView)); } @@ -981,12 +981,12 @@ namespace MatterHackers.MatterControl public string GCodeLineColorStyle { - get => UserSettings.Instance.get("GCodeLineColorStyle"); + get => UserSettings.Instance.get(UserSettingsKey.GCodeLineColorStyle); set { if (this.GCodeLineColorStyle != value) { - UserSettings.Instance.set("GCodeLineColorStyle", value); + UserSettings.Instance.set(UserSettingsKey.GCodeLineColorStyle, value); this.IsDirty = true; this.OnPropertyChanged(nameof(GCodeLineColorStyle)); } @@ -995,12 +995,12 @@ namespace MatterHackers.MatterControl public bool SimulateExtrusion { - get => UserSettings.Instance.get("GcodeViewerSimulateExtrusion") == "True"; + get => UserSettings.Instance.get(UserSettingsKey.GcodeViewerSimulateExtrusion) == "True"; set { if (this.SimulateExtrusion != value) { - UserSettings.Instance.set("GcodeViewerSimulateExtrusion", value.ToString()); + UserSettings.Instance.set(UserSettingsKey.GcodeViewerSimulateExtrusion, value.ToString()); this.IsDirty = true; this.OnPropertyChanged(nameof(SimulateExtrusion)); } @@ -1009,12 +1009,12 @@ namespace MatterHackers.MatterControl public bool TransparentExtrusion { - get => UserSettings.Instance.get("GcodeViewerTransparentExtrusion") == "True"; + get => UserSettings.Instance.get(UserSettingsKey.GcodeViewerTransparentExtrusion) == "True"; set { if (this.TransparentExtrusion != value) { - UserSettings.Instance.set("GcodeViewerTransparentExtrusion", value.ToString()); + UserSettings.Instance.set(UserSettingsKey.GcodeViewerTransparentExtrusion, value.ToString()); this.IsDirty = true; this.OnPropertyChanged(nameof(TransparentExtrusion)); } @@ -1025,7 +1025,7 @@ namespace MatterHackers.MatterControl { get { - string value = UserSettings.Instance.get("GcodeViewerHideExtruderOffsets"); + string value = UserSettings.Instance.get(UserSettingsKey.GcodeViewerHideExtruderOffsets); if (value == null) { return true; @@ -1036,7 +1036,7 @@ namespace MatterHackers.MatterControl { if (this.HideExtruderOffsets != value) { - UserSettings.Instance.set("GcodeViewerHideExtruderOffsets", value.ToString()); + UserSettings.Instance.set(UserSettingsKey.GcodeViewerHideExtruderOffsets, value.ToString()); this.IsDirty = true; this.OnPropertyChanged(nameof(HideExtruderOffsets)); } @@ -1045,12 +1045,12 @@ namespace MatterHackers.MatterControl public bool SyncToPrint { - get => UserSettings.Instance.get("LayerViewSyncToPrint") == "True"; + get => UserSettings.Instance.get(UserSettingsKey.LayerViewSyncToPrint) == "True"; set { if (this.SyncToPrint != value) { - UserSettings.Instance.set("LayerViewSyncToPrint", value.ToString()); + UserSettings.Instance.set(UserSettingsKey.LayerViewSyncToPrint, value.ToString()); this.IsDirty = true; this.OnPropertyChanged(nameof(SyncToPrint)); } diff --git a/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs b/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs index 1265f15fa..41d12939f 100644 --- a/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs +++ b/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs @@ -109,10 +109,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage theme, new SettingsItem.ToggleSwitchConfig() { - Checked = UserSettings.Instance.get("PrintNotificationsEnabled") == "true", + Checked = UserSettings.Instance.get(UserSettingsKey.PrintNotificationsEnabled) == "true", ToggleAction = (itemChecked) => { - UserSettings.Instance.set("PrintNotificationsEnabled", itemChecked ? "true" : "false"); + UserSettings.Instance.set(UserSettingsKey.PrintNotificationsEnabled, itemChecked ? "true" : "false"); } }, configureNotificationsButton, @@ -144,9 +144,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage UiThread.RunOnIdle(() => { string languageCode = languageSelector.SelectedValue; - if (languageCode != UserSettings.Instance.get("Language")) + if (languageCode != UserSettings.Instance.get(UserSettingsKey.Language)) { - UserSettings.Instance.set("Language", languageCode); + UserSettings.Instance.set(UserSettingsKey.Language, languageCode); if (languageCode == "L10N") { diff --git a/ConfigurationPage/LanguageSelector.cs b/ConfigurationPage/LanguageSelector.cs index 01a95b341..b8710cebc 100644 --- a/ConfigurationPage/LanguageSelector.cs +++ b/ConfigurationPage/LanguageSelector.cs @@ -21,7 +21,7 @@ namespace MatterHackers.MatterControl AddItem(entry.Key, entry.Value); } - string languageCode = UserSettings.Instance.get("Language"); + string languageCode = UserSettings.Instance.get(UserSettingsKey.Language); foreach (KeyValuePair entry in languageDict) { if (languageCode == entry.Value) diff --git a/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPagelInstructions.cs b/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPagelInstructions.cs index 8201e9faf..0794f053d 100644 --- a/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPagelInstructions.cs +++ b/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPagelInstructions.cs @@ -66,7 +66,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling Closed += (s, e) => { // move from this wizard to the print leveling wizard if needed - ApplicationController.Instance.RunAnyRequiredCalibration(printer, theme); + ApplicationController.Instance.RunAnyRequiredPrinterSetup(printer, theme); }; base.PageIsBecomingActive(); diff --git a/ConfigurationPage/PrintLeveling/WizardPages/LastPagelInstructions.cs b/ConfigurationPage/PrintLeveling/WizardPages/LastPagelInstructions.cs index 3fdd44828..2f31be15c 100644 --- a/ConfigurationPage/PrintLeveling/WizardPages/LastPagelInstructions.cs +++ b/ConfigurationPage/PrintLeveling/WizardPages/LastPagelInstructions.cs @@ -40,10 +40,12 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { protected WizardControl container; private List probePositions; + private ThemeConfig theme; public LastPagelInstructions(PrinterConfig printer, WizardControl container, string pageDescription, string instructionsText, List probePositions, ThemeConfig theme) : base(printer, pageDescription, instructionsText, theme) { + this.theme = theme; this.probePositions = probePositions; this.container = container; } @@ -78,6 +80,13 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling // Make sure when the wizard is done we turn off the bed heating printer.Connection.TurnOffBedAndExtruders(TurnOff.AfterDelay); + Closed += (s, e) => + { + // give instruction about how to load filament if the user has not gotten them + ApplicationController.Instance.RunAnyRequiredPrinterSetup(printer, theme); + }; + + base.PageIsBecomingActive(); } } diff --git a/History/PrintHistoryData.cs b/History/PrintHistoryData.cs index b8d6f3b6f..6cb7dfca0 100644 --- a/History/PrintHistoryData.cs +++ b/History/PrintHistoryData.cs @@ -116,7 +116,7 @@ namespace MatterHackers.MatterControl.PrintHistory public IEnumerable GetHistoryItems(int recordCount) { string query; - if (UserSettings.Instance.get("PrintHistoryFilterShowCompleted") == "true") + if (UserSettings.Instance.get(UserSettingsKey.PrintHistoryFilterShowCompleted) == "true") { query = string.Format("SELECT * FROM PrintTask WHERE PrintComplete = 1 ORDER BY PrintStart DESC LIMIT {0};", recordCount); } diff --git a/Library/Widgets/PrintLibraryWidget.cs b/Library/Widgets/PrintLibraryWidget.cs index f1fc81973..6ab49c9e2 100644 --- a/Library/Widgets/PrintLibraryWidget.cs +++ b/Library/Widgets/PrintLibraryWidget.cs @@ -75,7 +75,7 @@ namespace MatterHackers.MatterControl.PrintLibrary { Name = "LibraryView", // Drop containers if ShowContainers != 1 - ContainerFilter = (container) => UserSettings.Instance.get("ShowContainers") == "1", + ContainerFilter = (container) => UserSettings.Instance.get(UserSettingsKey.ShowContainers) == "1", BackgroundColor = theme.ActiveTabColor, //BorderColor = theme.MinimalShade, Border = new BorderDouble(top: 1) @@ -164,12 +164,12 @@ namespace MatterHackers.MatterControl.PrintLibrary VAnchor = VAnchor.Fit, Padding = new BorderDouble(left: 2, bottom: 2, top: 6), // Same padding as toolbar above Name = "Show Folders Toggle", - Checked = UserSettings.Instance.get("ShowContainers") == "1", + Checked = UserSettings.Instance.get(UserSettingsKey.ShowContainers) == "1", MinimumSize = new Vector2(0, theme.ButtonHeight) }; showFolders.CheckedStateChanged += async (s, e) => { - UserSettings.Instance.set("ShowContainers", showFolders.Checked ? "1" : "0"); + UserSettings.Instance.set(UserSettingsKey.ShowContainers, showFolders.Checked ? "1" : "0"); await libraryView.Reload(); }; toolbar.AddChild(showFolders); diff --git a/MatterControl.csproj b/MatterControl.csproj index 5d083d016..c31736649 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -74,7 +74,8 @@ - + + diff --git a/PartPreviewWindow/PrinterTabPage.cs b/PartPreviewWindow/PrinterTabPage.cs index 9e4934615..880ddb5c9 100644 --- a/PartPreviewWindow/PrinterTabPage.cs +++ b/PartPreviewWindow/PrinterTabPage.cs @@ -250,12 +250,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow switch (viewMode) { case PartViewMode.Layers2D: - UserSettings.Instance.set("LayerViewDefault", "2D Layer"); + UserSettings.Instance.set(UserSettingsKey.LayerViewDefault, "2D Layer"); gcode2DWidget.Visible = true; break; case PartViewMode.Layers3D: - UserSettings.Instance.set("LayerViewDefault", "3D Layer"); + UserSettings.Instance.set(UserSettingsKey.LayerViewDefault, "3D Layer"); break; case PartViewMode.Model: diff --git a/ConfigurationPage/CalibrationSettings/CalibrationControls.cs b/PrinterControls/ControlWidgets/CalibrationControls.cs similarity index 100% rename from ConfigurationPage/CalibrationSettings/CalibrationControls.cs rename to PrinterControls/ControlWidgets/CalibrationControls.cs diff --git a/SettingsManagement/UserSettings.cs b/SettingsManagement/UserSettings.cs index 177ee52ec..9f561baaa 100644 --- a/SettingsManagement/UserSettings.cs +++ b/SettingsManagement/UserSettings.cs @@ -6,29 +6,52 @@ namespace MatterHackers.MatterControl { public static class UserSettingsKey { - public const string UpdateFeedType = nameof(UpdateFeedType); + public const string AfterPrintFinishedPlaySound = nameof(AfterPrintFinishedPlaySound); + public const string AfterPrintFinishedSendEmail = nameof(AfterPrintFinishedSendEmail); + public const string AfterPrintFinishedSendTextMessage = nameof(AfterPrintFinishedSendTextMessage); public const string ApplicationDisplayMode = nameof(ApplicationDisplayMode); public const string ApplicationTextSize = nameof(ApplicationTextSize); - public const string defaultRenderSetting = nameof(defaultRenderSetting); - public const string ThumbnailRenderingMode = nameof(ThumbnailRenderingMode); - public const string CredentialsInvalid = nameof(CredentialsInvalid); - public const string CredentialsInvalidReason = nameof(CredentialsInvalidReason); - public const string TerminalFilterOutput = nameof(TerminalFilterOutput); - public const string TerminalAutoUppercase = nameof(TerminalAutoUppercase); - public const string SliceSettingsTabPinned = nameof(SliceSettingsTabPinned); - public const string SliceSettingsTabIndex = nameof(SliceSettingsTabIndex); - public const string SliceSettingsWidth = nameof(SliceSettingsWidth); - public const string SliceSettingsWidget_CurrentTab = nameof(SliceSettingsWidget_CurrentTab); - public const string OpenScadPath = nameof(OpenScadPath); - public const string LibraryViewWidth = nameof(LibraryViewWidth); - public const string SelectedObjectPanelWidth = nameof(SelectedObjectPanelWidth); + public const string ColorPanelExpanded = nameof(ColorPanelExpanded); public const string ConfigurePrinter_CurrentTab = nameof(ConfigurePrinter_CurrentTab); public const string ConfigurePrinterTabVisible = nameof(ConfigurePrinterTabVisible); - public const string MirrorPanelExpanded = nameof(MirrorPanelExpanded); - public const string MaterialsPanelExpanded = nameof(MaterialsPanelExpanded); - public const string ColorPanelExpanded = nameof(ColorPanelExpanded); - public const string ScalePanelExpanded = nameof(ScalePanelExpanded); + public const string CredentialsInvalid = nameof(CredentialsInvalid); + public const string CredentialsInvalidReason = nameof(CredentialsInvalidReason); + public const string defaultRenderSetting = nameof(defaultRenderSetting); + public const string DisplayedTip_LoadFilament = nameof(DisplayedTip_LoadFilament); public const string EditorPanelExpanded = nameof(EditorPanelExpanded); + public const string GCodeLineColorStyle = nameof(GCodeLineColorStyle); + public const string GcodeModelView = nameof(GcodeModelView); + public const string GcodeViewerHideExtruderOffsets = nameof(GcodeViewerHideExtruderOffsets); + public const string GcodeViewerRenderGrid = nameof(GcodeViewerRenderGrid); + public const string GcodeViewerRenderMoves = nameof(GcodeViewerRenderMoves); + public const string GcodeViewerRenderRetractions = nameof(GcodeViewerRenderRetractions); + public const string GcodeViewerSimulateExtrusion = nameof(GcodeViewerSimulateExtrusion); + public const string GcodeViewerTransparentExtrusion = nameof(GcodeViewerTransparentExtrusion); + public const string Language = nameof(Language); + public const string LayerViewDefault = nameof(LayerViewDefault); + public const string LayerViewSyncToPrint = nameof(LayerViewSyncToPrint); + public const string LibraryViewWidth = nameof(LibraryViewWidth); + public const string MaterialsPanelExpanded = nameof(MaterialsPanelExpanded); + public const string MirrorPanelExpanded = nameof(MirrorPanelExpanded); + public const string NotificationEmailAddress = nameof(NotificationEmailAddress); + public const string NotificationPhoneNumber = nameof(NotificationPhoneNumber); + public const string OpenScadPath = nameof(OpenScadPath); + public const string PrintHistoryFilterShowCompleted = nameof(PrintHistoryFilterShowCompleted); + public const string PrintNotificationsEnabled = nameof(PrintNotificationsEnabled); + public const string PrintNotificationsIncludeImage = nameof(PrintNotificationsIncludeImage); + public const string PublicProfilesSha = nameof(PublicProfilesSha); + public const string ScalePanelExpanded = nameof(ScalePanelExpanded); + public const string SelectedObjectPanelWidth = nameof(SelectedObjectPanelWidth); + public const string ShowContainers = nameof(ShowContainers); + public const string SliceSettingsTabIndex = nameof(SliceSettingsTabIndex); + public const string SliceSettingsTabPinned = nameof(SliceSettingsTabPinned); + public const string SliceSettingsWidget_CurrentTab = nameof(SliceSettingsWidget_CurrentTab); + public const string SliceSettingsWidth = nameof(SliceSettingsWidth); + public const string SoftwareLicenseAccepted = nameof(SoftwareLicenseAccepted); + public const string TerminalAutoUppercase = nameof(TerminalAutoUppercase); + public const string TerminalFilterOutput = nameof(TerminalFilterOutput); + public const string ThumbnailRenderingMode = nameof(ThumbnailRenderingMode); + public const string UpdateFeedType = nameof(UpdateFeedType); } public class UserSettings diff --git a/SetupWizard/LicenseAgreementPage.cs b/SetupWizard/LicenseAgreementPage.cs index 710ffdeb7..4ed882764 100644 --- a/SetupWizard/LicenseAgreementPage.cs +++ b/SetupWizard/LicenseAgreementPage.cs @@ -57,7 +57,7 @@ public class LicenseAgreementPage : DialogPage var acceptButton = theme.CreateDialogButton("Accept".Localize()); acceptButton.Click += (s, e) => { - UserSettings.Instance.set("SoftwareLicenseAccepted", "true"); + UserSettings.Instance.set(UserSettingsKey.SoftwareLicenseAccepted, "true"); UiThread.RunOnIdle(WizardWindow.Close); }; diff --git a/SetupWizard/UserTipManager.cs b/SetupWizard/UserTipManager.cs new file mode 100644 index 000000000..8737e888d --- /dev/null +++ b/SetupWizard/UserTipManager.cs @@ -0,0 +1,83 @@ +/* +Copyright (c) 2017, Lars Brubaker, John Lewin +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. +*/ + +using System; +using System.Linq; +using MatterHackers.Agg.UI; + +namespace MatterHackers.MatterControl.SetupWizard +{ + public class UserTipManager + { + private GuiWidget widgetToExplain; + private static UserTipManager _instance; + public static UserTipManager Instance + { + get + { + if (_instance == null) + { + _instance = new UserTipManager(); + } + return _instance; + } + } + + private UserTipManager() + { + + } + + public void ShowTip(SystemWindow systemWindow, string widgetName, string extruder0TipMessage) + { + widgetToExplain = systemWindow.Descendants().Where((w) => w.Name == widgetName).FirstOrDefault(); +#if DEBUG + if(widgetToExplain == null) + { + throw new Exception("Can't find the named widget"); + } +#endif + if (widgetToExplain != null) + { + widgetToExplain.AfterDraw -= DoShowTip; + } + // hook the widget draw and wait for it to draw so that we know it is visible + widgetToExplain.AfterDraw += DoShowTip; + widgetToExplain.Invalidate(); + } + + private void DoShowTip(object sender, DrawEventArgs e) + { + if (widgetToExplain != null) + { + widgetToExplain.AfterDraw -= DoShowTip; + } + } + } +} \ No newline at end of file diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index cbdb78f11..d64762410 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit cbdb78f11e8074123cbf99c45ff1f858fa05b4e2 +Subproject commit d647624107c7e005c145c64e72842632333fddf9 From 93993d8ea5f63a177c8132f50f8479d8b400a0b3 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 18 Apr 2018 14:47:37 -0700 Subject: [PATCH 2/4] renaming to HelpSystem --- ApplicationView/ApplicationController.cs | 2 +- .../{UserTipManager.cs => HelpSystemManager.cs} | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) rename SetupWizard/{UserTipManager.cs => HelpSystemManager.cs} (92%) diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index 1a9f33c52..c9d0b2d3d 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -959,7 +959,7 @@ namespace MatterHackers.MatterControl + "\t• " + "Select Material".Localize() + "\n" + "\t• " + "Set Temperature".Localize() + "\n" + "\t• " + "Load and Unload Filament".Localize() + "\n"; - UserTipManager.Instance.ShowTip(AppContext.RootSystemWindow, widgetName, extruder0TipMessage); + HelpSystemManager.Instance.ShowTip(AppContext.RootSystemWindow, widgetName, extruder0TipMessage); } return false; diff --git a/SetupWizard/UserTipManager.cs b/SetupWizard/HelpSystemManager.cs similarity index 92% rename from SetupWizard/UserTipManager.cs rename to SetupWizard/HelpSystemManager.cs index 8737e888d..10a1694b3 100644 --- a/SetupWizard/UserTipManager.cs +++ b/SetupWizard/HelpSystemManager.cs @@ -33,23 +33,23 @@ using MatterHackers.Agg.UI; namespace MatterHackers.MatterControl.SetupWizard { - public class UserTipManager + public class HelpSystemManager { private GuiWidget widgetToExplain; - private static UserTipManager _instance; - public static UserTipManager Instance + private static HelpSystemManager _instance; + public static HelpSystemManager Instance { get { if (_instance == null) { - _instance = new UserTipManager(); + _instance = new HelpSystemManager(); } return _instance; } } - private UserTipManager() + private HelpSystemManager() { } From b661b41baf0ffc27ed74587fb87a78cc222e5043 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 18 Apr 2018 17:04:37 -0700 Subject: [PATCH 3/4] Working on new help system --- ApplicationView/ApplicationController.cs | 8 +- MatterControl.csproj | 2 +- PartPreviewWindow/PlusTab/ExplorePanel.cs | 4 + PartPreviewWindow/PlusTab/ExplorerBar.cs | 2 +- SetupWizard/HelpSystemManager.cs | 134 +++++++++++++++++++--- Submodules/agg-sharp | 2 +- 6 files changed, 127 insertions(+), 25 deletions(-) diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index c9d0b2d3d..f738badde 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -955,10 +955,10 @@ namespace MatterHackers.MatterControl var widgetName = "Hotend 0"; string extruder0TipMessage = "Extruder Controls can be fonud here.".Localize() + "\n" - + "They include".Localize() + ":\n" - + "\t• " + "Select Material".Localize() + "\n" - + "\t• " + "Set Temperature".Localize() + "\n" - + "\t• " + "Load and Unload Filament".Localize() + "\n"; + + " • " + "Select Material".Localize() + "\n" + + " • " + "Set Temperature".Localize() + "\n" + + " • " + "Move Print Head".Localize() + "\n" + + " • " + "Load and Unload Filament".Localize() + "\n"; HelpSystemManager.Instance.ShowTip(AppContext.RootSystemWindow, widgetName, extruder0TipMessage); } diff --git a/MatterControl.csproj b/MatterControl.csproj index c31736649..bc4fc3c74 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -74,7 +74,6 @@ - @@ -230,6 +229,7 @@ + diff --git a/PartPreviewWindow/PlusTab/ExplorePanel.cs b/PartPreviewWindow/PlusTab/ExplorePanel.cs index 07f1da827..3dc081c01 100644 --- a/PartPreviewWindow/PlusTab/ExplorePanel.cs +++ b/PartPreviewWindow/PlusTab/ExplorePanel.cs @@ -77,6 +77,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab // TODO: implement panel for case of having no printer selected //var explorerBar = new ExplorerBar("testing", theme); //topToBottom.AddChild(explorerBar); + + // for now just show + topToBottom.AddChild( + new PrinterBar(partPreviewContent, lastProfile, theme)); } topToBottom.AddChild(new PartsBar(partPreviewContent, theme) diff --git a/PartPreviewWindow/PlusTab/ExplorerBar.cs b/PartPreviewWindow/PlusTab/ExplorerBar.cs index 025252061..5c9ce0595 100644 --- a/PartPreviewWindow/PlusTab/ExplorerBar.cs +++ b/PartPreviewWindow/PlusTab/ExplorerBar.cs @@ -79,7 +79,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab private PrinterInfo printerInfo; public PrinterBar(PartPreviewContent partPreviewContent, PrinterInfo printerInfo, ThemeConfig theme) - : base(printerInfo.Name, theme) + : base(printerInfo?.Name ?? "", theme) { headingBar.CloseAllChildren(); headingBar.AddChild(new PrinterSelector(theme) diff --git a/SetupWizard/HelpSystemManager.cs b/SetupWizard/HelpSystemManager.cs index 10a1694b3..ccd0555ba 100644 --- a/SetupWizard/HelpSystemManager.cs +++ b/SetupWizard/HelpSystemManager.cs @@ -27,16 +27,116 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ +using MatterHackers.Agg; +using MatterHackers.Agg.Font; +using MatterHackers.Agg.Transform; +using MatterHackers.Agg.UI; +using MatterHackers.Agg.VertexSource; using System; using System.Linq; -using MatterHackers.Agg.UI; namespace MatterHackers.MatterControl.SetupWizard { + public class HelpOverlay : GuiWidget + { + private double animationRatio = 0; + private bool DoneAnimating => animationRatio >= 1; + private GuiWidget target; + private string message; + Animation showAnimation; + + public HelpOverlay(GuiWidget target, string message) + { + this.target = target; + this.message = message; + HAnchor = HAnchor.Stretch; + VAnchor = VAnchor.Stretch; + + showAnimation = new Animation() + { + DrawTarget = this, + }; + + showAnimation.Update += (s, timePassed) => + { + animationRatio += timePassed; + if(animationRatio >= 1) + { + showAnimation?.Stop(); + showAnimation = null; + } + }; + } + + public override void OnClick(MouseEventArgs mouseEvent) + { + if (DoneAnimating) + { + CloseOnIdle(); + } + base.OnClick(mouseEvent); + } + + public override void OnDraw(Graphics2D graphics2D) + { + if(showAnimation != null + && !showAnimation.IsRunning) + { + showAnimation.Start(); + } + + var backgroundColor = new Color(Color.Black, 100); + + BackgroundColor = Color.Transparent; + + var childBounds = target.TransformToParentSpace(this, target.LocalBounds); + + VertexStorage dimRegion = new VertexStorage(); + dimRegion.MoveTo(LocalBounds.Left, LocalBounds.Bottom); + dimRegion.LineTo(LocalBounds.Right, LocalBounds.Bottom); + dimRegion.LineTo(LocalBounds.Right, LocalBounds.Top); + dimRegion.LineTo(LocalBounds.Left, LocalBounds.Top); + + var ratio = Easing.Quadratic.InOut(Math.Min(animationRatio, 1)); + + double closingLeft = LocalBounds.Left + (childBounds.Left - LocalBounds.Left) * ratio; + double closingRight = LocalBounds.Right - (LocalBounds.Right - childBounds.Right) * ratio; + double closingBottom = LocalBounds.Bottom + (childBounds.Bottom - LocalBounds.Bottom) * ratio; + double closingTop = LocalBounds.Top - (LocalBounds.Top - childBounds.Top) * ratio; + + dimRegion.MoveTo(closingRight, closingBottom); + dimRegion.LineTo(closingLeft, closingBottom); + dimRegion.LineTo(closingLeft, closingTop); + dimRegion.LineTo(closingRight, closingTop); + + graphics2D.Render(dimRegion, backgroundColor); + + BorderDouble margin = new BorderDouble(5); + + if (ratio >= 1) + { + TypeFacePrinter stringPrinter = new TypeFacePrinter(message); + var textBounds = stringPrinter.GetBounds(); + + var translated = new VertexSourceApplyTransform(stringPrinter, + Affine.NewTranslation(childBounds.Right - textBounds.Width - margin.Right, + childBounds.Bottom - stringPrinter.TypeFaceStyle.AscentInPixels - margin.Top));// - textBounds.Height)); + + graphics2D.Render(translated, Color.White); + } + + base.OnDraw(graphics2D); + } + } + public class HelpSystemManager { - private GuiWidget widgetToExplain; + private SystemWindow SystemWindow { get; set; } + + private string message; + private GuiWidget target; private static HelpSystemManager _instance; + public static HelpSystemManager Instance { get @@ -51,32 +151,30 @@ namespace MatterHackers.MatterControl.SetupWizard private HelpSystemManager() { - } - public void ShowTip(SystemWindow systemWindow, string widgetName, string extruder0TipMessage) + public void ShowTip(SystemWindow systemWindow, string widgetName, string message) { - widgetToExplain = systemWindow.Descendants().Where((w) => w.Name == widgetName).FirstOrDefault(); -#if DEBUG - if(widgetToExplain == null) + this.SystemWindow = systemWindow; + this.message = message; + target = systemWindow.Descendants().Where((w) => w.Name == widgetName).FirstOrDefault(); + + if (target != null) { - throw new Exception("Can't find the named widget"); - } -#endif - if (widgetToExplain != null) - { - widgetToExplain.AfterDraw -= DoShowTip; + target.AfterDraw -= DoShowTip; } // hook the widget draw and wait for it to draw so that we know it is visible - widgetToExplain.AfterDraw += DoShowTip; - widgetToExplain.Invalidate(); + target.AfterDraw += DoShowTip; + target.Invalidate(); } - private void DoShowTip(object sender, DrawEventArgs e) + private void DoShowTip(object sender, DrawEventArgs drawEvent) { - if (widgetToExplain != null) + if (target != null) { - widgetToExplain.AfterDraw -= DoShowTip; + target.AfterDraw -= DoShowTip; + + SystemWindow.AddChild(new HelpOverlay(target, message)); } } } diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index d64762410..bdb4067b7 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit d647624107c7e005c145c64e72842632333fddf9 +Subproject commit bdb4067b74ef36485810fa641049ae5007bae4fc From 9d7f7654ad422d65401078a8780c87189a3b1047 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 18 Apr 2018 17:06:59 -0700 Subject: [PATCH 4/4] Making help only show once. --- ApplicationView/ApplicationController.cs | 4 ++++ Submodules/agg-sharp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index f738badde..9bc127e8f 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -960,6 +960,10 @@ namespace MatterHackers.MatterControl + " • " + "Move Print Head".Localize() + "\n" + " • " + "Load and Unload Filament".Localize() + "\n"; HelpSystemManager.Instance.ShowTip(AppContext.RootSystemWindow, widgetName, extruder0TipMessage); + + UserSettings.Instance.set(UserSettingsKey.DisplayedTip_LoadFilament, "1"); + + return true; } return false; diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index bdb4067b7..cdbb27b3f 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit bdb4067b74ef36485810fa641049ae5007bae4fc +Subproject commit cdbb27b3f5335acae7fc143fa9f0019113bf929b