From 2cc91916ee3de70f431ceeaee66fd5326b79d0a4 Mon Sep 17 00:00:00 2001 From: jesusalvino Date: Mon, 25 Apr 2022 20:35:38 -0500 Subject: [PATCH 1/4] Watch Node height size behavior --- .../Views/Preview/WatchTree.xaml.cs | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs index c83b934baea..da23dd90368 100644 --- a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs +++ b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs @@ -14,8 +14,10 @@ public partial class WatchTree : UserControl { private WatchViewModel _vm; private WatchViewModel prevWatchViewModel; - private readonly int defaultSize = 200; - private readonly int minSize = 100; + private readonly int defaultWidthSize = 200; + private readonly int defaultHeightSize = 200; + private readonly int minWidthSize = 100; + private readonly int minHeightSize = 60; public WatchTree() { @@ -26,15 +28,31 @@ public WatchTree() void WatchTree_Loaded(object sender, RoutedEventArgs e) { _vm = this.DataContext as WatchViewModel; + _vm.PropertyChanged += _vm_PropertyChanged; + } + + private void _vm_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + if (e.PropertyName == "IsCollection") + { + if (_vm.IsCollection) + { + this.Height = defaultHeightSize; + } + else + { + this.Height = minHeightSize; + } + } } internal void SetWatchNodeProperties() { resizeThumb.Visibility = Visibility.Visible; - this.Width = defaultSize; - this.Height = defaultSize; - inputGrid.MinHeight = minSize; - inputGrid.MinWidth = minSize; + this.Width = defaultWidthSize; + this.Height = minHeightSize; + inputGrid.MinHeight = minHeightSize; + inputGrid.MinWidth = minWidthSize; } private void Button_Click(object sender, RoutedEventArgs e) From 0ecb5302adcd87fd4cceced62b46f5412e7fa22f Mon Sep 17 00:00:00 2001 From: jesusalvino Date: Thu, 28 Apr 2022 15:56:01 -0500 Subject: [PATCH 2/4] Dealing with the Width and reducing the Height as minimum --- src/DynamoCoreWpf/Views/Preview/WatchTree.xaml | 6 +++--- src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml index a85cf2f95ba..b11fc312dfd 100644 --- a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml +++ b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml @@ -311,7 +311,7 @@ - + @@ -377,7 +377,7 @@ CornerRadius="0,0,2,2" BorderThickness="0"> - + - L + diff --git a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs index da23dd90368..f70c87bdf01 100644 --- a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs +++ b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs @@ -17,7 +17,7 @@ public partial class WatchTree : UserControl private readonly int defaultWidthSize = 200; private readonly int defaultHeightSize = 200; private readonly int minWidthSize = 100; - private readonly int minHeightSize = 60; + private readonly int minHeightSize = 38; public WatchTree() { @@ -28,7 +28,7 @@ public WatchTree() void WatchTree_Loaded(object sender, RoutedEventArgs e) { _vm = this.DataContext as WatchViewModel; - _vm.PropertyChanged += _vm_PropertyChanged; + _vm.PropertyChanged += _vm_PropertyChanged; } private void _vm_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) @@ -44,6 +44,17 @@ private void _vm_PropertyChanged(object sender, System.ComponentModel.PropertyCh this.Height = minHeightSize; } } + else if (e.PropertyName == "Children") + { + if (!_vm.IsCollection) + { + if (_vm.Children != null) + { + double requiredWidth = _vm.Children[0].NodeLabel.Length * System.Convert.ToDouble(8.5); + this.Width = requiredWidth < defaultWidthSize ? defaultWidthSize : requiredWidth; + } + } + } } internal void SetWatchNodeProperties() From e42657637bcba0c05de2590292d2f6f9375e024e Mon Sep 17 00:00:00 2001 From: jesusalvino Date: Fri, 29 Apr 2022 20:22:56 -0500 Subject: [PATCH 3/4] Dynamic Width --- .../Views/Preview/WatchTree.xaml | 3 +++ .../Views/Preview/WatchTree.xaml.cs | 22 ++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml index b11fc312dfd..988d78a1ecb 100644 --- a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml +++ b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml @@ -313,6 +313,9 @@ + + + diff --git a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs index f70c87bdf01..baa63b1a1e4 100644 --- a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs +++ b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs @@ -23,6 +23,12 @@ public WatchTree() { InitializeComponent(); this.Loaded += WatchTree_Loaded; + this.Unloaded += WatchTree_Unloaded; + } + + private void WatchTree_Unloaded(object sender, RoutedEventArgs e) + { + _vm.PropertyChanged -= _vm_PropertyChanged; } void WatchTree_Loaded(object sender, RoutedEventArgs e) @@ -46,14 +52,18 @@ private void _vm_PropertyChanged(object sender, System.ComponentModel.PropertyCh } else if (e.PropertyName == "Children") { - if (!_vm.IsCollection) + if (_vm.Children != null) { - if (_vm.Children != null) + if (!_vm.Children[0].IsCollection) + { + double requiredWidth = (_vm.Children[0].NodeLabel.Length * 7.5) + 20; + this.Width = requiredWidth; + } + else { - double requiredWidth = _vm.Children[0].NodeLabel.Length * System.Convert.ToDouble(8.5); - this.Width = requiredWidth < defaultWidthSize ? defaultWidthSize : requiredWidth; - } - } + this.Width = defaultWidthSize; + } + } } } From 507b2364a6362fc6071d4152caf18fe4bfe42e34 Mon Sep 17 00:00:00 2001 From: jesusalvino Date: Mon, 2 May 2022 10:12:52 -0500 Subject: [PATCH 4/4] Max width of a Watch node --- src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs index baa63b1a1e4..35ba95f3d1f 100644 --- a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs +++ b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs @@ -55,15 +55,20 @@ private void _vm_PropertyChanged(object sender, System.ComponentModel.PropertyCh if (_vm.Children != null) { if (!_vm.Children[0].IsCollection) - { - double requiredWidth = (_vm.Children[0].NodeLabel.Length * 7.5) + 20; + { + double requiredWidth = (_vm.Children[0].NodeLabel.Length * 7.5); + if (requiredWidth > (defaultWidthSize * 2)) + { + requiredWidth = defaultWidthSize * 2; + } + requiredWidth += 20; this.Width = requiredWidth; } else { this.Width = defaultWidthSize; } - } + } } }