/// <summary> /// Handle mouse move. /// Se cursor, move/resize, make group selection. /// </summary> public override void OnMouseMove(DrawingCanvas drawingCanvas, MouseEventArgs e) { // Exclude all cases except left button on/off. if (e.MiddleButton == MouseButtonState.Pressed || e.RightButton == MouseButtonState.Pressed) { drawingCanvas.Cursor = HelperFunctions.DefaultCursor; return; } Point point = e.GetPosition(drawingCanvas); // Set cursor when left button is not pressed if (e.LeftButton == MouseButtonState.Released) { Cursor cursor = null; for (int i = 0; i < drawingCanvas.Count; i++) { int n = drawingCanvas[i].MakeHitTest(point); if (n > 0) { cursor = drawingCanvas[i].GetHandleCursor(n); break; } } if (cursor == null) { cursor = HelperFunctions.DefaultCursor; } drawingCanvas.Cursor = cursor; return; } if (!drawingCanvas.IsMouseCaptured) { return; } wasMove = true; // Find difference between previous and current position double dx = point.X - lastPoint.X; double dy = point.Y - lastPoint.Y; lastPoint = point; // Resize if (selectMode == SelectionMode.Size) { if (resizedObject != null) { resizedObject.MoveHandleTo(point, resizedObjectHandle); } } // Move if (selectMode == SelectionMode.Move) { foreach (GraphicsBase o in drawingCanvas.Selection) { o.Move(dx, dy); } } // Group selection if (selectMode == SelectionMode.GroupSelection) { // Resize selection rectangle drawingCanvas[drawingCanvas.Count - 1].MoveHandleTo( point, 5); } }