Skip to content

Commit

Permalink
grouping nodes from different states
Browse files Browse the repository at this point in the history
  • Loading branch information
ivaylo-matov committed Oct 10, 2024
1 parent 87c7c4e commit 2fa4a5b
Show file tree
Hide file tree
Showing 3 changed files with 512 additions and 277 deletions.
73 changes: 55 additions & 18 deletions TuneUp/ProfiledNodeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,16 @@ internal set
/// <summary>
/// Indicates whether this node represents the total execution time for its group
/// </summary>
public bool IsGroupExecutionTime => NodeModel == null && GroupModel == null;
public bool IsGroupExecutionTime
{
get => isGroupExecutionTime;
set
{
isGroupExecutionTime = value;
RaisePropertyChanged(nameof(IsGroupExecutionTime));
}
}
private bool isGroupExecutionTime;

/// <summary>
/// Prefix string of execution time.
Expand Down Expand Up @@ -228,6 +237,20 @@ public Guid GroupGUID
}
private Guid groupGIUD;

/// <summary>
/// The GUID of this node
/// </summary>
public Guid NodeGUID
{
get => nodeGIUD;
set
{
nodeGIUD = value;
RaisePropertyChanged(nameof(NodeGUID));
}
}
private Guid nodeGIUD;

/// <summary>
/// The name of the group to which this node belongs
/// This property is also applied to individual nodes and is used when sorting by name
Expand All @@ -246,7 +269,16 @@ public string GroupName
/// <summary>
/// Indicates if this node is a group
/// </summary>
public bool IsGroup => NodeModel == null && GroupModel != null;
public bool IsGroup
{
get => isGroup;
set
{
isGroup = value;
RaisePropertyChanged(nameof(IsGroup));
}
}
private bool isGroup;

public bool ShowGroupIndicator
{
Expand Down Expand Up @@ -341,22 +373,6 @@ private static string GetOriginalName(NodeModel node)
return nodeType.FullName;
}

internal void ResetGroupProperties()
{
GroupGUID = Guid.Empty;
GroupName = string.Empty;
GroupExecutionOrderNumber = null;
GroupExecutionMilliseconds = 0;
}

internal void ApplyGroupProperties(ProfiledNodeViewModel profiledGroup)
{
GroupGUID = profiledGroup.GroupGUID;
GroupName = profiledGroup.GroupName;
GroupExecutionOrderNumber = profiledGroup.GroupExecutionOrderNumber;
BackgroundBrush = profiledGroup.BackgroundBrush;
}

/// <summary>
/// Create a Profiled Node View Model from a NodeModel
/// </summary>
Expand All @@ -366,6 +382,7 @@ public ProfiledNodeViewModel(NodeModel node)
NodeModel = node;
State = ProfiledNodeState.NotExecuted;
Stopwatch = new Stopwatch();
NodeGUID = node.GUID;
}

/// <summary>
Expand All @@ -377,6 +394,8 @@ public ProfiledNodeViewModel(string name, ProfiledNodeState state)
{
this.Name = name;
State = state;
NodeGUID = Guid.NewGuid();
IsGroupExecutionTime = true;
}

/// <summary>
Expand All @@ -391,6 +410,24 @@ public ProfiledNodeViewModel(AnnotationModel group)
BackgroundBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(group.Background));
State = ProfiledNodeState.NotExecuted;
ShowGroupIndicator = true;
NodeGUID = Guid.NewGuid();
IsGroup = true;
}

/// <summary>
/// An alternative constructor to create a group or time node from another profiled node.
/// </summary>
/// <param name="group">the annotation model</param>
public ProfiledNodeViewModel(ProfiledNodeViewModel pNode)
{
Name = pNode.GroupName == DefaultGroupName ? DefaultDisplayGroupName : pNode.GroupName;
GroupName = pNode.GroupName;
State = pNode.State;
NodeGUID = Guid.NewGuid();
GroupGUID = pNode.GroupGUID;
IsGroup = true;
BackgroundBrush = pNode.BackgroundBrush;
ShowGroupIndicator = true;
}
}
}
4 changes: 2 additions & 2 deletions TuneUp/TuneUpWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private void LatestRunTable_Sorting(object sender, DataGridSortingEventArgs e)
{
"#" => TuneUpWindowViewModel.SortByNumber,
"Name" => TuneUpWindowViewModel.SortByName,
"Execution Time (ms)" => TuneUpWindowViewModel.SortByTime,
"Execution time (ms)" => TuneUpWindowViewModel.SortByTime,
_ => viewModel.SortingOrder
};

Expand All @@ -188,7 +188,7 @@ private void LatestRunTable_Sorting(object sender, DataGridSortingEventArgs e)
: ListSortDirection.Ascending;

// Apply custom sorting to ensure total times are at the bottom
viewModel.ApplyCustomSorting();
viewModel.ApplyCustomSortingToAllCollections();
e.Handled = true;
}
}
Expand Down
Loading

0 comments on commit 2fa4a5b

Please sign in to comment.