diff --git a/TuneUp/ProfiledNodeViewModel.cs b/TuneUp/ProfiledNodeViewModel.cs index d29c192..67f175c 100644 --- a/TuneUp/ProfiledNodeViewModel.cs +++ b/TuneUp/ProfiledNodeViewModel.cs @@ -99,13 +99,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)); + } } /// @@ -420,7 +423,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(); @@ -429,5 +432,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 4fd2944..f0a3a6e 100644 --- a/TuneUp/TuneUpWindowViewModel.cs +++ b/TuneUp/TuneUpWindowViewModel.cs @@ -360,9 +360,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(); } /// @@ -451,10 +449,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)); @@ -699,7 +694,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; } @@ -887,6 +882,7 @@ private void CurrentWorkspaceModel_NodeRemoved(NodeModel node) //Recalculate the execution times UpdateExecutionTime(); + UpdateTableVisibility(); } private void CurrentWorkspaceModel_GroupAdded(AnnotationModel group) @@ -1001,6 +997,7 @@ private void CurrentWorkspaceModel_GroupRemoved(AnnotationModel group) } RefreshAllCollectionViews(); + UpdateTableVisibility(); } private void OnCurrentWorkspaceChanged(IWorkspaceModel workspace) @@ -1021,6 +1018,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. ///