From 9797db1bb16fdff4dc66186a7e121a8035704243 Mon Sep 17 00:00:00 2001 From: Deyan Nenov Date: Wed, 17 Apr 2024 15:39:44 +0100 Subject: [PATCH] node lock on interaction - in case the node is in 'auto' mode, when user interacts with it, lock it - this is to prevent misunderstanding of what 'auto' mode does --- .../Properties/Resources.en-US.resx | 3 ++- src/DynamoCoreWpf/Properties/Resources.resx | 1 - src/Libraries/CoreNodeModels/DefineData.cs | 3 +++ .../NodeViewCustomizations/DefineData.cs | 25 ++++++++++++++++--- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index ef80976e0a5..10fad733a0a 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -3969,6 +3969,7 @@ To make this file into a new template, save it to a different folder, then move Toggle on if the input data contains a list. Tool-tip for info questionmark icon. + The package or one of its dependencies use an older version of {0} than you are currently using. Do you want to continue? @@ -3977,5 +3978,5 @@ To make this file into a new template, save it to a different folder, then move #Learn more=https://primer2.dynamobim.org/1_developer_primer_intro/3_developing_for_dynamo/updating-your-packages-and-dynamo-libraries-for-dynamo-3x-net8 - + diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index 67483704f8e..216425a9476 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -3957,7 +3957,6 @@ To make this file into a new template, save it to a different folder, then move Toggle on if the input data contains a list. Tool-tip for info questionmark icon. - This package or one of its dependencies were created for a previous version of Dynamo. It may not work in this version. Do you want to continue? diff --git a/src/Libraries/CoreNodeModels/DefineData.cs b/src/Libraries/CoreNodeModels/DefineData.cs index 4909259f5b7..93ee79d60b0 100644 --- a/src/Libraries/CoreNodeModels/DefineData.cs +++ b/src/Libraries/CoreNodeModels/DefineData.cs @@ -69,6 +69,9 @@ public bool IsList set { isList = value; + + if (IsAutoMode) { IsAutoMode = false; } // Lock the node on user interaction + OnNodeModified(); RaisePropertyChanged(nameof(IsList)); } diff --git a/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/DefineData.cs b/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/DefineData.cs index 0f99ccef3e9..1ab7ac2efc8 100644 --- a/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/DefineData.cs +++ b/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/DefineData.cs @@ -19,10 +19,13 @@ namespace CoreNodeModelsWpf.Nodes /// public class DefineDataNodeViewCustomization : DropDownNodeViewCustomization, INodeViewCustomization { + private ComboBox dropdown; + private ToggleButton toggleButton; + /// /// Customize the visual appearance of the DefineData node. /// - /// + /// The DefineData model to customize /// public void CustomizeView(DefineData model, NodeView nodeView) { @@ -47,7 +50,7 @@ public void CustomizeView(DefineData model, NodeView nodeView) base.CustomizeView(model, nodeView); var style = (Style)Dynamo.UI.SharedDictionaryManager.DynamoModernDictionary["NodeViewComboBox"]; - var dropdown = (ComboBox)nodeView.inputGrid.Children[1]; + dropdown = (ComboBox)nodeView.inputGrid.Children[1]; dropdown.Style = style; formControl.BaseComboBox = dropdown; @@ -58,6 +61,9 @@ public void CustomizeView(DefineData model, NodeView nodeView) dropdown.MinWidth = 220; dropdown.FontSize = 12; + // subscribe to the event inside the NodeModel to detect user interacting with the dropdown + dropdown.DropDownOpened += dropDown_DropDownOpened; + // Create the Grid as the root visual for the item template var gridFactory = new FrameworkElementFactory(typeof(Grid)); var col = new FrameworkElementFactory(typeof(ColumnDefinition)); @@ -131,7 +137,7 @@ public void CustomizeView(DefineData model, NodeView nodeView) // Add the padlock button var toggleButtonStyle = (Style)Dynamo.UI.SharedDictionaryManager.DynamoModernDictionary["PadlockToggleButton"]; var toggleButtonTooltipStyle = (Style)Dynamo.UI.SharedDictionaryManager.DynamoModernDictionary["GenericToolTipLight"]; - var toggleButton = new ToggleButton(); + toggleButton = new ToggleButton(); toggleButton.Style = toggleButtonStyle; Binding isToggleCheckedBinding = new Binding("IsAutoMode"); @@ -156,6 +162,19 @@ public void CustomizeView(DefineData model, NodeView nodeView) nodeView.inputGrid.Children.Add(toggleButton); } + public new void Dispose() + { + if (dropdown != null) dropdown.DropDownOpened -= dropDown_DropDownOpened; + } + + private void dropDown_DropDownOpened(object sender, EventArgs e) + { + if (toggleButton != null && toggleButton.IsChecked == true) + { + toggleButton.IsChecked = false; + } + } + public class LevelToIndentConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture)