From 01f310491930c8aaecf6e6221f2347962f098b2f Mon Sep 17 00:00:00 2001 From: Deyan Nenov Date: Tue, 14 Mar 2023 19:15:46 +0000 Subject: [PATCH] Edit Python Port Properties (#13788) * Outport - added Edit Port Properties button to port context menu - added a new button to the OutPortContextMenu to allow users to Edit Port Properties - for the time being, it is only enabled and visible in case of Python Node Model (in future this check can be removed allowing other nodes to use this functionality as well) * Output rename working - At this point, output port can be renamed - TODO: handle contextmenu - should close after interaction, now keeps alive - TODO: remove Categories - TODO: create validation checks (cannot be the same as any other Port, cannot be null, cannot be an Integer, anything else?) - TODO: Set Prompt name based on Inport/Outport usage * Hide popup after interaction - since we no longer need the popup to stick around after we have launched the Edit Properties Prompt, hide the popup * Resource properties added - added Port Properties Prompt property values as resources - added a dynamic prompt title based on the PortType value of the port - further cleaned the UI design * WindowsStartupLocation - Screen - cannot find DynamoView as an owner for some reason, using WindowStartupLocation.CenterScreen instead - control cleanup * Code refactor, name validation - refactor chunks of code for better usability - incorporated number and unique port name validation checks * Added Port Properties Prompt to context menu of Input port - now works for both Input and Output ports * Added port removal notification message - will prompt the user to agree to lose changes when removing port * Validation changed to status label - changed the validation warning method to status label underneath the Name text box * Save disabled on warning - disable 'Save' button when we are in a warning state (invalid port name) - cleans up interaction around blank name * Public converter comment - added comment to public converter * Moved private property - moved private property to top of class for better readability * Used DynamoUtilities method - used DynamoUtilities.PathHelper method to check for name validation * Removed commented out code - removed unnecessary code * Added back the missing page tag - fixed page tag --- .../Controls/DynamoNodeButton.cs | 33 ++- .../Controls/InPortContextMenu.xaml | 19 +- .../Controls/OutPortContextMenu.xaml | 12 +- .../Controls/OutPortContextMenu.xaml.cs | 4 +- src/DynamoCoreWpf/DynamoCoreWpf.csproj | 3 + .../Properties/Resources.Designer.cs | 90 ++++++ .../Properties/Resources.en-US.resx | 36 +++ src/DynamoCoreWpf/Properties/Resources.resx | 36 +++ src/DynamoCoreWpf/UI/Converters.cs | 25 ++ .../UI/Prompts/PortPropertiesEditPrompt.xaml | 276 ++++++++++++++++++ .../Prompts/PortPropertiesEditPrompt.xaml.cs | 221 ++++++++++++++ .../UI/Themes/Modern/DynamoConverters.xaml | 1 + src/DynamoCoreWpf/UI/Themes/Modern/Ports.xaml | 13 +- .../ViewModels/Core/InPortViewModel.cs | 70 ++++- .../ViewModels/Core/OutPortViewModel.cs | 81 ++++- .../ViewModels/Core/PortViewModel.cs | 4 +- .../Views/Core/WorkspaceView.xaml.cs | 6 + 17 files changed, 918 insertions(+), 12 deletions(-) create mode 100644 src/DynamoCoreWpf/UI/Prompts/PortPropertiesEditPrompt.xaml create mode 100644 src/DynamoCoreWpf/UI/Prompts/PortPropertiesEditPrompt.xaml.cs diff --git a/src/DynamoCoreWpf/Controls/DynamoNodeButton.cs b/src/DynamoCoreWpf/Controls/DynamoNodeButton.cs index a0e0f49c675..3b2b4dc6fc5 100644 --- a/src/DynamoCoreWpf/Controls/DynamoNodeButton.cs +++ b/src/DynamoCoreWpf/Controls/DynamoNodeButton.cs @@ -7,6 +7,7 @@ using Dynamo.UI; using Dynamo.Utilities; using Dynamo.ViewModels; +using Dynamo.Wpf.Utilities; namespace Dynamo.Nodes { @@ -28,6 +29,17 @@ private DynamoViewModel DynamoViewModel } } + private Window Owner + { + get + { + var f = WpfUtilities.FindUpVisualTree(this); + if (f != null) return f; + + return null; + } + } + public DynamoNodeButton() { } @@ -49,9 +61,28 @@ private void OnDynamoNodeButtonClick(object sender, RoutedEventArgs e) // if (null != this.model && (!string.IsNullOrEmpty(this.eventName))) { + MessageBoxResult result = MessageBoxResult.None; + + if (eventName.Equals("RemoveInPort")) + { + result = MessageBoxService.Show + ( + Owner, + Dynamo.Wpf.Properties.Resources.MessageRemovePythonPort, + Dynamo.Wpf.Properties.Resources.RemovePythonPortWarningMessageBoxTitle, + MessageBoxButton.OKCancel, + MessageBoxImage.Information + ); + } + + if (result == MessageBoxResult.Cancel) + { + return; + } + var command = new DynamoModel.ModelEventCommand(model.GUID, eventName); this.DynamoViewModel.ExecuteCommand(command); } } } -} \ No newline at end of file +} diff --git a/src/DynamoCoreWpf/Controls/InPortContextMenu.xaml b/src/DynamoCoreWpf/Controls/InPortContextMenu.xaml index bac80c11faf..155c90a7f67 100644 --- a/src/DynamoCoreWpf/Controls/InPortContextMenu.xaml +++ b/src/DynamoCoreWpf/Controls/InPortContextMenu.xaml @@ -1,4 +1,4 @@ - + IsChecked="{Binding Path=UseLevels, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" + Visibility="{Binding IsPythonNodePort, Converter={StaticResource InverseBoolToVisibilityCollapsedConverter}}" /> + IsEnabled="{Binding ElementName=UseLevel, Path=IsChecked}" + Visibility="{Binding IsPythonNodePort, Converter={StaticResource InverseBoolToVisibilityCollapsedConverter}}" /> + + +