Beispiel #1
0
        internal override void Update()
        {
            Rectangle minRect   = new Rectangle(rectangle.Right - tBarHeight + 6, position.Y - tBarHeight + 6, tBarHeight - 12, tBarHeight - 12);
            Rectangle titleRect = new Rectangle(position.X, position.Y - tBarHeight, size.width, tBarHeight);

            if (!Input.LeftD)
            {
                moving = false;
                res    = new ResizeInfo();
            }

            bool lResize = new Rectangle(rectangle.X, rectangle.Y, 6, tBarHeight + (minimized ? 0 : size.height)).IntersectsMouse();
            bool rResize = new Rectangle(rectangle.Right - 6, rectangle.Y, 6, tBarHeight + (minimized ? 0 : size.height)).IntersectsMouse();
            bool tResize = new Rectangle(rectangle.X, rectangle.Y, size.width, 6).IntersectsMouse();
            bool bResize = new Rectangle(rectangle.X, rectangle.Bottom - 6, size.width, 6).IntersectsMouse();

            if (res.dir != Direction.NONE)
            {
                lResize = (res.dir & Direction.LEFT) != 0;
                rResize = (res.dir & Direction.RIGHT) != 0;
                tResize = (res.dir & Direction.UP) != 0;
                bResize = (res.dir & Direction.DOWN) != 0;
            }
            if (minimized)
            {
                tResize = bResize = false;
            }
            if (moving || !canResize)
            {
                lResize = rResize = tResize = bResize = false;
            }

            if (runClicks)
            {
                if (lResize || rResize)
                {
                    GUI.SetCursor(CursorType.RESIZE_HORIZONTAL);
                    if (Input.LeftC)
                    {
                        res.pt.X = Input.mX - position.X - (rResize ? size.width : 0);
                        res.dir |= rResize ? Direction.RIGHT : Direction.LEFT;
                    }
                }
                if (tResize || bResize)
                {
                    GUI.SetCursor((lResize || rResize) ? CursorType.RESIZE_DIAGONAL : CursorType.RESIZE_VERTICAL);
                    if ((rResize && tResize) || (bResize && lResize))
                    {
                        GUI.FlipCursor(true);
                    }
                    if (Input.LeftC)
                    {
                        res.pt.Y = Input.mY - position.Y - (bResize ? size.height : 0);
                        res.dir |= bResize ? Direction.DOWN : Direction.UP;
                    }
                }
                if (minRect.IntersectsMouse())
                {
                    if (Input.LeftR)
                    {
                        minimized = !minimized;
                    }
                }
                else if (titleRect.IntersectsMouse() && res.dir == Direction.NONE && Input.LeftC)
                {
                    moving = true;
                }
                if (rectangle.IntersectsMouse() && Input.LeftC)
                {
                    GUI.formOrder.Remove(index);
                    GUI.formOrder.Add(index);
                }
            }

            if (moving)
            {
                position += new Position(Input.mDX, Input.mDY);
            }
            #region Resizing
            if ((res.dir & Direction.LEFT) != 0)
            {
                if (size.width - Input.mDX < minSize.width)
                {
                    res.mOff   |= Direction.LEFT;
                    position.X += size.width - minSize.width;
                    size.width  = minSize.width;
                }
                if ((res.mOff & Direction.LEFT) == 0)
                {
                    size.width -= Input.mDX;
                    position.X += Input.mDX;
                }
                if (Input.mX - position.X < res.pt.X && (res.mOff & Direction.LEFT) != 0)
                {
                    res.mOff &= ~Direction.LEFT;
                    int disp = res.pt.X - Input.mX + position.X;
                    position.X -= disp;
                    size.width += disp;
                }
            }
            if ((res.dir & Direction.RIGHT) != 0)
            {
                if (size.width + Input.mDX < minSize.width)
                {
                    res.mOff  |= Direction.RIGHT;
                    size.width = minSize.width;
                }
                if ((res.mOff & Direction.RIGHT) == 0)
                {
                    size.width += Input.mDX;
                }
                if (Input.mX - size.width - position.X > res.pt.X && (res.mOff & Direction.RIGHT) != 0)
                {
                    res.mOff  &= ~Direction.RIGHT;
                    size.width = Input.mX - position.X - res.pt.X;
                }
            }
            if ((res.dir & Direction.UP) != 0)
            {
                if (size.height - Input.mDY < minSize.height)
                {
                    res.mOff   |= Direction.UP;
                    position.Y += size.height - minSize.height;
                    size.height = minSize.height;
                }
                if ((res.mOff & Direction.UP) == 0)
                {
                    size.height -= Input.mDY;
                    position.Y  += Input.mDY;
                }
                if (Input.mY - position.Y < res.pt.Y && (res.mOff & Direction.UP) != 0)
                {
                    res.mOff &= ~Direction.UP;
                    int disp = res.pt.Y - Input.mY + position.Y;
                    position.Y  -= disp;
                    size.height += disp;
                }
            }
            if ((res.dir & Direction.DOWN) != 0)
            {
                if (size.height + Input.mDY < minSize.height)
                {
                    res.mOff   |= Direction.DOWN;
                    size.height = minSize.height;
                }
                if ((res.mOff & Direction.DOWN) == 0)
                {
                    size.height += Input.mDY;
                }
                if (Input.mY - size.height - position.Y > res.pt.Y && (res.mOff & Direction.DOWN) != 0)
                {
                    res.mOff   &= ~Direction.DOWN;
                    size.height = Input.mY - position.Y - res.pt.Y;
                }
            }
            #endregion
            if (GUI.contextMenu != null && !minimized)
            {
                MaskUpdate <ContextMenuArea>();
            }
            else if (isActive)
            {
                if (onUpdate != null)
                {
                    onUpdate.Invoke();
                }
                if (!minimized)
                {
                    base.Update();
                }
            }
            else
            {
                if (!minimized)
                {
                    foreach (Control c in controls)
                    {
                        c.Reposition(this);
                    }
                }
            }
        }
