Skip to content

Commit

Permalink
[DYN-7466] Navigate-to-corresponding-node/group-by-clicking-it-in-the…
Browse files Browse the repository at this point in the history
…-TuneUp-list (#15504)
  • Loading branch information
ivaylo-matov authored Sep 30, 2024
1 parent cebc4bf commit e9993f0
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 15 deletions.
9 changes: 9 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,9 @@ You can always redownload the package.</value>
</data>
<data name="MessageFailedToFindNodeById" xml:space="preserve">
<value>No node could be found with that Id.</value>
</data>
<data name="MessageFailedToFindGroupById" xml:space="preserve">
<value>No group could be found with that Id.</value>
</data>
<data name="MessageFailedToOpenCorruptedFile" xml:space="preserve">
<value>Error opening corrupted file: {0}</value>
Expand Down
3 changes: 3 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,9 @@ Do you want to install the latest Dynamo update?</value>
</data>
<data name="MessageFailedToFindNodeById" xml:space="preserve">
<value>No node could be found with that Id.</value>
</data>
<data name="MessageFailedToFindGroupById" xml:space="preserve">
<value>No group could be found with that Id.</value>
</data>
<data name="MessageFailedToOpenCorruptedFile" xml:space="preserve">
<value>Error opening corrupted file: {0}</value>
Expand Down
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 19 additions & 15 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2736,31 +2736,35 @@ internal void FocusCustomNodeWorkspace(Guid symbol, bool silent = false)
/// </summary>
/// <param name="e"></param>
/// <param name="forceShowElement"></param>
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));
}

Expand Down
19 changes: 19 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e9993f0

Please sign in to comment.