From cb8159a26e056c98f7aec09a613f9501d84b0b88 Mon Sep 17 00:00:00 2001 From: Roberto T <61755417+RobertGlobant20@users.noreply.github.com> Date: Fri, 3 Jan 2025 11:48:40 -0800 Subject: [PATCH] DYN-6897 Dynamo Button Disabled Revit (#15722) --- .../Views/SplashScreen/SplashScreen.xaml.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/DynamoCoreWpf/Views/SplashScreen/SplashScreen.xaml.cs b/src/DynamoCoreWpf/Views/SplashScreen/SplashScreen.xaml.cs index 8691f9789ae..a77a4d5ad49 100644 --- a/src/DynamoCoreWpf/Views/SplashScreen/SplashScreen.xaml.cs +++ b/src/DynamoCoreWpf/Views/SplashScreen/SplashScreen.xaml.cs @@ -41,6 +41,10 @@ public partial class SplashScreen : Window // Used to ensure that OnClosing is called only once. private bool IsClosing = false; + internal enum CloseMode { ByStartingDynamo, ByCloseButton, ByOther }; + + internal CloseMode currentCloseMode = CloseMode.ByOther; + // Timer used for Splash Screen loading internal Stopwatch loadingTimer; @@ -162,6 +166,7 @@ public SplashScreen(bool enableSignInButton = true) RequestSignIn = SignIn; RequestSignOut = SignOut; this.enableSignInButton = enableSignInButton; + currentCloseMode = CloseMode.ByOther; } protected override void OnClosing(CancelEventArgs e) @@ -172,6 +177,11 @@ protected override void OnClosing(CancelEventArgs e) // webview2.Dispose => webview2.Visible.Set receives windows message => crash because object got disposed. if (!IsClosing) { + //Means that the SplashScreen was closed by other way for example by using the Windows Task Bar + if(currentCloseMode == CloseMode.ByOther) + { + CloseWasExplicit = true; + } // First call to OnClosing IsClosing = true; } @@ -283,6 +293,7 @@ private void LaunchDynamo(bool isCheckboxChecked) { viewModel.PreferenceSettings.EnableStaticSplashScreen = !isCheckboxChecked; } + currentCloseMode = CloseMode.ByStartingDynamo; Close(); dynamoView?.Show(); dynamoView?.Activate(); @@ -574,6 +585,8 @@ private static bool IsValidPreferencesFile(string filePath) internal void CloseWindow(bool isCheckboxChecked = false) { CloseWasExplicit = true; + currentCloseMode = CloseMode.ByCloseButton; + if (viewModel != null && isCheckboxChecked) { viewModel.PreferenceSettings.EnableStaticSplashScreen = !isCheckboxChecked;