Beispiel #2
0
        internal override void Update()
        {
            Rectangle minRect = new Rectangle(rectangle.Right - tBarHeight + 6, position.Y - tBarHeight + 6, tBarHeight - 12, tBarHeight - 12);
            Rectangle titleRect = new Rectangle(position.X, position.Y - tBarHeight, size.width, tBarHeight);
            if (!Input.LeftD)
            {
                moving = false;
                res = new ResizeInfo();
            }

            bool lResize = new Rectangle(rectangle.X, rectangle.Y, 6, tBarHeight + (minimized ? 0 : size.height)).IntersectsMouse();
            bool rResize = new Rectangle(rectangle.Right - 6, rectangle.Y, 6, tBarHeight + (minimized ? 0 : size.height)).IntersectsMouse();
            bool tResize = new Rectangle(rectangle.X, rectangle.Y, size.width, 6).IntersectsMouse();
            bool bResize = new Rectangle(rectangle.X, rectangle.Bottom - 6, size.width, 6).IntersectsMouse();
            if (res.dir != Direction.NONE)
            {
                lResize = (res.dir & Direction.LEFT) != 0;
                rResize = (res.dir & Direction.RIGHT) != 0;
                tResize = (res.dir & Direction.UP) != 0;
                bResize = (res.dir & Direction.DOWN) != 0;
            }
            if (minimized)
            {
                tResize = bResize = false;
            }
            if (moving || !canResize)
            {
                lResize = rResize = tResize = bResize = false;
            }

            if (runClicks)
            {
                if (lResize || rResize)
                {
                    GUI.SetCursor(CursorType.RESIZE_HORIZONTAL);
                    if (Input.LeftC)
                    {
                        res.pt.X = Input.mX - position.X - (rResize ? size.width : 0);
                        res.dir |= rResize ? Direction.RIGHT : Direction.LEFT;
                    }
                }
                if (tResize || bResize)
                {
                    GUI.SetCursor((lResize || rResize) ? CursorType.RESIZE_DIAGONAL : CursorType.RESIZE_VERTICAL);
                    if ((rResize && tResize) || (bResize && lResize))
                    {
                        GUI.FlipCursor(true);
                    }
                    if (Input.LeftC)
                    {
                        res.pt.Y = Input.mY - position.Y - (bResize ? size.height : 0);
                        res.dir |= bResize ? Direction.DOWN : Direction.UP;
                    }
                }
                if (minRect.IntersectsMouse())
                {
                    if (Input.LeftR)
                    {
                        minimized = !minimized;
                    }
                }
                else if (titleRect.IntersectsMouse() && res.dir == Direction.NONE && Input.LeftC)
                {
                    moving = true;
                }
                if (rectangle.IntersectsMouse() && Input.LeftC)
                {
                    GUI.formOrder.Remove(index);
                    GUI.formOrder.Add(index);
                }
            }

            if (moving)
            {
                position += new Position(Input.mDX, Input.mDY);
            }
            #region Resizing
            if ((res.dir & Direction.LEFT) != 0)
            {
                if (size.width - Input.mDX < minSize.width)
                {
                    res.mOff |= Direction.LEFT;
                    position.X += size.width - minSize.width;
                    size.width = minSize.width;
                }
                if ((res.mOff & Direction.LEFT) == 0)
                {
                    size.width -= Input.mDX;
                    position.X += Input.mDX;
                }
                if (Input.mX - position.X < res.pt.X && (res.mOff & Direction.LEFT) != 0)
                {
                    res.mOff &= ~Direction.LEFT;
                    int disp = res.pt.X - Input.mX + position.X;
                    position.X -= disp;
                    size.width += disp;
                }
            }
            if ((res.dir & Direction.RIGHT) != 0)
            {
                if (size.width + Input.mDX < minSize.width)
                {
                    res.mOff |= Direction.RIGHT;
                    size.width = minSize.width;
                }
                if ((res.mOff & Direction.RIGHT) == 0)
                {
                    size.width += Input.mDX;
                }
                if (Input.mX - size.width - position.X > res.pt.X && (res.mOff & Direction.RIGHT) != 0)
                {
                    res.mOff &= ~Direction.RIGHT;
                    size.width = Input.mX - position.X - res.pt.X;
                }
            }
            if ((res.dir & Direction.UP) != 0)
            {
                if (size.height - Input.mDY < minSize.height)
                {
                    res.mOff |= Direction.UP;
                    position.Y += size.height - minSize.height;
                    size.height = minSize.height;
                }
                if ((res.mOff & Direction.UP) == 0)
                {
                    size.height -= Input.mDY;
                    position.Y += Input.mDY;
                }
                if (Input.mY - position.Y < res.pt.Y && (res.mOff & Direction.UP) != 0)
                {
                    res.mOff &= ~Direction.UP;
                    int disp = res.pt.Y - Input.mY + position.Y;
                    position.Y -= disp;
                    size.height += disp;
                }
            }
            if ((res.dir & Direction.DOWN) != 0)
            {
                if (size.height + Input.mDY < minSize.height)
                {
                    res.mOff |= Direction.DOWN;
                    size.height = minSize.height;
                }
                if ((res.mOff & Direction.DOWN) == 0)
                {
                    size.height += Input.mDY;
                }
                if (Input.mY - size.height - position.Y > res.pt.Y && (res.mOff & Direction.DOWN) != 0)
                {
                    res.mOff &= ~Direction.DOWN;
                    size.height = Input.mY - position.Y - res.pt.Y;
                }
            }
            #endregion
            if (GUI.contextMenu != null && !minimized)
            {
                MaskUpdate<ContextMenuArea>();
            }
            else if (isActive)
            {
                if (onUpdate != null)
                {
                    onUpdate.Invoke();
                }
                if (!minimized)
                {
                    base.Update();
                }
            }
            else
            {
                if (!minimized)
                {
                    foreach (Control c in controls)
                    {
                        c.Reposition(this);
                    }
                }
            }
        }