I have implemented a WPF project which renders a 3D mesh of data coming from a micro profilometer.
Since I have already implemented a big part of the work of 2D data analysis on WinForms; I want to create a user control of the WPF class which is called by the winform application. And I did. The problem is that in the WPF class the mouse events are triggered, and I can rotate, zoom, and shift the mesh; but when I insert the user control in my winform application, the mesh is successfully created; but the mouse events aren't triggered at all. (but they are implemented in the user control)
Am I missing some logic?
Here is the code for the WPF mouse events
public void OnViewportMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs args)
{
Point pt = args.GetPosition(mainViewport);
if (args.ChangedButton == MouseButton.Left) // rotate or drag 3d model
{
m_transformMatrix.OnLBtnDown(pt);
}
}
public void OnViewportMouseMove(object sender, System.Windows.Input.MouseEventArgs args)
{
Point pt = args.GetPosition(mainViewport);
if (args.LeftButton == MouseButtonState.Pressed) // rotate or drag 3d model
{
m_transformMatrix.OnMouseMove(pt, mainViewport);
TransformChart();
}
}
public void OnViewportMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs args)
{
Point pt = args.GetPosition(mainViewport);
if (args.ChangedButton == MouseButton.Left)
{
m_transformMatrix.OnLBtnUp();
}
}
}
And this is the winform that uses the WPF user control
public partial class MeshViewer: Form
{
wpfControlLib.UserControl1 userControl;
public MeshViewer(double[,] d)
{
InitializeComponent();
userControl = new wpfControlLib.UserControl1(d);
elementHost1.Child = userControl;
elementHost1.Show();
}
}
I tried to put the same mouse event handlers in the winform class and then call the corresponding mouse events of the WPF class, but the mouse event args are different in WinForms and WPF... and I don't think this is the right path...