diff --git a/src/DynamoCoreWpf/DynamoCoreWpf.csproj b/src/DynamoCoreWpf/DynamoCoreWpf.csproj
index cfd33befbed..da7d03b0450 100644
--- a/src/DynamoCoreWpf/DynamoCoreWpf.csproj
+++ b/src/DynamoCoreWpf/DynamoCoreWpf.csproj
@@ -157,6 +157,7 @@
+
diff --git a/src/DynamoCoreWpf/Extensions/ViewLoadedParams.cs b/src/DynamoCoreWpf/Extensions/ViewLoadedParams.cs
index 948d8064f41..11986ba7359 100644
--- a/src/DynamoCoreWpf/Extensions/ViewLoadedParams.cs
+++ b/src/DynamoCoreWpf/Extensions/ViewLoadedParams.cs
@@ -9,6 +9,7 @@
using Dynamo.Utilities;
using Dynamo.ViewModels;
using Dynamo.Visualization;
+using Dynamo.Wpf.ViewModels;
using Dynamo.Wpf.ViewModels.Watch3D;
namespace Dynamo.Wpf.Extensions
@@ -54,6 +55,15 @@ public IPackageInstaller PackageInstaller
get { return dynamoViewModel.PackageManagerClientViewModel; }
}
+ private ViewModelCommandExecutive viewModelCommandExecutive;
+ ///
+ /// Class used for executing commands on the DynamoViewModel and current WorkspaceViewModel
+ ///
+ public ViewModelCommandExecutive ViewModelCommandExecutive
+ {
+ get { return viewModelCommandExecutive ?? (viewModelCommandExecutive = new ViewModelCommandExecutive(dynamoViewModel)); }
+ }
+
///
/// A reference to the Dynamo Window object. Useful for correctly setting the parent of a
/// newly created window.
diff --git a/src/DynamoCoreWpf/Extensions/ViewModelCommandExecutive.cs b/src/DynamoCoreWpf/Extensions/ViewModelCommandExecutive.cs
new file mode 100644
index 00000000000..5d4c8668dbf
--- /dev/null
+++ b/src/DynamoCoreWpf/Extensions/ViewModelCommandExecutive.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Dynamo.ViewModels;
+
+namespace Dynamo.Wpf.Extensions
+{
+ ///
+ /// The ViewModelCommandExecutive provides access to DynamoViewModel and WorkspaceViewModel commands
+ ///
+ public class ViewModelCommandExecutive
+ {
+ private DynamoViewModel dynamoViewModel;
+
+ ///
+ /// Create a Command Executive for a DynamoViewModel
+ ///
+ ///
+ internal ViewModelCommandExecutive(DynamoViewModel viewModel)
+ {
+ dynamoViewModel = viewModel;
+ }
+
+ ///
+ /// Fit the current workspace view to the current selection
+ ///
+ public void FitViewCommand()
+ {
+ dynamoViewModel.FitViewCommand.Execute(null);
+ }
+
+ ///
+ /// Search for an element by its ID and focus the view on it
+ ///
+ ///
+ public void FindByIdCommand(string objectID)
+ {
+ dynamoViewModel.CurrentSpaceViewModel.FindByIdCommand.Execute(objectID);
+ }
+
+ ///
+ /// Force re-execute all nodes in the current workspace
+ ///
+ /// Should errors be shown?
+ public void ForceRunExpressionCommand(bool showErrors = true)
+ {
+ dynamoViewModel.ForceRunExpressionCommand.Execute(showErrors);
+ }
+ }
+}
diff --git a/src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs b/src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs
index e0c7b20f312..e9406348e40 100644
--- a/src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs
+++ b/src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs
@@ -837,12 +837,11 @@ internal void CenterViewOnElement(object sender, EventArgs e)
double deltaX = nodeCenterInOverlay.X - outerCenter.X;
double deltaY = nodeCenterInOverlay.Y - outerCenter.Y;
+
+ vm.Model.X -= deltaX;
+ vm.Model.Y -= deltaY;
- //var offset = new Point(vm.CurrentOffset.X - deltaX, vm.CurrentOffset.Y - deltaY);
-
- //vm.CurrentOffset = offset;
-
- zoomBorder.SetTranslateTransformOrigin(new Point2D(vm.Model.X - deltaX, vm.Model.Y - deltaY));
+ zoomBorder.SetTranslateTransformOrigin(new Point2D(vm.Model.X, vm.Model.Y));
}
});
}