void DragAreaTracker_MouseDown(object sender, MouseButtonEventArgs e)
        {
            mouse_down_point     = e.GetPosition(canvas);
            button_left_pressed  = e.LeftButton == MouseButtonState.Pressed;
            button_right_pressed = e.RightButton == MouseButtonState.Pressed;

            if (null == current_annotation)
            {
                canvas.CaptureMouse();

                current_annotation = new DragAreaControl(visible);

                Canvas.SetLeft(current_annotation, mouse_down_point.X);
                Canvas.SetTop(current_annotation, mouse_down_point.Y);
                current_annotation.Width  = 0;
                current_annotation.Height = 0;

                canvas.Children.Add(current_annotation);

                if (null != OnDragStarted)
                {
                    OnDragStarted(button_left_pressed, button_right_pressed, mouse_down_point);
                }

                if (null != OnDragInProgress)
                {
                    OnDragInProgress(button_left_pressed, button_right_pressed, mouse_down_point, mouse_down_point);
                }
            }
        }
Ejemplo n.º 2
0
        private void DragAreaTracker_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (null != current_annotation)
            {
                canvas.Children.Remove(current_annotation);
                current_annotation = null;
                canvas.ReleaseMouseCapture();

                Point mouse_up_point = e.GetPosition(canvas);
                OnDragComplete?.Invoke(button_left_pressed, button_right_pressed, mouse_down_point, mouse_up_point);
            }
        }