Esempio n. 1
0
        public bool IsAero()
        {
            int num = 0;

            SBNFormController.DwmIsCompositionEnabled(ref num);
            return(num == 1);
        }
Esempio n. 2
0
        protected void CustomProc(ref Message m)
        {
            int msg = m.Msg;

            if (msg <= 15)
            {
                if (msg == 1)
                {
                    this.GetFrameSize();
                    this.FrameChanged();
                    m.Result = SBNFormController.MSG_HANDLED;
                    base.WndProc(ref m);
                    return;
                }
                if (msg != 6)
                {
                    if (msg != 15)
                    {
                        goto IL_316;
                    }
                    SBNFormController.PAINTSTRUCT pAINTSTRUCT = default(SBNFormController.PAINTSTRUCT);
                    if (!this._bPainting)
                    {
                        this._bPainting = true;
                        SBNFormController.BeginPaint(m.HWnd, ref pAINTSTRUCT);
                        this.PaintThis(pAINTSTRUCT.hdc, pAINTSTRUCT.rcPaint);
                        SBNFormController.EndPaint(m.HWnd, ref pAINTSTRUCT);
                        this._bPainting = false;
                        base.WndProc(ref m);
                    }
                    else
                    {
                        base.WndProc(ref m);
                    }
                    return;
                }
            }
            else
            {
                switch (msg)
                {
                case 131:
                    if (m.WParam != IntPtr.Zero && m.Result == IntPtr.Zero)
                    {
                        if (this._bExtendIntoFrame)
                        {
                            SBNFormController.NCCALCSIZE_PARAMS nCCALCSIZE_PARAMS = (SBNFormController.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(SBNFormController.NCCALCSIZE_PARAMS));
                            nCCALCSIZE_PARAMS.rect0.Top = nCCALCSIZE_PARAMS.rect0.Top - ((this._tMargins.cyTopHeight > this.CaptionHeight) ? this.CaptionHeight : this._tMargins.cyTopHeight);
                            nCCALCSIZE_PARAMS.rect1     = nCCALCSIZE_PARAMS.rect0;
                            Marshal.StructureToPtr(nCCALCSIZE_PARAMS, m.LParam, false);
                            m.Result = (IntPtr)1024;
                        }
                        base.WndProc(ref m);
                    }
                    else
                    {
                        base.WndProc(ref m);
                    }
                    return;

                case 132:
                    if (m.Result == (IntPtr)0L)
                    {
                        IntPtr zero = IntPtr.Zero;
                        if (SBNFormController.DwmDefWindowProc(m.HWnd, (uint)m.Msg, m.WParam, m.LParam, ref zero))
                        {
                            m.Result = zero;
                        }
                        else
                        {
                            m.Result = (IntPtr)((long)this.HitTest());
                        }
                    }
                    else
                    {
                        base.WndProc(ref m);
                    }
                    return;

                default:
                    if (msg == 274)
                    {
                        uint num;
                        if (IntPtr.Size == 4)
                        {
                            num = (uint)m.WParam.ToInt32();
                        }
                        else
                        {
                            num = (uint)m.WParam.ToInt64();
                        }
                        if ((num & 65520u) == 61728u)
                        {
                            this.CurrentForm.Height = this._iStoreHeight;
                        }
                        else if (this.CurrentForm.WindowState == FormWindowState.Normal)
                        {
                            this._iStoreHeight = this.CurrentForm.Height;
                        }
                        base.WndProc(ref m);
                        return;
                    }
                    if (msg != 798)
                    {
                        goto IL_316;
                    }
                    break;
                }
            }
            SBNFormController.DwmExtendFrameIntoClientArea(this.CurrentForm.Handle, ref this._tMargins);
            m.Result = SBNFormController.MSG_HANDLED;
            base.WndProc(ref m);
            return;

IL_316:
            base.WndProc(ref m);
        }
Esempio n. 3
0
 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);
                     }
                 }
             }
         }
     }
 }
Esempio n. 4
0
 private void InvalidateWindow()
 {
     SBNFormController.RedrawWindow(this.CurrentForm.Handle, IntPtr.Zero, IntPtr.Zero, 1285u);
 }
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
        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);
        }