private void DragAreaTracker_MouseMove(object sender, MouseEventArgs e) { if (null != current_annotation) { Point mouse_move_point = e.GetPosition(canvas); Canvas.SetLeft(current_annotation, Math.Min(mouse_move_point.X, mouse_down_point.X)); Canvas.SetTop(current_annotation, Math.Min(mouse_move_point.Y, mouse_down_point.Y)); current_annotation.Width = Math.Abs(mouse_move_point.X - mouse_down_point.X); current_annotation.Height = Math.Abs(mouse_move_point.Y - mouse_down_point.Y); OnDragInProgress?.Invoke(button_left_pressed, button_right_pressed, mouse_down_point, mouse_move_point); } }
private 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); OnDragStarted?.Invoke(button_left_pressed, button_right_pressed, mouse_down_point); OnDragInProgress?.Invoke(button_left_pressed, button_right_pressed, mouse_down_point, mouse_down_point); } }