void SurfaceMouseMove(object sender, MouseEventArgs e)
 {
     if (DrawingMode != DrawingModes.None)
     {
         Cursor = Cursors.Cross;
     }
     else
     {
         Cursor = Cursors.Default;
     }
     if (mouseDown)
     {
         if (mouseDownElement != null) // an element is currently dragged
         {
             selectedElements.HideGrippers();
             if (mouseDownElement.Selected) // dragged element has been selected before -> move all
             {
                 selectedElements.MoveBy(e.X - mX, e.Y - mY);
             }
             else // dragged element is not among selected elements -> just move dragged one
             {
                 mouseDownElement.MoveBy(e.X - mX, e.Y - mY);
             }
             mX = e.X;
             mY = e.Y;
             Invalidate();
         }
         else if (drawingElement != null) // an element is currently drawn
         {
             drawingElement.Width  = e.X - drawingElement.Left;
             drawingElement.Height = e.Y - drawingElement.Top;
             Invalidate();
         }
     }
 }
Exemple #2
0
        void SurfaceMouseMove(object sender, MouseEventArgs e)
        {
            Point currentMouse = MouseHelper.FixMouseCoordinates(e);

            if (DrawingMode != DrawingModes.None)
            {
                Cursor = Cursors.Cross;
            }
            else
            {
                Cursor = Cursors.Default;
            }

            if (mouseDown)
            {
                if (mouseDownElement != null)                  // an element is currently dragged
                {
                    mouseDownElement.Invalidate();
                    selectedElements.HideGrippers();
                    // Move the element
                    if (mouseDownElement.Selected)
                    {
                        if (!isSurfaceMoveMadeUndoable)
                        {
                            // Only allow one undoable per mouse-down/move/up "cycle"
                            isSurfaceMoveMadeUndoable = true;
                            selectedElements.MakeBoundsChangeUndoable(false);
                        }
                        // dragged element has been selected before -> move all
                        selectedElements.MoveBy(currentMouse.X - mouseStart.X, currentMouse.Y - mouseStart.Y);
                    }
                    else
                    {
                        if (!isSurfaceMoveMadeUndoable)
                        {
                            // Only allow one undoable per mouse-down/move/up "cycle"
                            isSurfaceMoveMadeUndoable = true;
                            mouseDownElement.MakeBoundsChangeUndoable(false);
                        }
                        // dragged element is not among selected elements -> just move dragged one
                        mouseDownElement.MoveBy(currentMouse.X - mouseStart.X, currentMouse.Y - mouseStart.Y);
                    }
                    mouseStart = currentMouse;
                    mouseDownElement.Invalidate();
                    modified = true;
                }
                else if (drawingElement != null)
                {
                    if (!drawingElement.HandleMouseMove(currentMouse.X, currentMouse.Y))
                    {
                        // an element is currently drawn
                        drawingElement.Invalidate();
                        drawingElement.Width  = currentMouse.X - drawingElement.Left;
                        drawingElement.Height = currentMouse.Y - drawingElement.Top;
                        drawingElement.Invalidate();
                    }
                    modified = true;
                }
            }
        }