Ejemplo n.º 1
0
        protected internal override void MouseDown(object sender, MouseEventArgs e)
        {
            if (windowBorder.AbsoluteRenderTransform.Contains(e.X, e.Y) == ContainmentType.Contains)
            {
                if (!LockPosition)
                {
                    var rect = windowBorder.GetBorder(Direction.Top);
                    rect.X += windowBorder.AbsoluteRenderTransform.X;
                    rect.Y += windowBorder.AbsoluteRenderTransform.Y;
                    if (rect.Contains(e.X, e.Y) == ContainmentType.Contains)
                    {
                        mouseOffset = new Vector2(rect.X - e.X, rect.Y - e.Y);
                        state       = DialogWindowState.Drag;
                    }
                }
                switch (ResizeMode)
                {
                case UI.ResizeMode.CanResize:
                    resizeCanResize(e.X, e.Y);
                    break;

                case UI.ResizeMode.NoResize:
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        private void resizeCanResize(float x, float y)
        {
            // this is just an idea for now!

            // Drag
            var rect = windowBorder.GetBorder(Direction.Top);

            rect.X      += windowBorder.AbsoluteRenderTransform.X;
            rect.Y      += windowBorder.AbsoluteRenderTransform.Y + 8;
            rect.Width  -= windowBorder.BorderThickness.Right;
            rect.Height -= 8;
            if (rect.Contains(x, y) == ContainmentType.Contains)
            {
                mouseOffset = new Vector2(rect.X, rect.Y) - new Vector2(x, y);
                state       = DialogWindowState.Drag;
                return;
            }

            // Resize
            var resizeRectBottom = windowBorder.GetBorder(Direction.Bottom);

            resizeRectBottom.X += windowBorder.AbsoluteRenderTransform.X;
            resizeRectBottom.Y += windowBorder.AbsoluteRenderTransform.Y;
            if (resizeRectBottom.Contains(x, y) == ContainmentType.Contains)
            {
#if WINDOWS
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.SizeNS;
#endif
                mouseOffset = new Vector2(resizeRectBottom.X, resizeRectBottom.Y) - new Vector2(x, y);
                state       = DialogWindowState.ResizeY1;
                return;
            }

            var recttop = windowBorder.GetBorder(Direction.Top);
            recttop.X      += windowBorder.AbsoluteRenderTransform.X;
            recttop.Y      += windowBorder.AbsoluteRenderTransform.Y;
            recttop.Width  -= windowBorder.BorderThickness.Right;
            recttop.Height -= 24;
            if (recttop.Contains(x, y) == ContainmentType.Contains)
            {
#if WINDOWS
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.SizeNS;
#endif
                mouseOffset = new Vector2(recttop.X, recttop.Y) - new Vector2(x, y);
                state       = DialogWindowState.ResizeY2;
                return;
            }

            var resizeRectRight = windowBorder.GetBorder(Direction.Right);
            resizeRectRight.X      += windowBorder.AbsoluteRenderTransform.X;
            resizeRectRight.Y      += windowBorder.AbsoluteRenderTransform.Y;
            resizeRectRight.Height -= windowBorder.BorderThickness.Bottom;
            if (resizeRectRight.Contains(x, y) == ContainmentType.Contains)
            {
#if WINDOWS
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.SizeWE;
#endif
                mouseOffset = new Vector2(resizeRectRight.X, resizeRectRight.Y) - new Vector2(x, y);
                state       = DialogWindowState.ResizeX1;
                return;
            }

            var resizeRectLeft = windowBorder.GetBorder(Direction.Left);
            resizeRectLeft.X      += windowBorder.AbsoluteRenderTransform.X;
            resizeRectLeft.Y      += windowBorder.AbsoluteRenderTransform.Y + windowBorder.BorderThickness.Top;
            resizeRectLeft.Height -= windowBorder.BorderThickness.Bottom + windowBorder.BorderThickness.Top;
            if (resizeRectLeft.Contains(x, y) == ContainmentType.Contains)
            {
#if WINDOWS
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.SizeWE;
#endif
                mouseOffset = Vector2.Zero;
                state       = DialogWindowState.ResizeX2;
                return;
            }

            // resize corners
            var rectx1 = new BoundingRectangle()
            {
                X      = windowBorder.AbsoluteRenderTransform.X + windowBorder.RenderSize.X - windowBorder.BorderThickness.Right,
                Y      = windowBorder.AbsoluteRenderTransform.Y + windowBorder.RenderSize.Y - windowBorder.BorderThickness.Bottom,
                Width  = windowBorder.BorderThickness.Right,
                Height = windowBorder.BorderThickness.Bottom,
            };
            if (rectx1.Contains(x, y) == ContainmentType.Contains)
            {
#if WINDOWS
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.SizeNWSE;
#endif
                mouseOffset = Vector2.Zero;
                state       = DialogWindowState.Resize;
                return;
            }

            var rectx2 = new BoundingRectangle()
            {
                X      = windowBorder.AbsoluteRenderTransform.X,
                Y      = windowBorder.AbsoluteRenderTransform.Y + windowBorder.RenderSize.Y - windowBorder.BorderThickness.Bottom,
                Width  = windowBorder.BorderThickness.Left,
                Height = windowBorder.BorderThickness.Bottom,
            };
            if (rectx2.Contains(x, y) == ContainmentType.Contains)
            {
#if WINDOWS
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.SizeNESW;
#endif
                mouseOffset = Vector2.Zero;
                state       = DialogWindowState.Resize;
                return;
            }

            var rectx3 = new BoundingRectangle()
            {
                X      = windowBorder.AbsoluteRenderTransform.X,
                Y      = windowBorder.AbsoluteRenderTransform.Y,
                Width  = windowBorder.BorderThickness.Left,
                Height = windowBorder.BorderThickness.Top,
            };
            if (rectx3.Contains(x, y) == ContainmentType.Contains)
            {
#if WINDOWS
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.SizeNWSE;
#endif
                mouseOffset = Vector2.Zero;
                state       = DialogWindowState.Resize;
                return;
            }

            var rectx4 = new BoundingRectangle()
            {
                X      = windowBorder.AbsoluteRenderTransform.X + windowBorder.RenderSize.X - windowBorder.BorderThickness.Right,
                Y      = windowBorder.AbsoluteRenderTransform.Y,
                Width  = windowBorder.BorderThickness.Left,
                Height = windowBorder.BorderThickness.Top,
            };
            if (rectx4.Contains(x, y) == ContainmentType.Contains)
            {
#if WINDOWS
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.SizeNESW;
#endif
                mouseOffset = Vector2.Zero;
                state       = DialogWindowState.Resize;
                return;
            }
        }
Ejemplo n.º 3
0
 protected internal override void MouseUp(object sender, MouseEventArgs e)
 {
     state = DialogWindowState.Default;
 }