Ejemplo n.º 1
0
            /// <summary>
            /// Checks if specified item is inside this collection.
            /// </summary>
            public bool Contains(T item)
            {
                var bounds = item.Bounds;

                return(TopRight != null && TopRight.Extent.IntersectsWith(bounds) && TopRight.Contains(item) ||
                       TopLeft != null && TopLeft.Extent.IntersectsWith(bounds) && TopLeft.Contains(item) ||
                       BottomRight != null && BottomRight.Extent.IntersectsWith(bounds) && BottomRight.Contains(item) ||
                       BottomLeft != null && BottomLeft.Extent.IntersectsWith(bounds) && BottomLeft.Contains(item) ||
                       ItemsInQuadrant.Contains(item));
            }
Ejemplo n.º 2
0
        public bool ProcessFormMessage(ref Message message)
        {
            if (!AllowToResize || message.Msg != WM_NCHITTEST)
            {
                return(false);
            }

            int x      = (int)(message.LParam.ToInt64() & 0xFFFF);
            int y      = (int)(message.LParam.ToInt64() >> 16);
            var cursor = TargetForm.PointToClient(new Point(x, y));

            if (TopLeft.Contains(cursor))
            {
                message.Result = (IntPtr)HTTOPLEFT;
                return(true);
            }
            else if (TopRight.Contains(cursor))
            {
                message.Result = (IntPtr)HTTOPRIGHT;
                return(true);
            }
            else if (BottomLeft.Contains(cursor))
            {
                message.Result = (IntPtr)HTBOTTOMLEFT;
                return(true);
            }
            else if (BottomRight.Contains(cursor))
            {
                message.Result = (IntPtr)HTBOTTOMRIGHT;
                return(true);
            }
            else if (Top.Contains(cursor))
            {
                message.Result = (IntPtr)HTTOP;
                return(true);
            }
            else if (Left.Contains(cursor))
            {
                message.Result = (IntPtr)HTLEFT;
                return(true);
            }
            else if (Right.Contains(cursor))
            {
                message.Result = (IntPtr)HTRIGHT;
                return(true);
            }
            else if (Bottom.Contains(cursor))
            {
                message.Result = (IntPtr)HTBOTTOM;
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        public override UIElement OnMouseAction(MouseActionEventArgs mouse)
        {
            UIElement intercept = base.OnMouseAction(mouse);

            if (intercept == null && FrameDimensions.Contains(mouse.Position))
            {
                intercept = this;

                if (ResizeableByUser && mouse.Button == MouseButton.Left && mouse.Action == MouseAction.Pressed)
                {
                    if (TopLeft.Contains(mouse.Position))
                    {
                        EdgeCaught = Edge.TopLeft;
                    }
                    else if (Top.Contains(mouse.Position))
                    {
                        EdgeCaught = Edge.Top;
                    }
                    else if (TopRight.Contains(mouse.Position))
                    {
                        EdgeCaught = Edge.TopRight;
                    }
                    else if (MiddleLeft.Contains(mouse.Position))
                    {
                        EdgeCaught = Edge.Left;
                    }
                    else if (MiddleRight.Contains(mouse.Position))
                    {
                        EdgeCaught = Edge.Right;
                    }
                    else if (BottomLeft.Contains(mouse.Position))
                    {
                        EdgeCaught = Edge.BottomLeft;
                    }
                    else if (Bottom.Contains(mouse.Position))
                    {
                        EdgeCaught = Edge.Bottom;
                    }
                    else if (BottomRight.Contains(mouse.Position))
                    {
                        EdgeCaught = Edge.BottomRight;
                    }
                }
            }

            if (mouse.Button == MouseButton.Left && mouse.Action == MouseAction.Released)
            {
                EdgeCaught = Edge.None;
            }

            return(intercept);
        }
Ejemplo n.º 4
0
        protected override void WndProc(ref Message message)
        {
            base.WndProc(ref message);

            if (message.Msg == WM_NCHITTEST && CanResize && WindowState == FormWindowState.Normal)
            {
                int x = message.LParam.ToInt32() & 0xffff;
                int y = (int)((message.LParam.ToInt32() & 0xffff0000) >> 16);

                Point cursor = PointToClient(new Point(x, y));

                //  var cursor = this.PointToClient(Cursor.Position);

                if (TopLeft.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOPLEFT;
                }
                else if (TopRight.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOPRIGHT;
                }
                else if (BottomLeft.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOMLEFT;
                }
                else if (BottomRight.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOMRIGHT;
                }

                else if (Top.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOP;
                }
                else if (Left.Contains(cursor))
                {
                    message.Result = (IntPtr)HTLEFT;
                }
                else if (Right.Contains(cursor))
                {
                    message.Result = (IntPtr)HTRIGHT;
                }
                else if (Bottom.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOM;
                }
            }
        }
Ejemplo n.º 5
0
        protected override void WndProc(ref Message message)
        {
            base.WndProc(ref message);


            if (message.Msg == 0x84) // WM_NCHITTEST
            {
                var cursor = this.PointToClient(Cursor.Position);

                if (TopLeft.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOPLEFT;
                }
                else if (TopRight.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOPRIGHT;
                }
                else if (BottomLeft.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOMLEFT;
                }
                else if (BottomRight.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOMRIGHT;
                }

                else if (Top.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOP;
                }
                else if (Left.Contains(cursor))
                {
                    message.Result = (IntPtr)HTLEFT;
                }
                else if (Right.Contains(cursor))
                {
                    message.Result = (IntPtr)HTRIGHT;
                }
                else if (Bottom.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOM;
                }
                else
                {
                    message.Result = (IntPtr)(HT_CAPTION);
                }
            }
        }
Ejemplo n.º 6
0
        protected override void WndProc(ref Message message)
        {
            base.WndProc(ref message);

            if (message.Msg == 0x84)
            {
                var cp     = MousePosition;
                var cursor = this.PointToClient(cp);

                if (TopLeft.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOPLEFT;
                }
                else if (TopRight.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOPRIGHT;
                }
                else if (BottomLeft.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOMLEFT;
                }
                else if (BottomRight.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOMRIGHT;
                }

                else if (TopBorder.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOP;
                }
                else if (LeftBorder.Contains(cursor))
                {
                    message.Result = (IntPtr)HTLEFT;
                }
                else if (RightBorder.Contains(cursor))
                {
                    message.Result = (IntPtr)HTRIGHT;
                }
                else if (BottomBorder.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOM;
                }
            }
        }
Ejemplo n.º 7
0
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);

            if (m.Msg == 0x84)
            {
                var cursor = this.PointToClient(Cursor.Position);

                if (TopLeft.Contains(cursor))
                {
                    m.Result = (IntPtr)HTTOPLEFT;
                }
                else if (TopRight.Contains(cursor))
                {
                    m.Result = (IntPtr)HTTOPRIGHT;
                }
                else if (BottomLeft.Contains(cursor))
                {
                    m.Result = (IntPtr)HTBOTTOMLEFT;
                }
                else if (BottomRight.Contains(cursor))
                {
                    m.Result = (IntPtr)HTBOTTOMRIGHT;
                }

                else if (Top.Contains(cursor))
                {
                    m.Result = (IntPtr)HTTOP;
                }
                else if (Left.Contains(cursor))
                {
                    m.Result = (IntPtr)HTLEFT;
                }
                else if (Right.Contains(cursor))
                {
                    m.Result = (IntPtr)HTRIGHT;
                }
                else if (Bottom.Contains(cursor))
                {
                    m.Result = (IntPtr)HTBOTTOM;
                }
            }
        }
