Exemplo n.º 1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (!isDrawRectAreaCreated && firstStartPoint != Point.Empty)
            {
                firstEndPoint = new Point(e.X, e.Y);
                lastPoint     = firstStartPoint;
                this.Refresh();
                return;
            }

            if (!HasDrawRectangleArea)
            {
                return;
            }

            Point point    = new Point(e.X, e.Y);
            Point oldPoint = lastPoint;

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

                if (n > 0)
                {
                    cursor = drawRect.GetHandleCursor(n);
                }

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

                this.Cursor = cursor;

                return;
            }


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

            int dx = e.X - lastPoint.X;
            int dy = e.Y - lastPoint.Y;

            lastPoint.X = e.X;
            lastPoint.Y = e.Y;

            // resize
            if (drawRect != null)
            {
                //this.drawArea.Visible = false;
                this.toolStripPanel.Visible = false;
                this.myColorPicker.Visible  = false;

                this.ResizeDrawArea();

                if (selectMode == SelectionMode.Size)
                {
                    drawRect.MoveHandleTo(point, resizedObjectHandle);
                }
                else if (selectMode == SelectionMode.Move)
                {
                    this.Cursor = Cursors.SizeAll;
                    drawRect.Move(dx, dy);
                }

                this.Refresh();
            }

            base.OnMouseMove(e);
        }