views:

224

answers:

0

Hello,

I have a polyline in WPF, which contains some points. When the user clicks on a segment line it should drag the whole poly. when the user clicks on a single "knot" or point of the structure, it should be possible to drag only that point, reconfiguring the shape. I've been able to detect when the user clicks on a segment. I am trying to user the mouse move handler to move the segment according to the mouse, but it doesn't work correctly. In mouse move handler:

        if (e.MouseDevice.LeftButton == MouseButtonState.Pressed)
        {
            if (hitresult != null)
            {


                    // Calculate the current position of the object.
                    double deltaV = e.GetPosition(null).Y - mouseVerticalPosition;
                    double deltaH = e.GetPosition(null).X - mouseHorizontalPosition;
                    double newTop = deltaV + (double)polyLineEyeLeft.GetValue(Canvas.TopProperty);
                    double newLeft = deltaH + (double)polyLineEyeLeft.GetValue(Canvas.LeftProperty);

                    // Set new position of object.
                    polyLineEyeLeft.SetValue(Canvas.TopProperty, newTop);
                    polyLineEyeLeft.SetValue(Canvas.LeftProperty, newLeft);

                    // Update position global variables.
                    mouseVerticalPosition = e.GetPosition(null).Y;
                    mouseHorizontalPosition = e.GetPosition(null).X;
                }

}