/// <summary>
        /// Mouse is moved.
        /// None button is pressed, ot left button is pressed.
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseMove(XnaToolUser drawArea, MouseEventArgs e)
        {
            var point = new Point(drawArea.MyMouseX, drawArea.MyMouseY);

            // set cursor when mouse button is not pressed
            if (e.Button == MouseButtons.None)
            {
                Cursor cursor = null;

                for (int i = 0; i < drawArea.GraphicsList.Count; i++)
                {
                    int n = drawArea.GraphicsList[i].HitTest(point);

                    if (n > 0)
                    {
                        cursor = drawArea.GraphicsList[i].GetHandleCursor(n);
                        break;
                    }
                    if (drawArea.GraphicsList[i].HitOnCircumferance)
                    {
                        cursor = drawArea.GraphicsList[i].GetOutlineCursor(n);
                        break;
                    }
                }

                if (cursor == null)
                {
                    cursor = Cursors.Default;
                }

                drawArea.Cursor = cursor;

                return;
            }

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            // Left button is pressed

            // Find difference between previous and current position
            float dx = drawArea.MyMouseX - _lastPoint.X;
            float dy = drawArea.MyMouseY - _lastPoint.Y;

            _lastPoint.X = drawArea.MyMouseX;
            _lastPoint.Y = drawArea.MyMouseY;

            // resize
            if (_selectMode == SelectionMode.Size)
            {
                if (_resizedObject != null)
                {
                    _resizedObject.MoveHandleTo(point, _resizedObjectHandle);
                    drawArea.SetDirty();
                    drawArea.Refresh();
                }
            }

            // move
            if (_selectMode == SelectionMode.Move)
            {
                int n = drawArea.GraphicsList.SelectionCount;

                for (int i = 0; i < n; i++)
                {
                    drawArea.GraphicsList.GetSelectedObject(i).Move(dx, dy);
                }

                drawArea.Cursor = Cursors.SizeAll;
                drawArea.SetDirty();
                drawArea.Refresh();
            }

            if (_selectMode == SelectionMode.NetSelection)
            {
                drawArea.NetRectangle = XnaDrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint);
                drawArea.Refresh();
                return;
            }
        }
Example #2
0
 public void Execute()
 {
     _itemResized.MoveHandleTo(_newPoint, _handle);
 }