So I try to pass informations from my MainWindow.xaml.cs to a new Window called Distance.xaml.cs. Therefore I added a button, which opens the new Window, when clicked. My Code nearly perfectly works:
private void CmdDistance_Click(object senderr, RoutedEventArgs e)
{
Distance distance = new Distance();
distance.setPosition(e.GetPosition(DepthImage));
distance.setArray(mySkeletonArray);
distance.Show();
}
The only problem is that I need to pass the Position on DepthImage to Distance.xaml.cs. So I use GetPosition. But here's my problem: To use GetPosition I need to use System.Windows.Input.MouseEventArgs, but if I program two EventHandler to my function I get the error:
No overload for 'CmdDistance_Click' matches delegate 'System.Windows.RoutedEventHandler'
Does anybody know what I'm doing wrong
Edit: I now changed my code, so that I first store the mouse position in a variable, and the pass it to the second window. The problem is that when I try to mark two point in my image nothing is passed from MainWindow to the second window, and therefore nothing happens.
Here is my new code for MainWindow:
public partial class MainWindow:Window
{
System.Windows.Point myMousePosition;
private void MousePosition(object sender, System.Windows.Input.MouseEventArgs e)
{
System.Windows.Point myMousePosition = e.GetPosition(DepthImage);
}
private void CmdDistance_Click(object senderr, RoutedEventArgs e)
{
Distance distance = new Distance();
distance.setPosition(myMousePosition);
distance.setArray(mySkeletonArray);
distance.Show();
}
}
In the DistanceWindow I use this lines of code to calculate the distance:
public partial class Distance : Window
{
KinectSensor mySensor;
SkeletonPoint[] mySkeletonArray;
System.Windows.Point position;
int i;
public Distance()
{
InitializeComponent();
i = 1;
}
public void setPosition(System.Windows.Point pos)
{
position = pos;
}
public void setArray(SkeletonPoint[] SkeletonArray)
{
mySkeletonArray = SkeletonArray;
}
private void DistanceMeasurement(object sender, System.Windows.Input.MouseEventArgs e)
{
int xpos = (int)position.X;
int ypos = (int)position.Y;
}
}