Ejemplo n.º 8
0
        public void WndProc(ref Message message)
        {
            if (message.Msg == 0x84) // WM_NCHITTEST
            {
                var cursor = _parent.PointToClient(Cursor.Position);

                if (TopLeft.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOPLEFT;
                }
                else if (TopRight.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOPRIGHT;
                }
                else if (BottomLeft.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOMLEFT;
                }
                else if (BottomRight.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOMRIGHT;
                }

                else if (Top.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOP;
                }
                else if (Left.Contains(cursor))
                {
                    message.Result = (IntPtr)HTLEFT;
                }
                else if (Right.Contains(cursor))
                {
                    message.Result = (IntPtr)HTRIGHT;
                }
                else if (Bottom.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOM;
                }
            }
        }
        protected override void WndProc(ref Message message)
        {
            try
            {
                if (message.Msg == WM_SYSCOMMAND && (message.WParam.ToInt32() & 0xfff0) == SC_SIZE)
                {
                    if (FormResizable)
                    {
                        GetSystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, out int isDragFullWindow, 0);

                        if (isDragFullWindow != 0)
                        {
                            SetSystemParametersInfo(SPI_SETDRAGFULLWINDOWS, 0, 0, 0);
                        }

                        base.WndProc(ref message);

                        if (isDragFullWindow != 0)
                        {
                            SetSystemParametersInfo(SPI_SETDRAGFULLWINDOWS, 1, 0, 0);
                        }
                    }
                }
                else
                {
                    if (message.Msg == 0x84) // WM_NCHITTEST
                    {
                        if (FormResizable)
                        {
                            // Always add grid styles regardless of border type

                            var cursor = PointToClient(Cursor.Position);

                            if (TopLeft.Contains(cursor))
                            {
                                message.Result = (IntPtr)HTTOPLEFT;
                            }
                            else if (TopRight.Contains(cursor))
                            {
                                message.Result = (IntPtr)HTTOPRIGHT;
                            }
                            else if (BottomLeft.Contains(cursor))
                            {
                                message.Result = (IntPtr)HTBOTTOMLEFT;
                            }
                            else if (BottomRight.Contains(cursor))
                            {
                                message.Result = (IntPtr)HTBOTTOMRIGHT;
                            }
                            else if (Top.Contains(cursor))
                            {
                                message.Result = (IntPtr)HTTOP;
                            }
                            else if (Left.Contains(cursor))
                            {
                                message.Result = (IntPtr)HTLEFT;
                            }
                            else if (Right.Contains(cursor))
                            {
                                message.Result = (IntPtr)HTRIGHT;
                            }
                            else if (Bottom.Contains(cursor))
                            {
                                message.Result = (IntPtr)HTBOTTOM;
                            }
                        }
                        else
                        {
                            Cursor.Current = Cursors.Arrow;
                            message.Result = (IntPtr)1;  // Processed6
                            return;
                        }
                    }

                    base.WndProc(ref message);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(
                    "The application encountered a fatal error and must be restarted. Please contact the service desk with this message: " +
                    e.Message, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 10
0
        protected override void WndProc(ref Message message)
        {
            switch (message.Msg)
            {
            // box shadow
            case WM_NCPAINT:
                if (m_aeroEnabled)
                {
                    var v = 2;
                    DwmSetWindowAttribute(this.Handle, 2, ref v, 4);
                    MARGINS margins = new MARGINS()
                    {
                        bottomHeight = 1,
                        leftWidth    = 1,
                        rightWidth   = 1,
                        topHeight    = 1
                    };
                    DwmExtendFrameIntoClientArea(this.Handle, ref margins);
                }
                break;

            default:
                break;
            }

            base.WndProc(ref message);

            if (message.Msg == 0x84) // WM_NCHITTEST
            {
                var cursor = this.PointToClient(Cursor.Position);

                if (TopLeft.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOPLEFT;
                }
                else if (TopRight.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOPRIGHT;
                }
                else if (BottomLeft.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOMLEFT;
                }
                else if (BottomRight.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOMRIGHT;
                }

                else if (Top.Contains(cursor))
                {
                    message.Result = (IntPtr)HTTOP;
                }
                else if (Left.Contains(cursor))
                {
                    message.Result = (IntPtr)HTLEFT;
                }
                else if (Right.Contains(cursor))
                {
                    message.Result = (IntPtr)HTRIGHT;
                }
                else if (Bottom.Contains(cursor))
                {
                    message.Result = (IntPtr)HTBOTTOM;
                }
            }
        }
Ejemplo n.º 11
0
        protected override void WndProc(ref Message message)
        {
            try
            {
                if (message.Msg == WM_SYSCOMMAND && (message.WParam.ToInt32() & 0xfff0) == SC_SIZE)
                {
                    int isDragFullWindow;
                    GetSystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, out isDragFullWindow, 0);

                    if (isDragFullWindow != 0)
                    {
                        SetSystemParametersInfo(SPI_SETDRAGFULLWINDOWS, 0, 0, 0);
                    }

                    base.WndProc(ref message);

                    if (isDragFullWindow != 0)
                    {
                        SetSystemParametersInfo(SPI_SETDRAGFULLWINDOWS, 1, 0, 0);
                    }
                }
                else
                {
                    base.WndProc(ref message);

                    if (message.Msg == 0x84) // WM_NCHITTEST
                    {
                        var cursor = PointToClient(Cursor.Position);

                        if (TopLeft.Contains(cursor))
                        {
                            message.Result = (IntPtr)HTTOPLEFT;
                        }
                        else if (TopRight.Contains(cursor))
                        {
                            message.Result = (IntPtr)HTTOPRIGHT;
                        }
                        else if (BottomLeft.Contains(cursor))
                        {
                            message.Result = (IntPtr)HTBOTTOMLEFT;
                        }
                        else if (BottomRight.Contains(cursor))
                        {
                            message.Result = (IntPtr)HTBOTTOMRIGHT;
                        }

                        else if (Top.Contains(cursor))
                        {
                            message.Result = (IntPtr)HTTOP;
                        }
                        else if (Left.Contains(cursor))
                        {
                            message.Result = (IntPtr)HTLEFT;
                        }
                        else if (Right.Contains(cursor))
                        {
                            message.Result = (IntPtr)HTRIGHT;
                        }
                        else if (Bottom.Contains(cursor))
                        {
                            message.Result = (IntPtr)HTBOTTOM;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(
                    "Google Geolocation encountered a fatal error and must be restarted. Please contact support with this message: " +
                    e.Message, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }