protected override IList <JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization) { var properties = base.CreateProperties(type, memberSerialization); var top = properties.Where(property => Top.Contains(property.PropertyName)); var bottom = properties.Where(property => Bottom.Contains(property.PropertyName)); var remaining = properties.Where(property => !top.Contains(property) && !bottom.Contains(property)); return(top.Concat(remaining).Concat(bottom).ToList()); }
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); }
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); }
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; } } }
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); } } }
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; } } }
/// <summary> /// 如果某条边包含这个点,则返回这条边。 /// 否则返回 null。 /// </summary> /// <param name="point"></param> /// <returns></returns> public RectLineDirection?LineContains(Point point) { if (Left.Contains(point)) { return(RectLineDirection.Left); } if (Top.Contains(point)) { return(RectLineDirection.Top); } if (Right.Contains(point)) { return(RectLineDirection.Right); } if (Bottom.Contains(point)) { return(RectLineDirection.Bottom); } return(null); }
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); } }
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; } } }
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); } }