From e9993f033f22da758dd9afdbdd81b08e191c551a Mon Sep 17 00:00:00 2001 From: Ivo Petrov <48355182+ivaylo-matov@users.noreply.github.com> Date: Mon, 30 Sep 2024 18:07:53 +0100 Subject: [PATCH] [DYN-7466] Navigate-to-corresponding-node/group-by-clicking-it-in-the-TuneUp-list (#15504) --- .../Properties/Resources.Designer.cs | 9 +++++ .../Properties/Resources.en-US.resx | 3 ++ src/DynamoCoreWpf/Properties/Resources.resx | 3 ++ src/DynamoCoreWpf/PublicAPI.Unshipped.txt | 1 + .../ViewModels/Core/DynamoViewModel.cs | 34 +++++++++++-------- .../ViewModels/Core/WorkspaceViewModel.cs | 19 +++++++++++ 6 files changed, 54 insertions(+), 15 deletions(-) diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs index 141cc6e0fd4..4605c185a64 100644 --- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs +++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs @@ -4507,6 +4507,15 @@ public static string MessageFailedToDownloadPackageVersion { } } + /// + /// Looks up a localized string similar to No group could be found with that Id.. + /// + public static string MessageFailedToFindGroupById { + get { + return ResourceManager.GetString("MessageFailedToFindGroupById", resourceCulture); + } + } + /// /// Looks up a localized string similar to No node could be found with that Id.. /// diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index 0afa100be71..281fd133fb9 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -1323,6 +1323,9 @@ You can always redownload the package. No node could be found with that Id. + + + No group could be found with that Id. Error opening corrupted file: {0} diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index ff5426a0527..0ccc2e6378e 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -1915,6 +1915,9 @@ Do you want to install the latest Dynamo update? No node could be found with that Id. + + + No group could be found with that Id. Error opening corrupted file: {0} diff --git a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt index 22f10109f6f..2cdfa3f88b4 100644 --- a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt +++ b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt @@ -4856,6 +4856,7 @@ static Dynamo.Wpf.Properties.Resources.MessageFailedToDelete.get -> string static Dynamo.Wpf.Properties.Resources.MessageFailedToDownloadPackage.get -> string static Dynamo.Wpf.Properties.Resources.MessageFailedToDownloadPackageVersion.get -> string static Dynamo.Wpf.Properties.Resources.MessageFailedToFindNodeById.get -> string +static Dynamo.Wpf.Properties.Resources.MessageFailedToFindGroupById.get -> string static Dynamo.Wpf.Properties.Resources.MessageFailedToOpenCorruptedFile.get -> string static Dynamo.Wpf.Properties.Resources.MessageFailedToSaveAsImage.get -> string static Dynamo.Wpf.Properties.Resources.MessageFailedToUnload.get -> string diff --git a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs index 4a401ee6e3a..c9dfec9c397 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs @@ -2736,31 +2736,35 @@ internal void FocusCustomNodeWorkspace(Guid symbol, bool silent = false) /// /// /// - internal void ShowElement(NodeModel e, bool forceShowElement = true) + internal void ShowElement(ModelBase e, bool forceShowElement = true) { if (HomeSpace.RunSettings.RunType == RunType.Automatic && forceShowElement) return; - if (!model.CurrentWorkspace.Nodes.Contains(e)) + // Handle NodeModel + if (e is NodeModel node) { - if (HomeSpace != null && HomeSpace.Nodes.Contains(e)) + if (!model.CurrentWorkspace.Nodes.Contains(e)) { - //Show the homespace - model.CurrentWorkspace = HomeSpace; - } - else - { - foreach ( - var customNodeWorkspace in - model.CustomNodeManager.LoadedWorkspaces.Where( - customNodeWorkspace => customNodeWorkspace.Nodes.Contains(e))) + if (HomeSpace != null && HomeSpace.Nodes.Contains(e)) { - FocusCustomNodeWorkspace(customNodeWorkspace.CustomNodeId); - break; + //Show the homespace + model.CurrentWorkspace = HomeSpace; + } + else + { + foreach ( + var customNodeWorkspace in + model.CustomNodeManager.LoadedWorkspaces.Where( + customNodeWorkspace => customNodeWorkspace.Nodes.Contains(e))) + { + FocusCustomNodeWorkspace(customNodeWorkspace.CustomNodeId); + break; + } } } } - + // Center the view on the model this.CurrentSpaceViewModel.OnRequestCenterViewOnElement(this, new ModelEventArgs(e)); } diff --git a/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs index a3175672525..544340baab2 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs @@ -1646,6 +1646,25 @@ private void FindById(object id) { DynamoViewModel.Model.Logger.Log(Wpf.Properties.Resources.MessageFailedToFindNodeById); } + + try + { + var group = DynamoViewModel.Model.CurrentWorkspace.Annotations.FirstOrDefault(x => x.GUID.ToString() == id.ToString()); + + if (group != null) + { + //select the element + DynamoSelection.Instance.ClearSelection(); + DynamoSelection.Instance.Selection.Add(group); + + //focus on the element + DynamoViewModel.ShowElement(group); + } + } + catch + { + DynamoViewModel.Model.Logger.Log(Wpf.Properties.Resources.MessageFailedToFindGroupById); + } } private static bool CanFindById(object id)