From ef46c316265f69043557c5a20fc9072f20893d92 Mon Sep 17 00:00:00 2001 From: Ivo Petrov <48355182+ivaylo-matov@users.noreply.github.com> Date: Tue, 17 Sep 2024 01:48:37 +0100 Subject: [PATCH] [DYN-7334] Revised TuneUp controls layout (#53) * initial button re-arrangement * DataGrid work * progress record * progress record * collections wotking fix sorting add datagrids * totals aligned * total run times working * evaluation completed works * progress record * progress TODO: - reset PreviousRun TotalGroup nodes' execution times - remove execution time 0s from NotExecuted nodes when hoover over them * progress record TODO: - Remove executionOrder from TotalGroupNodes - ExportJSON - write the code - Total time to be calculated from rounded times - Remove ExecutionTimes from NotExecuted nodes - UI to update when a node is renamed - UI to update when group is renamed and/or background color has changed * before UI cleanup * progress record * progress * draft PR * showGroups off by default * Update ProfiledNodeViewModel.cs --- TuneUp/ProfiledNodeViewModel.cs | 123 +++- TuneUp/TuneUpViewExtension.cs | 7 +- TuneUp/TuneUpWindow.xaml | 730 +++++++++++++++++------- TuneUp/TuneUpWindow.xaml.cs | 200 +++++-- TuneUp/TuneUpWindowViewModel.cs | 964 +++++++++++++++++++++++++------- TuneUpTests/TuneUpTests.cs | 6 +- help-16px.png | Bin 0 -> 471 bytes 7 files changed, 1558 insertions(+), 472 deletions(-) create mode 100644 help-16px.png diff --git a/TuneUp/ProfiledNodeViewModel.cs b/TuneUp/ProfiledNodeViewModel.cs index 87aca8b..ef378d4 100644 --- a/TuneUp/ProfiledNodeViewModel.cs +++ b/TuneUp/ProfiledNodeViewModel.cs @@ -7,18 +7,115 @@ using Dynamo.Core; using Dynamo.Graph.Annotations; using Dynamo.Graph.Nodes; +using Dynamo.Graph.Nodes.CustomNodes; +using Dynamo.Graph.Nodes.ZeroTouch; namespace TuneUp { public class ProfiledNodeViewModel : NotificationObject { #region Properties + + /// + /// Checks if the Node has been Renamed after its creation + /// + public bool IsRenamed + { + get + { + if (NodeModel == null) + { + return false; + } + isRenamed = GetOriginalName(NodeModel) != NodeModel.Name; + return isRenamed; + } + internal set + { + if (isRenamed == value) return; + isRenamed = value; + RaisePropertyChanged(nameof(IsRenamed)); + } + } + private bool isRenamed = false; + + /// + /// The original name of the node + /// + public string OriginalName + { + get + { + //string originalName = NodeModel.GetOriginalName(); + string originalName = GetOriginalName(NodeModel); + return originalName; + } + internal set + { + if (originalName == value) return; + originalName = value; + RaisePropertyChanged(nameof(OriginalName)); + } + } + private string originalName = string.Empty; + + /// + /// Indicates whether this node represents the total execution time for its group + /// + public bool IsGroupExecutionTime + { + get => isGroupExecutionTime; + set + { + isGroupExecutionTime = value; + RaisePropertyChanged(nameof(IsGroupExecutionTime)); + } + } + private bool isGroupExecutionTime = false; + + /// + /// Getting the original name before graph author renamed the node + /// + /// target NodeModel + /// Original node name as string + private static string GetOriginalName(NodeModel node) + { + if (node == null) return string.Empty; + // For dummy node, return the current name so that does not appear to be renamed + if (node is DummyNode) + { + return node.Name; + } + if (node.IsCustomFunction) + { + // If the custom node is not loaded, return the current name so that does not appear to be renamed + if ((node as Function).State == ElementState.Error && (node as Function).Definition.IsProxy) + { + return node.Name; + } + // If the custom node is loaded, return original name as usual + var customNodeFunction = node as Function; + return customNodeFunction?.Definition.DisplayName; + } + + var function = node as DSFunctionBase; + if (function != null) + return function.Controller.Definition.DisplayName; + + var nodeType = node.GetType(); + var elNameAttrib = nodeType.GetCustomAttributes(false).FirstOrDefault(); + if (elNameAttrib != null) + return elNameAttrib.Name; + + return nodeType.FullName; + } + /// /// Prefix string of execution time. /// public static readonly string ExecutionTimelString = "Execution Time"; - public static readonly string GroupNodePrefix = "Group: "; + public static readonly string GroupExecutionTimeString = "Group total"; private string name = String.Empty; /// @@ -31,7 +128,9 @@ public string Name get { // For virtual row, do not attempt to grab node name - if (!name.Contains(ExecutionTimelString) && !name.StartsWith(GroupNodePrefix)) + if (!name.Contains(ExecutionTimelString) && + !name.StartsWith(GroupNodePrefix) && + !name.Equals(GroupExecutionTimeString)) name = NodeModel?.Name; return name; } @@ -102,8 +201,14 @@ public TimeSpan GroupExecutionTime /// public int ExecutionMilliseconds { - get => (int)Math.Round(ExecutionTime.TotalMilliseconds); + get => executionMilliseconds; + set + { + executionMilliseconds = value; + RaisePropertyChanged(nameof(ExecutionMilliseconds)); + } } + private int executionMilliseconds; /// /// Indicates whether this node was executed on the most recent graph run @@ -176,6 +281,18 @@ public bool IsGroup } private bool isGroup; + public bool ShowGroupIndicator + { + get => showGroupIndicator; + set + { + showGroupIndicator = value; + RaisePropertyChanged(nameof(ShowGroupIndicator)); + } + } + private bool showGroupIndicator; + + /// /// The background brush for this node /// If this node represents a group, it inherits the background color from the associated AnnotationModel diff --git a/TuneUp/TuneUpViewExtension.cs b/TuneUp/TuneUpViewExtension.cs index 57fe602..fabeb01 100644 --- a/TuneUp/TuneUpViewExtension.cs +++ b/TuneUp/TuneUpViewExtension.cs @@ -18,7 +18,6 @@ public class TuneUpViewExtension : ViewExtensionBase, IViewExtension public override void Dispose() { - TuneUpView.Dispose(); } public override void Startup(ViewStartupParams p) @@ -34,7 +33,9 @@ public override void Loaded(ViewLoadedParams p) TuneUpView = new TuneUpWindow(p, UniqueId) { // Set the data context for the main grid in the window. - NodeAnalysisTable = { DataContext = ViewModel }, + LatestRunTable = { DataContext = ViewModel }, + PreviousRunTable = { DataContext = ViewModel }, + NotExecutedTable = { DataContext = ViewModel }, MainGrid = { DataContext = ViewModel }, Owner = p.DynamoWindow }; @@ -114,7 +115,7 @@ public override void Closed() this.TuneUpMenuItem.IsChecked = false; // Reset DataGrid sorting order & direction - ViewModel.SortingOrder = "number"; + ViewModel.SortingOrder = TuneUpWindowViewModel.SortByNumber; ViewModel.SortDirection = System.ComponentModel.ListSortDirection.Ascending; } } diff --git a/TuneUp/TuneUpWindow.xaml b/TuneUp/TuneUpWindow.xaml index cbecbd3..cd15d62 100644 --- a/TuneUp/TuneUpWindow.xaml +++ b/TuneUp/TuneUpWindow.xaml @@ -1,89 +1,120 @@ - + - - - + + + + + + + + + + + + #555555 + + #434343 + + - + - - - - - + - + - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - -