From 8c8e9e06ecf9927fd90eee1078d2e037e5eda29a Mon Sep 17 00:00:00 2001 From: Roberto T Date: Tue, 20 Feb 2024 09:28:53 -0600 Subject: [PATCH 1/6] DYN-6440 Custom Selection node overlapping When choosing a large string text from the ComboBox was overlapping other controls at left side so for fixing this bug I've set the MaxWidth property and also I've added a tooltip showing the text (this will be useful when we have a large string). --- .../NodeViewCustomizations/CustomSelection.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs b/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs index fe100434466..5d653bffb3c 100644 --- a/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs +++ b/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs @@ -19,6 +19,7 @@ public class CustomSelectionNodeViewCustomization : DropDownNodeViewCustomizatio /// public void CustomizeView(CustomSelection model, NodeView nodeView) { + const double leftMargin = 40; var formControl = new CustomSelectionControl(new CustomSelectionViewModel(model)); nodeView.inputGrid.Children.Add(formControl); @@ -27,12 +28,23 @@ public void CustomizeView(CustomSelection model, NodeView nodeView) base.CustomizeView(model, nodeView); var dropdown = (ComboBox)nodeView.inputGrid.Children[1]; + dropdown.MaxWidth = formControl.Width - leftMargin; formControl.BaseComboBox = dropdown; + formControl.BaseComboBox.SelectionChanged += BaseComboBox_SelectionChanged; // Add margin to the dropdown to show the expander. - dropdown.Margin = new Thickness(40, 0, 0, 0); + dropdown.Margin = new Thickness(leftMargin, 0, 0, 0); dropdown.VerticalAlignment = VerticalAlignment.Top; } + + private void BaseComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + var comboSender = sender as ComboBox; + if (comboSender != null) + { + comboSender.ToolTip = comboSender.SelectedItem?.ToString(); + } + } } -} \ No newline at end of file +} From cd055bf4b07814abcbd834bd1f1166c62b6debfe Mon Sep 17 00:00:00 2001 From: Roberto T Date: Tue, 20 Feb 2024 17:48:12 -0600 Subject: [PATCH 2/6] DYN-6440 Custom Selection node overlapping Adding a new TextBlock that when has a large text will wrap the text show at the end the chars: "..." --- .../UI/Themes/Modern/DynamoModern.xaml | 11 +++++++++ .../NodeViewCustomizations/CustomSelection.cs | 23 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml b/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml index c3cc6e2c43e..81af096fd8c 100644 --- a/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml +++ b/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml @@ -1981,6 +1981,17 @@ Foreground="#F5F5F5" IsReadOnly="{TemplateBinding IsReadOnly}" Visibility="Hidden" /> + Date: Wed, 21 Feb 2024 12:33:33 -0600 Subject: [PATCH 3/6] DYN-6440 Custom Selection node overlapping Fixing TextBlock Style --- src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml b/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml index 81af096fd8c..423187884b9 100644 --- a/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml +++ b/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml @@ -1982,13 +1982,10 @@ IsReadOnly="{TemplateBinding IsReadOnly}" Visibility="Hidden" /> From 9721ab013e792b85d05b012b2523e46bfda36c47 Mon Sep 17 00:00:00 2001 From: Roberto T Date: Fri, 23 Feb 2024 12:11:56 -0600 Subject: [PATCH 4/6] DYN-6440 Custom Selection node overlapping Code Review Adding property in the Model so we can control the TextBlock Visibility. --- .../UI/Themes/Modern/DynamoModern.xaml | 2 +- .../CoreNodeModels/Input/CustomSelection.cs | 17 +++++++++++++++++ .../NodeViewCustomizations/CustomSelection.cs | 3 ++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml b/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml index 423187884b9..abf88c0e770 100644 --- a/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml +++ b/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml @@ -1988,7 +1988,7 @@ Focusable="True" TextWrapping="Wrap" TextTrimming="CharacterEllipsis" - Visibility="Collapsed" /> + Visibility="{Binding IsVisibleDropDownTextBlock, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}" /> serializedItems; + private bool isVisibleDropDownTextBlock = false; + + /// + /// This property will Collapse or make Visible the TextBlock for the ComboBox template "RefreshComboBox" (by default will be Collapsed) + /// + public bool IsVisibleDropDownTextBlock + { + get + { + return isVisibleDropDownTextBlock; + } + set + { + isVisibleDropDownTextBlock = value; + RaisePropertyChanged(nameof(IsVisibleDropDownTextBlock)); + } + } /// /// Copy of to be serialized./> diff --git a/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs b/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs index bb20e9f95ae..8cef1282f0c 100644 --- a/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs +++ b/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs @@ -6,6 +6,7 @@ using Dynamo.Wpf; using CoreNodeModels; using System.Windows.Data; +using System.Runtime.InteropServices; namespace CoreNodeModelsWpf.Nodes { @@ -43,7 +44,7 @@ public void CustomizeView(CustomSelection model, NodeView nodeView) var dropDownTextBlock = dropdown.Template.FindName("PART_ReadOnlyTextBlock", dropdown) as TextBlock; if (dropDownTextBlock != null) { - dropDownTextBlock.Visibility = Visibility.Visible; + model.IsVisibleDropDownTextBlock = true; } var dropDownContent = dropdown.Template.FindName("ContentSite", dropdown) as ContentPresenter; From 3b3b57c2b3a53f9574324660735c1d8e4fb15d78 Mon Sep 17 00:00:00 2001 From: Roberto T Date: Fri, 23 Feb 2024 12:13:37 -0600 Subject: [PATCH 5/6] DYN-6440 Custom Selection node overlapping Code Review Removed unused using --- .../CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs b/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs index 8cef1282f0c..7177fbcf7a2 100644 --- a/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs +++ b/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs @@ -6,7 +6,6 @@ using Dynamo.Wpf; using CoreNodeModels; using System.Windows.Data; -using System.Runtime.InteropServices; namespace CoreNodeModelsWpf.Nodes { From c08ab0e2f61b5605c254fd987dc8d385272623ea Mon Sep 17 00:00:00 2001 From: Roberto T Date: Fri, 23 Feb 2024 15:39:47 -0600 Subject: [PATCH 6/6] DYN-6440 Custom Selection node overlapping Code Review Added more comments for clarifying the use of the IsVisibleDropDownTextBlock property. Also I've added the Dispose() method for unsubscribing event handlers (although I'm not so sure if we are disposing this class correctly). --- .../NodeViewCustomizations/CustomSelection.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs b/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs index 7177fbcf7a2..27e61e99b7a 100644 --- a/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs +++ b/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs @@ -6,6 +6,8 @@ using Dynamo.Wpf; using CoreNodeModels; using System.Windows.Data; +using System.Data.Common; +using System; namespace CoreNodeModelsWpf.Nodes { @@ -14,6 +16,7 @@ namespace CoreNodeModelsWpf.Nodes /// public class CustomSelectionNodeViewCustomization : DropDownNodeViewCustomization, INodeViewCustomization { + private CustomSelectionControl formControl; /// /// Customize the visual appearance of the custom dropdown node. /// @@ -22,7 +25,7 @@ public class CustomSelectionNodeViewCustomization : DropDownNodeViewCustomizatio public void CustomizeView(CustomSelection model, NodeView nodeView) { const double leftMargin = 40; - var formControl = new CustomSelectionControl(new CustomSelectionViewModel(model)); + formControl = new CustomSelectionControl(new CustomSelectionViewModel(model)); nodeView.inputGrid.Children.Add(formControl); @@ -43,6 +46,8 @@ public void CustomizeView(CustomSelection model, NodeView nodeView) var dropDownTextBlock = dropdown.Template.FindName("PART_ReadOnlyTextBlock", dropdown) as TextBlock; if (dropDownTextBlock != null) { + //IsVisibleDropDownTextBlock will be false by default so the TextBlock (located in the ComboBox template) will be Collapsed then just when is a Custom Selection node we set the value to true and the TextBlock will be visible + //We used a TextBlock because the normal TextBox doesn't have the TextTrimming property and the requirement was asking for setting TextTrimming="CharacterEllipsis" model.IsVisibleDropDownTextBlock = true; } @@ -69,5 +74,19 @@ private void BaseComboBox_SelectionChanged(object sender, SelectionChangedEventA comboSender.ToolTip = comboSender.SelectedItem?.ToString(); } } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected void Dispose(bool disposing) + { + if (disposing) + { + formControl.BaseComboBox.SelectionChanged -= BaseComboBox_SelectionChanged; + } + } } }