From b0eb47a713f333e6c2cda9d777d6cc746702ad1f Mon Sep 17 00:00:00 2001 From: Ashish Aggarwal Date: Mon, 15 Jan 2024 12:16:49 -0500 Subject: [PATCH] Dynamo SignIn UI toolbar fixes and tooltip updates (#14842) * Fix PostDiff job * fixes 1 and 2 * DYN-5868 fix-3 --- .../Controls/ShortcutToolbar.xaml | 2 +- .../Controls/ShortcutToolbar.xaml.cs | 32 ++++++++++++++++--- .../Properties/Resources.Designer.cs | 20 +++++++++++- .../Properties/Resources.en-US.resx | 10 ++++-- src/DynamoCoreWpf/Properties/Resources.resx | 10 ++++-- .../UI/Prompts/DynamoMessageBox.xaml.cs | 21 ++++++++++++ .../Utilities/MessageBoxUtilities.cs | 10 ++++++ 7 files changed, 94 insertions(+), 11 deletions(-) diff --git a/src/DynamoCoreWpf/Controls/ShortcutToolbar.xaml b/src/DynamoCoreWpf/Controls/ShortcutToolbar.xaml index 5cb110c3de7..46a4439fc81 100644 --- a/src/DynamoCoreWpf/Controls/ShortcutToolbar.xaml +++ b/src/DynamoCoreWpf/Controls/ShortcutToolbar.xaml @@ -216,7 +216,7 @@ diff --git a/src/DynamoCoreWpf/Controls/ShortcutToolbar.xaml.cs b/src/DynamoCoreWpf/Controls/ShortcutToolbar.xaml.cs index 043d9f46b03..425d91741e3 100644 --- a/src/DynamoCoreWpf/Controls/ShortcutToolbar.xaml.cs +++ b/src/DynamoCoreWpf/Controls/ShortcutToolbar.xaml.cs @@ -56,12 +56,17 @@ public ShortcutToolbar(DynamoViewModel dynamoViewModel) var shortcutToolbar = new ShortcutToolbarViewModel(dynamoViewModel); DataContext = shortcutToolbar; authManager = dynamoViewModel.Model.AuthenticationManager; - if (authManager.IsLoggedInInitial()) + if (authManager != null) { authManager.LoginStateChanged += AuthChangeHandler; - } - else { - logoutOption.Visibility = Visibility.Collapsed; + if (authManager.LoginState == LoginState.LoggedIn) + { + loginMenu.Items.Add(logoutOption); + } + else + { + loginMenu.Items.Remove(logoutOption); + } } this.Loaded += ShortcutToolbar_Loaded; @@ -90,12 +95,17 @@ private void AuthChangeHandler(LoginState status) LoginButton.ToolTip = Wpf.Properties.Resources.SignInButtonContentToolTip; txtSignIn.Text = Wpf.Properties.Resources.SignInButtonText; logoutOption.Visibility = Visibility.Collapsed; + loginMenu.Items.Remove(logoutOption); } else if (status == LoginState.LoggedIn) { txtSignIn.Text = authManager.Username; - logoutOption.Visibility = Visibility.Visible; LoginButton.ToolTip = null; + if (loginMenu.Items.Count == 0) + { + loginMenu.Items.Add(logoutOption); + } + logoutOption.Visibility = Visibility.Visible; } } @@ -134,6 +144,18 @@ private void LoginButton_OnClick(object sender, RoutedEventArgs e) } } + private void LogoutOption_Click(object sender, RoutedEventArgs e) + { + if (authManager.LoginState == LoginState.LoggedIn) + { + var result = Wpf.Utilities.MessageBoxService.Show(Application.Current?.MainWindow, Wpf.Properties.Resources.SignOutConfirmationDialogText, Wpf.Properties.Resources.SignOutConfirmationDialogTitle,MessageBoxButton.OKCancel, new List() { "Sign Out", "Cancel"}, MessageBoxImage.Information); + if (result == MessageBoxResult.OK) + { + authManager.ToggleLoginState(null); + } + } + } + public List AllChildren(DependencyObject parent) { var _list = new List { }; diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs index 92d403962bb..69d90d507e1 100644 --- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs +++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs @@ -7674,7 +7674,7 @@ public static string PreferencesViewShowPreviewBubbles { } /// - /// Looks up a localized string similar to Switchable only when the current workspace is in Manual run mode.. + /// Looks up a localized string similar to To preview the execution state of your graph, wires connected to ports that will be affected by a graph run are highlighted in orange. Available only when the current workspace is in Manual run mode.. /// public static string PreferencesViewShowRunPreviewTooltip { get { @@ -9183,6 +9183,24 @@ public static string SigningInButtonText { } } + /// + /// Looks up a localized string similar to Signing out of Dynamo will sign you out of all Autodesk desktop products.. + /// + public static string SignOutConfirmationDialogText { + get { + return ResourceManager.GetString("SignOutConfirmationDialogText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sign out of Dynamo. + /// + public static string SignOutConfirmationDialogTitle { + get { + return ResourceManager.GetString("SignOutConfirmationDialogTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Please update the permissions or go to Preferences >Node and Package Paths...' to change your default directory.. /// diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index 9bee7a4e45d..eca56492e8e 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -2589,7 +2589,7 @@ Do you wish to uninstall {1}? Restart {2} to complete the uninstall and try down Package/Library Search Paths - Switchable only when the current workspace is in Manual run mode. + To preview the execution state of your graph, wires connected to ports that will be affected by a graph run are highlighted in orange. Available only when the current workspace is in Manual run mode. Issues found @@ -3879,4 +3879,10 @@ In certain complex graphs or host program scenarios, Automatic mode may cause in Millimeters - + + Signing out of Dynamo will sign you out of all Autodesk desktop products. + + + Sign out of Dynamo + + \ No newline at end of file diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index c5619f66142..a3df5d76d3e 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -2877,7 +2877,7 @@ Do you wish to uninstall {1}? Restart {2} to complete the uninstall and try down Package/Library Search Paths - Switchable only when the current workspace is in Manual run mode. + To preview the execution state of your graph, wires connected to ports that will be affected by a graph run are highlighted in orange. Available only when the current workspace is in Manual run mode. Issues found @@ -3866,4 +3866,10 @@ In certain complex graphs or host program scenarios, Automatic mode may cause in Millimeters - + + Signing out of Dynamo will sign you out of all Autodesk desktop products. + + + Sign out of Dynamo + + \ No newline at end of file diff --git a/src/DynamoCoreWpf/UI/Prompts/DynamoMessageBox.xaml.cs b/src/DynamoCoreWpf/UI/Prompts/DynamoMessageBox.xaml.cs index 6767be18120..c2d4617ae5e 100644 --- a/src/DynamoCoreWpf/UI/Prompts/DynamoMessageBox.xaml.cs +++ b/src/DynamoCoreWpf/UI/Prompts/DynamoMessageBox.xaml.cs @@ -272,6 +272,27 @@ internal static MessageBoxResult Show(string messageBoxText, string caption, Mes return dynamoMessageBox.CustomDialogResult; } + internal static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, IEnumerable buttonNames, + MessageBoxImage icon) + { + var dynamoMessageBox = new DynamoMessageBox + { + BodyText = messageBoxText, + TitleText = caption, + MessageBoxButton = button, + MessageBoxImage = icon + }; + + if (owner != null && owner.IsLoaded) + { + dynamoMessageBox.Owner = owner; + } + + dynamoMessageBox.ConfigureButtons(button, buttonNames); + dynamoMessageBox.ShowDialog(); + return dynamoMessageBox.CustomDialogResult; + } + public event PropertyChangedEventHandler PropertyChanged; /// diff --git a/src/DynamoCoreWpf/Utilities/MessageBoxUtilities.cs b/src/DynamoCoreWpf/Utilities/MessageBoxUtilities.cs index a77304c0516..a96ebdb83aa 100644 --- a/src/DynamoCoreWpf/Utilities/MessageBoxUtilities.cs +++ b/src/DynamoCoreWpf/Utilities/MessageBoxUtilities.cs @@ -12,6 +12,7 @@ internal interface IMessageBox MessageBoxResult Show(string msg, string title, MessageBoxButton button, MessageBoxImage img); MessageBoxResult Show(string msg, string title, bool showRichTextBox, MessageBoxButton button, MessageBoxImage img); MessageBoxResult Show(Window owner,string msg, string title, MessageBoxButton button, MessageBoxImage img); + MessageBoxResult Show(Window owner, string msg, string title, MessageBoxButton button, IEnumerable buttonNames, MessageBoxImage img); MessageBoxResult Show(string msg, string title, MessageBoxButton button, IEnumerable buttonNames, MessageBoxImage img); } @@ -38,6 +39,11 @@ MessageBoxResult IMessageBox.Show(string msg, string title, MessageBoxButton but { return DynamoMessageBox.Show(msg, title, button,buttonNames, img); } + + MessageBoxResult IMessageBox.Show(Window owner, string msg, string title, MessageBoxButton button, IEnumerable buttonNames, MessageBoxImage img) + { + return DynamoMessageBox.Show(owner, msg, title, button, buttonNames, img); + } } private static IMessageBox msg_box; @@ -57,6 +63,10 @@ public static MessageBoxResult Show(Window owner,string msg, string title, Messa { return (msg_box ?? (msg_box = new DefaultMessageBox())).Show(owner,msg, title, button, img); } + public static MessageBoxResult Show(Window owner, string msg, string title, MessageBoxButton button, IEnumerable buttonNames, MessageBoxImage img) + { + return (msg_box ?? (msg_box = new DefaultMessageBox())).Show(owner, msg, title, button, buttonNames, img); + } public static MessageBoxResult Show(string msg, string title, MessageBoxButton button, IEnumerable buttonNames, MessageBoxImage img) { return (msg_box ?? (msg_box = new DefaultMessageBox())).Show(msg, title, button, buttonNames, img);