From d9a8067831b2ab3c6756fa08c6724a710ebc7aaa Mon Sep 17 00:00:00 2001 From: "Aaron (Qilong)" <173288704@qq.com> Date: Tue, 16 Jan 2024 01:09:00 +0800 Subject: [PATCH 1/9] Re-work watch node display logic (#14841) --- .../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 c3aa107ae35..dedb39408ba 100644 --- a/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs @@ -190,8 +190,11 @@ public bool IsCollection get { return isCollection; } set { - isCollection = value; - RaisePropertyChanged("IsCollection"); + if (isCollection != value) + { + isCollection = value; + RaisePropertyChanged(nameof(IsCollection)); + } } } @@ -203,8 +206,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; } } } From d88a835277fac859e32886a73a715930aea6f976 Mon Sep 17 00:00:00 2001 From: "Aaron (Qilong)" <173288704@qq.com> Date: Fri, 20 Oct 2023 11:15:23 -0400 Subject: [PATCH 2/9] improvements (#14497) --- .../Properties/Resources.Designer.cs | 36 +++++++++---------- .../Properties/Resources.en-US.resx | 6 ++-- src/DynamoCoreWpf/Properties/Resources.resx | 6 ++-- .../Search/NodeAutoCompleteSearchViewModel.cs | 11 +++--- .../Views/Menu/PreferencesView.xaml | 4 +-- 5 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs index 3de5f72a46b..db8e4d9ea0f 100644 --- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs +++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs @@ -3479,24 +3479,6 @@ public static string HideClassicNodeLibrary { } } - /// - /// Looks up a localized string similar to Hide nodes below a specified confidence level. - /// - public static string HideNodesBelowSpecificConfidenceLevel { - get { - return ResourceManager.GetString("HideNodesBelowSpecificConfidenceLevel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Confidence level appears next to each recommended node and represents estimated probability that the node is a good choice. When toggled on, this setting hides recommended nodes that don’t meet the specified confidence level. You can click the Low Confidence header to show the nodes.. - /// - public static string HideNodesBelowSpecificConfidenceLevelInfo { - get { - return ResourceManager.GetString("HideNodesBelowSpecificConfidenceLevelInfo", resourceCulture); - } - } - /// /// Looks up a localized string similar to Hide Wires. /// @@ -7376,6 +7358,24 @@ public static string PreferencesWindowShowPreviewBubblesTooltip { } } + /// + /// Looks up a localized string similar to Preferred confidence level. + /// + public static string PreferredConfidenceLevel { + get { + return ResourceManager.GetString("PreferredConfidenceLevel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Confidence level appears next to each recommended node and represents estimated probability that the node is a good choice. When toggled on, this setting hides recommended nodes that don’t meet the specified confidence level. You can click the Low Confidence header to show the nodes.. + /// + public static string PreferredConfidenceLevelInfo { + get { + return ResourceManager.GetString("PreferredConfidenceLevelInfo", resourceCulture); + } + } + /// /// Looks up a localized string similar to Your package will be scanned for viruses, and will be available for download once it successfully passes the scan.. /// diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index b6fb25f11b9..caac9cd1ebf 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -3342,10 +3342,10 @@ You can manage this in Preferences -> Security. Node Autocomplete Preferences | Features | Node Autocomplete - - Hide nodes below a specified confidence level + + Preferred confidence level - + Confidence level appears next to each recommended node and represents estimated probability that the node is a good choice. When toggled on, this setting hides recommended nodes that don’t meet the specified confidence level. You can click the Low Confidence header to show the nodes. diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index b7e469db40e..e094990be3f 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -3329,10 +3329,10 @@ You can manage this in Preferences -> Security. Node Autocomplete Preferences | Features | Node Autocomplete - - Hide nodes below a specified confidence level + + Preferred confidence level - + Confidence level appears next to each recommended node and represents estimated probability that the node is a good choice. When toggled on, this setting hides recommended nodes that don’t meet the specified confidence level. You can click the Low Confidence header to show the nodes. diff --git a/src/DynamoCoreWpf/ViewModels/Search/NodeAutoCompleteSearchViewModel.cs b/src/DynamoCoreWpf/ViewModels/Search/NodeAutoCompleteSearchViewModel.cs index 704fd6482f9..87cf2e7a23a 100644 --- a/src/DynamoCoreWpf/ViewModels/Search/NodeAutoCompleteSearchViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Search/NodeAutoCompleteSearchViewModel.cs @@ -156,12 +156,13 @@ internal NodeAutoCompleteSearchViewModel(DynamoViewModel dynamoViewModel) : base internal void ResetAutoCompleteSearchViewState() { DisplayAutocompleteMLStaticPage = false; - DisplayLowConfidence = false; + DisplayLowConfidence = PreferenceSettings.Instance.HideNodesBelowSpecificConfidenceLevel; AutocompleteMLMessage = string.Empty; AutocompleteMLTitle = string.Empty; FilteredResults = new List(); FilteredHighConfidenceResults = new List(); FilteredLowConfidenceResults = new List(); + searchElementsCache = new List(); } private void InitializeDefaultAutoCompleteCandidates() @@ -409,10 +410,10 @@ internal void DisplayMachineLearningResults() } } - // Show low confidence section if there are some results under threshold. - DisplayLowConfidence = FilteredLowConfidenceResults.Count() > 0; + // Show low confidence section if there are some results under threshold and feature enabled + DisplayLowConfidence = FilteredLowConfidenceResults.Any() && PreferenceSettings.Instance.HideNodesBelowSpecificConfidenceLevel; - if (FilteredHighConfidenceResults.Count() == 0) + if (!FilteredHighConfidenceResults.Any()) { DisplayAutocompleteMLStaticPage = true; AutocompleteMLTitle = Resources.AutocompleteLowConfidenceTitle; @@ -421,7 +422,7 @@ internal void DisplayMachineLearningResults() } // By default, show only the results which are above the threshold - FilteredResults = FilteredHighConfidenceResults; + FilteredResults = PreferenceSettings.Instance.HideNodesBelowSpecificConfidenceLevel? FilteredHighConfidenceResults : results ; } } diff --git a/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml b/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml index c818e800487..6a8779fe1c2 100644 --- a/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml +++ b/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml @@ -956,7 +956,7 @@ IsChecked="{Binding Path=HideNodesBelowSpecificConfidenceLevelIsChecked}" Style="{StaticResource EllipseToggleButton1}" IsEnabled="{Binding Path=EnableHideNodesToggle}"/> -