From 2f15a548e566d60b039fc482727e6f9db50f1e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesus=20Alfredo=20Alvi=C3=B1o?= Date: Thu, 24 Aug 2023 13:36:02 -0500 Subject: [PATCH 1/7] Make sure close the Toast notification when Dynamo closes --- src/DynamoCoreWpf/.npmrc | 1 + .../UI/GuidedTour/GuidesManager.cs | 31 ++++++++++++------- .../ViewModels/Menu/PreferencesViewModel.cs | 6 ++++ src/Notifications/.npmrc | 1 + 4 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 src/DynamoCoreWpf/.npmrc create mode 100644 src/Notifications/.npmrc diff --git a/src/DynamoCoreWpf/.npmrc b/src/DynamoCoreWpf/.npmrc new file mode 100644 index 00000000000..0453efcd428 --- /dev/null +++ b/src/DynamoCoreWpf/.npmrc @@ -0,0 +1 @@ +registry=https://registry.npmjs.org \ No newline at end of file diff --git a/src/DynamoCoreWpf/UI/GuidedTour/GuidesManager.cs b/src/DynamoCoreWpf/UI/GuidedTour/GuidesManager.cs index a36536a62f6..cd20b115d5a 100644 --- a/src/DynamoCoreWpf/UI/GuidedTour/GuidesManager.cs +++ b/src/DynamoCoreWpf/UI/GuidedTour/GuidesManager.cs @@ -9,6 +9,7 @@ using System.Windows.Controls.Primitives; using Dynamo.Controls; using Dynamo.Logging; +using Dynamo.Utilities; using Dynamo.ViewModels; using Dynamo.Wpf.Properties; using Dynamo.Wpf.ViewModels.GuidedTour; @@ -120,7 +121,7 @@ internal void Initialize() guideBackgroundElement.ClearCutOffSection(); guideBackgroundElement.ClearHighlightSection(); stopwatch = Stopwatch.StartNew(); - } + } /// /// Creates the background for the GuidedTour @@ -244,10 +245,10 @@ internal void ExitTour() { Logging.Analytics.TrackEvent(Logging.Actions.Completed, Logging.Categories.GuidedTourOperations, guidName, currentGuide.CurrentStep.Sequence); } - else + else { Logging.Analytics.TrackEvent(Logging.Actions.End, Logging.Categories.GuidedTourOperations, guidName, currentGuide.CurrentStep.Sequence); - } + } Logging.Analytics.TrackTimedEvent(Logging.Categories.GuidedTourOperations, Logging.Actions.TimeElapsed.ToString(), stopwatch.Elapsed, guidName); currentGuide.ClearGuide(); @@ -338,7 +339,7 @@ private void CreateGuideSteps(string jsonFile) totalTooltips = (from step in guide.GuideSteps where step.StepType == Step.StepTypes.TOOLTIP || step.StepType == Step.StepTypes.SURVEY - select step).GroupBy(x=>x.Sequence).Count(); + select step).GroupBy(x => x.Sequence).Count(); foreach (Step step in guide.GuideSteps) { @@ -464,7 +465,7 @@ private Step CreateStep(Step jsonStepInfo, HostControlInfo hostControlInfo, int } }; var popupWindow = newStep.stepUIPopup as PopupWindow; - if(popupWindow != null && hostControlInfo.HtmlPage != null && !string.IsNullOrEmpty(hostControlInfo.HtmlPage.FileName)) + if (popupWindow != null && hostControlInfo.HtmlPage != null && !string.IsNullOrEmpty(hostControlInfo.HtmlPage.FileName)) { popupWindow.WebBrowserUserDataFolder = userDataFolder != null ? userDataFolder.FullName : string.Empty; } @@ -525,11 +526,11 @@ internal Guide GetNextGuide() private void Popup_StepClosed(string name, Step.StepTypes stepType) - { + { GuideFlowEvents.OnGuidedTourFinish(currentGuide.Name); //The exit tour popup will be shown only when a popup (doesn't apply for survey) is closed or when the tour is closed. - if(stepType != Step.StepTypes.SURVEY) + if (stepType != Step.StepTypes.SURVEY) CreateRealTimeInfoWindow(Res.ExitTourWindowContent); } @@ -546,10 +547,7 @@ internal void CreateRealTimeInfoWindow(string content, bool stayOpen = false) UIElement hostUIElement = GuideUtilities.FindChild(mainRootElement, "statusBarPanel"); // When popup already exist, replace it - if ( exitTourPopup != null && exitTourPopup.IsOpen) - { - exitTourPopup.IsOpen = false; - } + CloseRealTimeInfoWindow(); // Otherwise creates the RealTimeInfoWindow popup and set up all the needed values // to show the popup over the Dynamo workspace exitTourPopup = new RealTimeInfoWindow() @@ -565,5 +563,16 @@ internal void CreateRealTimeInfoWindow(string content, bool stayOpen = false) exitTourPopup.PlacementTarget = hostUIElement; exitTourPopup.IsOpen = true; } + + /// + /// Closes the exitTourPopup if exist and it's open + /// + internal void CloseRealTimeInfoWindow() + { + if (exitTourPopup != null && exitTourPopup.IsOpen) + { + exitTourPopup.IsOpen = false; + } + } } } diff --git a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs index 82717f84a59..6c5f98e0416 100644 --- a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs @@ -1341,6 +1341,7 @@ public PreferencesViewModel(DynamoViewModel dynamoViewModel) this.preferenceSettings.PropertyChanged += PreferenceSettings_PropertyChanged; this.pythonScriptEditorTextOptions = dynamoViewModel.PythonScriptEditorTextOptions; this.dynamoViewModel = dynamoViewModel; + this.dynamoViewModel.Model.ShutdownStarted += Model_ShutdownStarted; if (dynamoViewModel.PackageManagerClientViewModel != null) { @@ -1428,6 +1429,11 @@ public PreferencesViewModel(DynamoViewModel dynamoViewModel) InitializeCommands(); } + private void Model_ShutdownStarted(DynamoModel model) + { + dynamoViewModel.MainGuideManager?.CloseRealTimeInfoWindow(); + } + private void PreferenceSettings_PropertyChanged(object sender, PropertyChangedEventArgs e) { var property = e.PropertyName; diff --git a/src/Notifications/.npmrc b/src/Notifications/.npmrc new file mode 100644 index 00000000000..0453efcd428 --- /dev/null +++ b/src/Notifications/.npmrc @@ -0,0 +1 @@ +registry=https://registry.npmjs.org \ No newline at end of file From e87e55b30cec364de29a241849ea7fa88f2ca299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesus=20Alfredo=20Alvi=C3=B1o?= Date: Thu, 24 Aug 2023 14:13:23 -0500 Subject: [PATCH 2/7] Removing extra file --- src/Notifications/.npmrc | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/Notifications/.npmrc diff --git a/src/Notifications/.npmrc b/src/Notifications/.npmrc deleted file mode 100644 index 0453efcd428..00000000000 --- a/src/Notifications/.npmrc +++ /dev/null @@ -1 +0,0 @@ -registry=https://registry.npmjs.org \ No newline at end of file From 7c6fbf53e797aa4163a15241fb29f11de2362580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesus=20Alfredo=20Alvi=C3=B1o?= Date: Thu, 24 Aug 2023 14:15:34 -0500 Subject: [PATCH 3/7] Removing extra file --- src/DynamoCoreWpf/.npmrc | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/DynamoCoreWpf/.npmrc diff --git a/src/DynamoCoreWpf/.npmrc b/src/DynamoCoreWpf/.npmrc deleted file mode 100644 index 0453efcd428..00000000000 --- a/src/DynamoCoreWpf/.npmrc +++ /dev/null @@ -1 +0,0 @@ -registry=https://registry.npmjs.org \ No newline at end of file From 717f6f733d529e50ca73446a84e4e3a746228f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesus=20Alfredo=20Alvi=C3=B1o?= Date: Thu, 24 Aug 2023 15:36:11 -0500 Subject: [PATCH 4/7] Relocate the responsibility about the toast notification to the DynamoViewModel --- src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs | 7 +++++++ src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs index f22d4d8e7fd..a0739c0a699 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs @@ -769,6 +769,12 @@ protected DynamoViewModel(StartConfiguration startConfiguration) } FileTrustViewModel = new FileTrustWarningViewModel(); + model.ShutdownStarted += Model_ShutdownStarted; + } + + private void Model_ShutdownStarted(DynamoModel model) + { + MainGuideManager?.CloseRealTimeInfoWindow(); } /// @@ -870,6 +876,7 @@ protected virtual void UnsubscribeAllEvents() DynamoSelection.Instance.Selection.CollectionChanged -= SelectionOnCollectionChanged; UsageReportingManager.Instance.PropertyChanged -= CollectInfoManager_PropertyChanged; + model.ShutdownStarted -= Model_ShutdownStarted; } private void InitializeRecentFiles() diff --git a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs index 6c5f98e0416..82717f84a59 100644 --- a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs @@ -1341,7 +1341,6 @@ public PreferencesViewModel(DynamoViewModel dynamoViewModel) this.preferenceSettings.PropertyChanged += PreferenceSettings_PropertyChanged; this.pythonScriptEditorTextOptions = dynamoViewModel.PythonScriptEditorTextOptions; this.dynamoViewModel = dynamoViewModel; - this.dynamoViewModel.Model.ShutdownStarted += Model_ShutdownStarted; if (dynamoViewModel.PackageManagerClientViewModel != null) { @@ -1429,11 +1428,6 @@ public PreferencesViewModel(DynamoViewModel dynamoViewModel) InitializeCommands(); } - private void Model_ShutdownStarted(DynamoModel model) - { - dynamoViewModel.MainGuideManager?.CloseRealTimeInfoWindow(); - } - private void PreferenceSettings_PropertyChanged(object sender, PropertyChangedEventArgs e) { var property = e.PropertyName; From 9058b061e1b87db381df48a98e6837abb067e63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesus=20Alfredo=20Alvi=C3=B1o?= Date: Fri, 25 Aug 2023 11:22:58 -0500 Subject: [PATCH 5/7] removing unnecessary using --- src/DynamoCoreWpf/UI/GuidedTour/GuidesManager.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/DynamoCoreWpf/UI/GuidedTour/GuidesManager.cs b/src/DynamoCoreWpf/UI/GuidedTour/GuidesManager.cs index cd20b115d5a..9b1ec946162 100644 --- a/src/DynamoCoreWpf/UI/GuidedTour/GuidesManager.cs +++ b/src/DynamoCoreWpf/UI/GuidedTour/GuidesManager.cs @@ -9,7 +9,6 @@ using System.Windows.Controls.Primitives; using Dynamo.Controls; using Dynamo.Logging; -using Dynamo.Utilities; using Dynamo.ViewModels; using Dynamo.Wpf.Properties; using Dynamo.Wpf.ViewModels.GuidedTour; From 7bbcc17ab9cc52c9c132e1a55ed332f496ba4610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesus=20Alfredo=20Alvi=C3=B1o?= Date: Fri, 25 Aug 2023 11:39:01 -0500 Subject: [PATCH 6/7] take advantage of already implementation to apply minimal changes --- src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs index a0739c0a699..679afba3832 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs @@ -769,12 +769,6 @@ protected DynamoViewModel(StartConfiguration startConfiguration) } FileTrustViewModel = new FileTrustWarningViewModel(); - model.ShutdownStarted += Model_ShutdownStarted; - } - - private void Model_ShutdownStarted(DynamoModel model) - { - MainGuideManager?.CloseRealTimeInfoWindow(); } /// @@ -876,7 +870,6 @@ protected virtual void UnsubscribeAllEvents() DynamoSelection.Instance.Selection.CollectionChanged -= SelectionOnCollectionChanged; UsageReportingManager.Instance.PropertyChanged -= CollectInfoManager_PropertyChanged; - model.ShutdownStarted -= Model_ShutdownStarted; } private void InitializeRecentFiles() @@ -3426,6 +3419,7 @@ public bool PerformShutdownSequence(ShutdownParams shutdownParams) WatchHandler.RequestSelectGeometry -= BackgroundPreviewViewModel.AddLabelForPath; model.ComputeModelDeserialized -= model_ComputeModelDeserialized; model.RequestNotification -= model_RequestNotification; + MainGuideManager?.CloseRealTimeInfoWindow(); return true; } From 64252512c01519d4a5719151b5bafe49b5de5457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesus=20Alfredo=20Alvi=C3=B1o?= Date: Fri, 25 Aug 2023 12:08:21 -0500 Subject: [PATCH 7/7] Moving the code to a proper place --- src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs index 679afba3832..d412584d59a 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs @@ -3405,6 +3405,7 @@ public bool PerformShutdownSequence(ShutdownParams shutdownParams) BackgroundPreviewViewModel.Dispose(); + MainGuideManager?.CloseRealTimeInfoWindow(); model.ShutDown(shutdownParams.ShutdownHost); if (shutdownParams.ShutdownHost) @@ -3418,8 +3419,7 @@ public bool PerformShutdownSequence(ShutdownParams shutdownParams) BackgroundPreviewViewModel.PropertyChanged -= Watch3DViewModelPropertyChanged; WatchHandler.RequestSelectGeometry -= BackgroundPreviewViewModel.AddLabelForPath; model.ComputeModelDeserialized -= model_ComputeModelDeserialized; - model.RequestNotification -= model_RequestNotification; - MainGuideManager?.CloseRealTimeInfoWindow(); + model.RequestNotification -= model_RequestNotification; return true; }