public void CreateRoundedRectangleClip(IntPtr hdc, SBNFormController.RECT cliprect, SBNFormController.RECT canvasrect, uint radius) { this._hDc = hdc; IntPtr intPtr = SBNFormController.ClippingRegion.CreateRoundRectRgn(cliprect.Left, cliprect.Top, cliprect.Right, cliprect.Bottom, (int)radius, (int)radius); IntPtr intPtr2 = SBNFormController.ClippingRegion.CreateRectRgn(canvasrect.Left, canvasrect.Top, canvasrect.Right, canvasrect.Bottom); this._hClipRegion = SBNFormController.ClippingRegion.CreateRoundRectRgn(canvasrect.Left, canvasrect.Top, canvasrect.Right, canvasrect.Bottom, (int)radius, (int)radius); SBNFormController.ClippingRegion.CombineRgn(this._hClipRegion, intPtr2, intPtr, SBNFormController.ClippingRegion.CombineRgnStyles.RGN_DIFF); SBNFormController.ClippingRegion.SelectClipRgn(this._hDc, this._hClipRegion); SBNFormController.ClippingRegion.DeleteObject(intPtr); SBNFormController.ClippingRegion.DeleteObject(intPtr2); }
private void PaintThis(IntPtr hdc, SBNFormController.RECT rc) { SBNFormController.RECT cliprect = default(SBNFormController.RECT); SBNFormController.GetClientRect(this.CurrentForm.Handle, ref cliprect); if (this._bExtendIntoFrame) { cliprect.Left = this._tClientRect.Left - this._tMargins.cxLeftWidth; cliprect.Top = this._tMargins.cyTopHeight; cliprect.Right -= this._tMargins.cxRightWidth; cliprect.Bottom -= this._tMargins.cyBottomHeight; } else if (!this._bPaintWindow) { cliprect.Left = this._tMargins.cxLeftWidth; cliprect.Top = this._tMargins.cyTopHeight; cliprect.Right -= this._tMargins.cxRightWidth; cliprect.Bottom -= this._tMargins.cyBottomHeight; } if (!this._bPaintWindow) { int crColor; IntPtr intPtr; using (new SBNFormController.ClippingRegion(hdc, cliprect, rc)) { if (this.IsAero()) { SBNFormController.FillRect(hdc, ref rc, SBNFormController.GetStockObject(4)); } else { crColor = ColorTranslator.ToWin32(Color.FromArgb(194, 217, 247)); intPtr = SBNFormController.CreateSolidBrush(crColor); SBNFormController.FillRect(hdc, ref cliprect, intPtr); SBNFormController.DeleteObject(intPtr); } } crColor = ColorTranslator.ToWin32(this.CurrentForm.BackColor); intPtr = SBNFormController.CreateSolidBrush(crColor); SBNFormController.FillRect(hdc, ref cliprect, intPtr); SBNFormController.DeleteObject(intPtr); } else { SBNFormController.FillRect(hdc, ref rc, SBNFormController.GetStockObject(4)); } if (this._bExtendIntoFrame && this._bDrawCaption) { Rectangle layoutRect = new Rectangle(4, 4, rc.Right, this.CaptionHeight); using (Graphics graphics = Graphics.FromHdc(hdc)) { using (Font font = new Font("Segoe UI", 12f, FontStyle.Regular)) { SizeF sizeF = graphics.MeasureString(this.CurrentForm.Text, font); int num = (rc.Right - (int)sizeF.Width) / 2; if (num < 2 * this.FrameWidth) { num = 2 * this.FrameWidth; } layoutRect.X = num; layoutRect.Y = 4; using (StringFormat stringFormat = new StringFormat()) { stringFormat.HotkeyPrefix = HotkeyPrefix.None; stringFormat.FormatFlags = StringFormatFlags.NoWrap; stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Near; using (GraphicsPath graphicsPath = new GraphicsPath()) { graphics.SmoothingMode = SmoothingMode.HighQuality; graphicsPath.AddString(this.CurrentForm.Text, font.FontFamily, (int)font.Style, font.Size, layoutRect, stringFormat); graphics.FillPath(Brushes.Black, graphicsPath); } } } } } }
private void FrameChanged() { SBNFormController.RECT rECT = default(SBNFormController.RECT); SBNFormController.GetWindowRect(this.CurrentForm.Handle, ref rECT); SBNFormController.SetWindowPos(this.CurrentForm.Handle, IntPtr.Zero, rECT.Left, rECT.Top, rECT.Right - rECT.Left, rECT.Bottom - rECT.Top, 32u); }
private SBNFormController.HIT_CONSTANTS HitTest() { SBNFormController.RECT rECT = default(SBNFormController.RECT); Point pt = default(Point); SBNFormController.GetCursorPos(ref pt); SBNFormController.GetWindowRect(this.CurrentForm.Handle, ref rECT); pt.X -= rECT.Left; pt.Y -= rECT.Top; int num = rECT.Right - rECT.Left; int num2 = rECT.Bottom - rECT.Top; SBNFormController.RECT rECT2 = new SBNFormController.RECT(0, 0, this.FrameWidth, this.FrameHeight); SBNFormController.HIT_CONSTANTS result; if (SBNFormController.PtInRect(ref rECT2, pt)) { result = SBNFormController.HIT_CONSTANTS.HTTOPLEFT; } else { rECT2 = new SBNFormController.RECT(num - this.FrameWidth, 0, num, this.FrameHeight); if (SBNFormController.PtInRect(ref rECT2, pt)) { result = SBNFormController.HIT_CONSTANTS.HTTOPRIGHT; } else { rECT2 = new SBNFormController.RECT(this.FrameWidth, 0, num - this.FrameWidth * 2 - this._iFrameOffset, this.FrameHeight); if (SBNFormController.PtInRect(ref rECT2, pt)) { result = SBNFormController.HIT_CONSTANTS.HTTOP; } else { rECT2 = new SBNFormController.RECT(this.FrameWidth, this.FrameHeight, num - (this.FrameWidth * 2 + this._iFrameOffset), this._tMargins.cyTopHeight); if (SBNFormController.PtInRect(ref rECT2, pt)) { result = SBNFormController.HIT_CONSTANTS.HTCAPTION; } else { rECT2 = new SBNFormController.RECT(0, this.FrameHeight, this.FrameWidth, num2 - this.FrameHeight); if (SBNFormController.PtInRect(ref rECT2, pt)) { result = SBNFormController.HIT_CONSTANTS.HTLEFT; } else { rECT2 = new SBNFormController.RECT(0, num2 - this.FrameHeight, this.FrameWidth, num2); if (SBNFormController.PtInRect(ref rECT2, pt)) { result = SBNFormController.HIT_CONSTANTS.HTBOTTOMLEFT; } else { rECT2 = new SBNFormController.RECT(this.FrameWidth, num2 - this.FrameHeight, num - this.FrameWidth, num2); if (SBNFormController.PtInRect(ref rECT2, pt)) { result = SBNFormController.HIT_CONSTANTS.HTBOTTOM; } else { rECT2 = new SBNFormController.RECT(num - this.FrameWidth, num2 - this.FrameHeight, num, num2); if (SBNFormController.PtInRect(ref rECT2, pt)) { result = SBNFormController.HIT_CONSTANTS.HTBOTTOMRIGHT; } else { rECT2 = new SBNFormController.RECT(num - this.FrameWidth, this.FrameHeight, num, num2 - this.FrameHeight); if (SBNFormController.PtInRect(ref rECT2, pt)) { result = SBNFormController.HIT_CONSTANTS.HTRIGHT; } else { result = SBNFormController.HIT_CONSTANTS.HTCLIENT; } } } } } } } } } return(result); }
private static extern bool OffsetRect(ref SBNFormController.RECT lprc, int dx, int dy);
private static extern int FillRect(IntPtr hDC, [In] ref SBNFormController.RECT lprc, IntPtr hbr);
private static extern bool GetClientRect(IntPtr hWnd, ref SBNFormController.RECT r);
private static extern bool GetWindowRect(IntPtr hWnd, ref SBNFormController.RECT lpRect);
private static extern bool PtInRect([In] ref SBNFormController.RECT lprc, Point pt);
public ClippingRegion(IntPtr hdc, SBNFormController.RECT cliprect, SBNFormController.RECT canvasrect, uint radius) { this.CreateRoundedRectangleClip(hdc, cliprect, canvasrect, radius); }
public ClippingRegion(IntPtr hdc, SBNFormController.RECT cliprect, SBNFormController.RECT canvasrect) { this.CreateRectangleClip(hdc, cliprect, canvasrect); }