From 041d1900373ab0c7696c905a194d6d91170d9f23 Mon Sep 17 00:00:00 2001 From: Ivo Petrov <48355182+ivaylo-matov@users.noreply.github.com> Date: Fri, 25 Oct 2024 20:58:35 +0100 Subject: [PATCH] Bug fixes - group naming & table visibility (#72) * bugs fixed - retain group prefix when nodes move between state groups. - hide table labels when collections are empty. * xml summary --- TuneUp/ProfiledNodeViewModel.cs | 22 ++++++++++++++++++---- TuneUp/TuneUpWindowViewModel.cs | 23 +++++++++++++++-------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/TuneUp/ProfiledNodeViewModel.cs b/TuneUp/ProfiledNodeViewModel.cs index b1d035c..c8bcc10 100644 --- a/TuneUp/ProfiledNodeViewModel.cs +++ b/TuneUp/ProfiledNodeViewModel.cs @@ -100,13 +100,16 @@ public string Name } else if (GroupModel != null) { - return GroupModel.AnnotationText == DefaultGroupName ? - $"{GroupNodePrefix}{DefaultDisplayGroupName}" : GroupModel.AnnotationText; + return GetProfiledGroupName(GroupModel.AnnotationText); } } return name; } - internal set { name = value; } + internal set + { + name = value; + RaisePropertyChanged(nameof(Name)); + } } /// @@ -421,7 +424,7 @@ public ProfiledNodeViewModel(AnnotationModel group) /// the annotation model public ProfiledNodeViewModel(ProfiledNodeViewModel pNode) { - Name = pNode.GroupName == DefaultGroupName ? DefaultDisplayGroupName : pNode.GroupName; + Name = GetProfiledGroupName(pNode.GroupName); GroupName = pNode.GroupName; State = pNode.State; NodeGUID = Guid.NewGuid(); @@ -430,5 +433,16 @@ public ProfiledNodeViewModel(ProfiledNodeViewModel pNode) BackgroundBrush = pNode.BackgroundBrush; ShowGroupIndicator = true; } + + /// + /// Returns the formatted profiled group name with the group prefix. + /// Uses a default display name if the group name matches the default. + /// + public static string GetProfiledGroupName(string groupName) + { + return groupName == DefaultGroupName + ? $"{GroupNodePrefix}{DefaultDisplayGroupName}" + : $"{GroupNodePrefix}{groupName}"; + } } } diff --git a/TuneUp/TuneUpWindowViewModel.cs b/TuneUp/TuneUpWindowViewModel.cs index ac9579b..a61a769 100644 --- a/TuneUp/TuneUpWindowViewModel.cs +++ b/TuneUp/TuneUpWindowViewModel.cs @@ -362,9 +362,7 @@ internal void ResetProfiledNodes() ApplyGroupNodeFilter(); // Ensure table visibility is updated in case TuneUp was closed and reopened with the same graph. - RaisePropertyChanged(nameof(LatestRunTableVisibility)); - RaisePropertyChanged(nameof(PreviousRunTableVisibility)); - RaisePropertyChanged(nameof(NotExecutedTableVisibility)); + UpdateTableVisibility(); } /// @@ -453,10 +451,7 @@ private void CurrentWorkspaceModel_EvaluationCompleted(object sender, Dynamo.Mod CalculateGroupNodes(); UpdateExecutionTime(); - - RaisePropertyChanged(nameof(LatestRunTableVisibility)); - RaisePropertyChanged(nameof(PreviousRunTableVisibility)); - RaisePropertyChanged(nameof(NotExecutedTableVisibility)); + UpdateTableVisibility(); RaisePropertyChanged(nameof(ProfiledNodesCollectionLatestRun)); RaisePropertyChanged(nameof(ProfiledNodesCollectionPreviousRun)); @@ -701,7 +696,7 @@ internal void OnGroupPropertyChanged(object sender, PropertyChangedEventArgs e) { if (pNode.IsGroup) { - pNode.Name = $"{ProfiledNodeViewModel.GroupNodePrefix}{groupModel.AnnotationText}"; + pNode.Name = ProfiledNodeViewModel.GetProfiledGroupName(groupModel.AnnotationText); } pNode.GroupName = groupModel.AnnotationText; } @@ -889,6 +884,7 @@ private void CurrentWorkspaceModel_NodeRemoved(NodeModel node) //Recalculate the execution times UpdateExecutionTime(); + UpdateTableVisibility(); } private void CurrentWorkspaceModel_GroupAdded(AnnotationModel group) @@ -1003,6 +999,7 @@ private void CurrentWorkspaceModel_GroupRemoved(AnnotationModel group) } RefreshAllCollectionViews(); + UpdateTableVisibility(); } private void OnCurrentWorkspaceChanged(IWorkspaceModel workspace) @@ -1023,6 +1020,16 @@ private void OnCurrentWorkspaceCleared(IWorkspaceModel workspace) #region Helpers + /// + /// Raises property change notifications for the visibility of the Latest Run, Previous Run, and Not Executed tables. + /// + private void UpdateTableVisibility() + { + RaisePropertyChanged(nameof(LatestRunTableVisibility)); + RaisePropertyChanged(nameof(PreviousRunTableVisibility)); + RaisePropertyChanged(nameof(NotExecutedTableVisibility)); + } + /// /// Resets group-related properties of the node and unregisters it from the group model dictionary. ///