From 647bff1184a59521738f62a580559817e01831ff Mon Sep 17 00:00:00 2001 From: "Aaron (Qilong)" Date: Fri, 12 Jan 2024 12:46:00 -0500 Subject: [PATCH] Re-work watch node display logic --- .../ViewModels/Preview/WatchViewModel.cs | 14 ++++-- .../Views/Preview/WatchTree.xaml | 49 ++++++++++++------- .../Views/Preview/WatchTree.xaml.cs | 14 ++++-- 3 files changed, 50 insertions(+), 27 deletions(-) diff --git a/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs b/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs index a345fb9728c..733859f8db7 100644 --- a/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs @@ -186,8 +186,11 @@ public bool IsCollection get { return isCollection; } set { - isCollection = value; - RaisePropertyChanged("IsCollection"); + if (isCollection != value) + { + isCollection = value; + RaisePropertyChanged(nameof(IsCollection)); + } } } @@ -199,8 +202,11 @@ public IEnumerable Levels get { return levels; } set { - levels = value; - RaisePropertyChanged("Levels"); + if (levels != value) + { + levels = value; + RaisePropertyChanged(nameof(Levels)); + } } } diff --git a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml index 339ef8fec52..3e2a15b9904 100644 --- a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml +++ b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml @@ -389,24 +389,17 @@ BorderBrush="#D3D3D3" CornerRadius="0,0,2,2" BorderThickness="0"> - - - - - - - - - - - + + + + + + + + - + + + + + + + + + + + diff --git a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs index d92655f9190..3b7ebe12b60 100644 --- a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs +++ b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs @@ -4,6 +4,7 @@ using Dynamo.ViewModels; using System; using CoreNodeModels; +using System.Linq; namespace Dynamo.Controls { @@ -68,7 +69,7 @@ private void _vm_PropertyChanged(object sender, System.ComponentModel.PropertyCh if (e.PropertyName == nameof(WatchViewModel.IsCollection)) { - // // The WatchTree controll will resize only if its role is a WatchNode (starts with an specific height), otherwise it won't resize (Bubble role). + // The WatchTree controll will resize only if its role is a WatchNode (starts with an specific height), otherwise it won't resize (Bubble role). if (!Double.IsNaN(this.Height)) { if (_vm.IsCollection) @@ -100,10 +101,13 @@ private void _vm_PropertyChanged(object sender, System.ComponentModel.PropertyCh { if (!_vm.Children[0].IsCollection) { - // We will use 7.5 as width factor for each character. + // if multiline string + if (NodeLabel.Contains(Environment.NewLine) || NodeLabel.Contains("\n")) + this.Height = defaultHeightSize; - double requiredWidth = (NodeLabel.Length * widthPerCharacter); - if (requiredWidth > (MaxWidthSize)) + // We will use 7.5 as width factor for each character. + double requiredWidth = NodeLabel.Length * widthPerCharacter; + if (requiredWidth > MaxWidthSize) { requiredWidth = MaxWidthSize; } @@ -123,6 +127,8 @@ private void _vm_PropertyChanged(object sender, System.ComponentModel.PropertyCh // Forcing not to display the Levels content when is being used for display info from another node like the Color Range this.ListLevelsDisplay.Visibility = Visibility.Hidden; this.ListLevelsDisplay.Height = 0; + // Hide resize grip + resizeThumb.Visibility = Visibility.Collapsed; } } }