コード例 #1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (Gump == null)
            {
                return;
            }

            if (e.Button == MouseButtons.None)
            {
                mouseDownAt = Point.Empty;
                resizing    = false;
            }
            redoStack.Clear();
            int xDelta = e.Location.X - mouseAt.X;
            int yDelta = e.Location.Y - mouseAt.Y;

            if (resizing)
            {
                redoStack.Clear();
                OnBeforeBaseGumpMoved(this, EventArgs.Empty);
                BaseGump resizableGump = gump.GetSelectedGumps()[0];
                switch (resizeType)
                {
                case ResizeType.BottomCenter:
                {
                    resizableGump.Height += yDelta;
                    break;
                }

                case ResizeType.BottomLeft:
                {
                    resizableGump.Location = new Point(resizableGump.Location.X + xDelta, resizableGump.Location.Y);
                    resizableGump.Width   -= xDelta;
                    resizableGump.Height  += yDelta;
                    break;
                }

                case ResizeType.BottomRight:
                {
                    resizableGump.Width  += xDelta;
                    resizableGump.Height += yDelta;
                    break;
                }

                case ResizeType.MiddleLeft:
                {
                    resizableGump.Location = new Point(resizableGump.Location.X + xDelta, resizableGump.Location.Y);
                    resizableGump.Width   -= xDelta;
                    break;
                }

                case ResizeType.MiddleRight:
                {
                    resizableGump.Width += xDelta;
                    break;
                }

                case ResizeType.TopCenter:
                {
                    resizableGump.Location = new Point(resizableGump.Location.X, resizableGump.Location.Y + yDelta);
                    resizableGump.Height  -= yDelta;
                    break;
                }

                case ResizeType.TopLeft:
                {
                    resizableGump.Location = new Point(resizableGump.Location.X + xDelta, resizableGump.Location.Y + yDelta);
                    resizableGump.Width   -= xDelta;
                    resizableGump.Height  -= yDelta;

                    break;
                }

                case ResizeType.TopRight:
                {
                    resizableGump.Location = new Point(resizableGump.Location.X, resizableGump.Location.Y + yDelta);
                    resizableGump.Width   += xDelta;
                    resizableGump.Height  -= yDelta;
                    break;
                }
                }

                resizableGump.Invalidate();
                OnBaseGumpMoved(this, EventArgs.Empty);
            }
            else if (movable != null)
            {
                redoStack.Clear();
                OnBeforeBaseGumpMoved(this, EventArgs.Empty);
                for (int i = 0; i < movable.Count; i++)
                {
                    movable[i].MoveBy(xDelta, yDelta);
                    movable[i].Invalidate();

                    OnBaseGumpMoved(this, EventArgs.Empty);
                }
            }
            else
            {
            }

            mouseAt = e.Location;

            Invalidate();
        }