コード例 #1
0
        private void PaintGrabHandleButtons(ItemPaintArgs pa, ref Rectangle targetRect)
        {
            RenderBarEventArgs re = null;
            if (this.CanHideResolved)
            {
                if (this.Style == eDotNetBarStyle.Office2000)
                    m_SystemButtons.CloseButtonRect = new Rectangle(targetRect.Right - 11, targetRect.Y + (targetRect.Height - m_SystemButtons.ButtonSize.Width) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
                else
                    m_SystemButtons.CloseButtonRect = new Rectangle(targetRect.Right - (m_SystemButtons.ButtonSize.Width + 1), targetRect.Y + (targetRect.Height - m_SystemButtons.ButtonSize.Height) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
                re = new RenderBarEventArgs(this, pa.Graphics, eBarRenderPart.CloseButton, m_SystemButtons.CloseButtonRect);
                OnPreRender(re);
                m_SystemButtons.CloseButtonRect = re.Bounds;
                targetRect.Width -= (m_SystemButtons.CloseButtonRect.Width + 3);
                if (!re.Cancel)
                    PaintCloseButton(pa);
            }
            if (GetPaintAutoHidePin())
            {
                if (this.Style == eDotNetBarStyle.Office2000)
                    m_SystemButtons.AutoHideButtonRect = new Rectangle(targetRect.Right - (m_SystemButtons.ButtonSize.Width - 1), targetRect.Y + (targetRect.Height - m_SystemButtons.ButtonSize.Height) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
                else
                    m_SystemButtons.AutoHideButtonRect = new Rectangle(targetRect.Right - (m_SystemButtons.ButtonSize.Width + 1), targetRect.Y + (targetRect.Height - m_SystemButtons.ButtonSize.Height) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
                re = new RenderBarEventArgs(this, pa.Graphics, eBarRenderPart.AutoHideButton, m_SystemButtons.AutoHideButtonRect);
                OnPreRender(re);
                m_SystemButtons.AutoHideButtonRect = re.Bounds;
                targetRect.Width -= (m_SystemButtons.AutoHideButtonRect.Width + 3);
                if (!re.Cancel)
                    PaintAutoHideButton(pa);
            }
            if (this.ShowCustomizeMenuButton)
            {
                re = new RenderBarEventArgs(this, pa.Graphics, eBarRenderPart.CustomizeButton, Rectangle.Empty);

                if (this.Style == eDotNetBarStyle.Office2000)
                {
                    m_SystemButtons.CustomizeButtonRect = new Rectangle(targetRect.X, targetRect.Y + (targetRect.Height - m_SystemButtons.ButtonSize.Height) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
                    re.Bounds = m_SystemButtons.CustomizeButtonRect;
                    OnPreRender(re);
                    m_SystemButtons.CustomizeButtonRect = re.Bounds;
                    targetRect.Width -= (m_SystemButtons.CustomizeButtonRect.Width + 2);
                    targetRect.X += (m_SystemButtons.CustomizeButtonRect.Width + 2);
                }
                else
                {
                    m_SystemButtons.CustomizeButtonRect = new Rectangle(targetRect.Right - (m_SystemButtons.ButtonSize.Width + 1), targetRect.Y + (targetRect.Height - m_SystemButtons.ButtonSize.Height) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
                    re.Bounds = m_SystemButtons.CustomizeButtonRect;
                    OnPreRender(re);
                    m_SystemButtons.CustomizeButtonRect = re.Bounds;
                    targetRect.Width -= (m_SystemButtons.CustomizeButtonRect.Width + 2);
                }

                if (!re.Cancel)
                    PaintCustomizeButton(pa);
            }

            if (this.GrabHandleStyle == eGrabHandleStyle.CaptionTaskPane)
            {
                targetRect.X += 2;
                targetRect.Width -= 2;
                targetRect.Inflate(0, -2);
                m_SystemButtons.CaptionButtonRect = targetRect;
                re = new RenderBarEventArgs(this, pa.Graphics, eBarRenderPart.CaptionTaskPane, m_SystemButtons.CaptionButtonRect);
                OnPreRender(re);
                m_SystemButtons.CaptionButtonRect = re.Bounds;
                if (!re.Cancel)
                    PaintCaptionButton(pa);
            }

            targetRect.X += 2;
            targetRect.Width -= 2;
        }
コード例 #2
0
 private void PaintCaptionText(ItemPaintArgs pa, Rectangle targetRect)
 {
     Graphics g = pa.Graphics;
     RenderBarEventArgs re = new RenderBarEventArgs(this, g, eBarRenderPart.CaptionText, targetRect);
     OnPreRender(re);
     if (re.Cancel) return;
     System.Drawing.Font objFont = null;
     bool bDisposeFont = false;
     try
     {
         objFont = this.Font.Clone() as Font; //new Font(this.Font.Name, 8);
         bDisposeFont = true;
     }
     catch
     {
         objFont = SystemFonts.MenuFont; // System.Windows.Forms.SystemInformation.MenuFont;
         bDisposeFont = true;
     }
     eTextFormat sf = eTextFormat.Default | eTextFormat.SingleLine | eTextFormat.EndEllipsis | eTextFormat.VerticalCenter;
     if (m_CaptionForeColor.IsEmpty)
     {
         if (this.IsThemed)
         {
             if (targetRect.Height < objFont.Height)
                 targetRect.Height = objFont.Height;
             if (targetRect.Width > 0)
             {
                 if (!m_HasFocus)
                     TextDrawing.DrawString(g, this.Text, objFont, SystemColors.WindowText, targetRect, sf);
                 else
                     TextDrawing.DrawString(g, this.Text, objFont, SystemColors.ActiveCaptionText, targetRect, sf);
             }
         }
         else
         {
             if (targetRect.Height < objFont.Height)
                 targetRect.Height = objFont.Height;
             if (targetRect.Width > 0)
             {
                 Color textColor = pa.Colors.BarCaptionText;
                 if (m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
                     textColor = pa.Colors.ItemText;
                 else if ((this.Style == eDotNetBarStyle.OfficeXP || this.Style == eDotNetBarStyle.Office2003 || this.Style == eDotNetBarStyle.VS2005 || BarFunctions.IsOffice2007Style(this.Style)) && !m_HasFocus)
                     textColor = pa.Colors.BarCaptionInactiveText;
                 TextDrawing.DrawString(g, this.Text, objFont, textColor, targetRect, sf);
             }
         }
     }
     else if (targetRect.Width > 0)
         TextDrawing.DrawString(g, this.Text, objFont, m_CaptionForeColor, targetRect, sf);
     if (bDisposeFont)
         objFont.Dispose();
 }
コード例 #3
0
 /// <summary>
 /// Raises the PostRender event.
 /// </summary>
 /// <param name="e">Provides the event arguments</param>
 protected virtual void OnPostRender(RenderBarEventArgs e)
 {
     if (PostRender != null)
         PostRender(this, e);
 }
コード例 #4
0
        /// <summary>
        /// Drawns bar grab handle if one specified.
        /// </summary>
        /// <param name="pa">Context information.</param>
        internal void PaintGrabHandle(ItemPaintArgs pa)
        {
            RenderBarEventArgs re = null;
            Graphics g = pa.Graphics;
            // Draw grab handles
            if (m_GrabHandleStyle != eGrabHandleStyle.None)
            {
                Rectangle r = Rectangle.Empty;

                if (m_GrabHandleStyle != eGrabHandleStyle.Caption && m_GrabHandleStyle != eGrabHandleStyle.CaptionTaskPane && m_GrabHandleStyle != eGrabHandleStyle.CaptionDotted && this.IsThemed && m_GrabHandleStyle != eGrabHandleStyle.ResizeHandle)
                {
                    ThemeRebar theme = this.ThemeRebar;
                    ThemeRebarParts part = ThemeRebarParts.Gripper;

                    if (m_ItemContainer.Orientation == eOrientation.Vertical)
                    {
                        part = ThemeRebarParts.GripperVert;
                        r = new Rectangle(m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + 2, m_GrabHandleRect.Width - 4, 5);
                    }
                    else
                        r = new Rectangle(m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + 2, 5, m_GrabHandleRect.Height - 4);
                    re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, r);
                    OnPreRender(re);
                    r = re.Bounds;
                    if (!re.Cancel)
                        theme.DrawBackground(g, part, ThemeRebarStates.Normal, r);
                    return;
                }

                Color clr = pa.Colors.BarBackground;
                if (!m_ItemContainer.m_BackgroundColor.IsEmpty)
                    clr = m_ItemContainer.m_BackgroundColor;

                switch (m_GrabHandleStyle)
                {
                    case eGrabHandleStyle.Single:
                        {
                            if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
                            {
                                r = new Rectangle(m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + 2, 3, m_GrabHandleRect.Height - 4);
                                re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, r);
                                OnPreRender(re);
                                if (!re.Cancel)
                                    BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.All, clr);
                            }
                            else
                            {
                                r = new Rectangle(m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + 2, m_GrabHandleRect.Width - 4, 3);
                                re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, r);
                                OnPreRender(re);
                                if (!re.Cancel)
                                    BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.All, clr);
                            }
                            break;
                        }
                    case eGrabHandleStyle.Double:
                        {
                            if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
                            {
                                r = new Rectangle(m_GrabHandleRect.X + 1, m_GrabHandleRect.Top + 1, 3, m_GrabHandleRect.Height - 2);
                                BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.All, clr);
                                r.Offset(3, 0);
                                re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, r);
                                OnPreRender(re);
                                if (!re.Cancel)
                                    BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.All, clr);
                            }
                            else
                            {
                                r = new Rectangle(m_GrabHandleRect.X + 1, m_GrabHandleRect.Top + 1, m_GrabHandleRect.Width - 2, 3);
                                BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.All, clr);
                                r.Offset(0, 3);
                                re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, r);
                                OnPreRender(re);
                                if (!re.Cancel)
                                    BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.All, clr);
                            }
                            break;
                        }
                    case eGrabHandleStyle.DoubleThin:
                        {
                            if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
                            {
                                r = new Rectangle(m_GrabHandleRect.X + 1, m_GrabHandleRect.Top + 2, 3, m_GrabHandleRect.Height - 4);
                                BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.Left | System.Windows.Forms.Border3DSide.Right, clr);
                                r.Offset(3, 0);
                                re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, r);
                                OnPreRender(re);
                                if (!re.Cancel)
                                    BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.Left | System.Windows.Forms.Border3DSide.Right, clr);
                            }
                            else
                            {
                                r = new Rectangle(m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + 1, m_GrabHandleRect.Width - 4, 2);
                                BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.Top | System.Windows.Forms.Border3DSide.Bottom, clr);
                                r.Offset(0, 3);
                                re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, r);
                                OnPreRender(re);
                                if (!re.Cancel)
                                    BarFunctions.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.Top | System.Windows.Forms.Border3DSide.Bottom, clr);
                            }
                            break;
                        }
                    case eGrabHandleStyle.DoubleFlat:
                        {
                            re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, m_GrabHandleRect);
                            OnPreRender(re);
                            if (!re.Cancel)
                            {
                                Pen pen = new Pen(ControlPaint.Dark(clr), 1);
                                if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
                                {
                                    g.DrawLine(/*SystemPens.ControlDark*/pen, m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + 2, m_GrabHandleRect.X + 2, m_GrabHandleRect.Height - 4);
                                    g.DrawLine(/*SystemPens.ControlDark*/pen, m_GrabHandleRect.X + 5, m_GrabHandleRect.Top + 2, m_GrabHandleRect.X + 5, m_GrabHandleRect.Height - 4);
                                }
                                else
                                {
                                    g.DrawLine(pen, m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + 2, m_GrabHandleRect.Width - 4, m_GrabHandleRect.Y + 2);
                                    g.DrawLine(pen, m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + 5, m_GrabHandleRect.Width - 4, m_GrabHandleRect.Y + 5);
                                }
                                pen.Dispose();
                                pen = null;
                            }
                            break;
                        }
                    case eGrabHandleStyle.Dotted:
                        {
                            re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, m_GrabHandleRect);
                            OnPreRender(re);
                            if (!re.Cancel)
                            {
                                Brush brushDark = new SolidBrush(ControlPaint.Dark(clr));
                                Brush brushLight = new SolidBrush(ControlPaint.Light(clr));
                                if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
                                {
                                    for (int i = 0; i < (m_GrabHandleRect.Height - 4); i += 4)
                                    {
                                        g.FillRectangle(/*SystemBrushes.ControlDark*/brushDark, m_GrabHandleRect.X + 1, m_GrabHandleRect.Top + 2 + i, 2, 2);
                                        g.FillRectangle(/*SystemBrushes.ControlLight*/brushLight, m_GrabHandleRect.X + 1, m_GrabHandleRect.Top + 2 + i, 1, 1);

                                        g.FillRectangle(brushDark, m_GrabHandleRect.X + 5, m_GrabHandleRect.Top + 2 + i, 2, 2);
                                        g.FillRectangle(brushLight, m_GrabHandleRect.X + 5, m_GrabHandleRect.Top + 2 + i, 1, 1);
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < (m_GrabHandleRect.Width - 4); i += 4)
                                    {
                                        g.FillRectangle(SystemBrushes.ControlDark, m_GrabHandleRect.Left + 2 + i, m_GrabHandleRect.Y + 1, 2, 2);
                                        g.FillRectangle(SystemBrushes.ControlLight, m_GrabHandleRect.Left + 2 + i, m_GrabHandleRect.Y + 1, 1, 1);

                                        g.FillRectangle(SystemBrushes.ControlDark, m_GrabHandleRect.Left + 2 + i, m_GrabHandleRect.Y + 5, 2, 2);
                                        g.FillRectangle(SystemBrushes.ControlLight, m_GrabHandleRect.Left + 2 + i, m_GrabHandleRect.Y + 5, 1, 1);
                                    }
                                }
                                brushDark.Dispose();
                                brushLight.Dispose();
                            }
                            break;
                        }
                    case eGrabHandleStyle.Stripe:
                        {
                            re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, m_GrabHandleRect);
                            OnPreRender(re);
                            if (!re.Cancel)
                            {
                                if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
                                {
                                    for (int i = 0; i < (m_GrabHandleRect.Height - 4); i += 3)
                                        BarFunctions.DrawBorder3D(g, m_GrabHandleRect.X + 2, m_GrabHandleRect.Top + i + 2, 5, 2, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.Top | System.Windows.Forms.Border3DSide.Bottom, clr);
                                    //System.Windows.Forms.ControlPaint.DrawBorder3D(g,m_GrabHandleRect.X+2,m_GrabHandleRect.Top+i+2,5,2,System.Windows.Forms.Border3DStyle.RaisedInner,System.Windows.Forms.Border3DSide.Top | System.Windows.Forms.Border3DSide.Bottom);
                                }
                                else
                                {
                                    for (int i = 0; i < (m_GrabHandleRect.Width - 4); i += 3)
                                        BarFunctions.DrawBorder3D(g, m_GrabHandleRect.Left + i + 2, m_GrabHandleRect.Y + 2, 2, 5, System.Windows.Forms.Border3DStyle.RaisedInner, System.Windows.Forms.Border3DSide.Right | System.Windows.Forms.Border3DSide.Left, clr);
                                    //System.Windows.Forms.ControlPaint.DrawBorder3D(g,m_GrabHandleRect.Left+i+2,m_GrabHandleRect.Y+2,2,5,System.Windows.Forms.Border3DStyle.RaisedInner,System.Windows.Forms.Border3DSide.Right | System.Windows.Forms.Border3DSide.Left);
                                }
                            }
                            break;
                        }
                    case eGrabHandleStyle.StripeFlat:
                        {
                            re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, m_GrabHandleRect);
                            OnPreRender(re);
                            if (!re.Cancel)
                            {
                                Pen pen = new Pen(pa.Colors.BarStripeColor/*ControlPaint.Dark(clr)*/, 1);
                                if (m_ItemContainer.Orientation == eOrientation.Horizontal && m_ItemContainer.LayoutType != eLayoutType.DockContainer)
                                {
                                    for (int i = 2; i < (m_GrabHandleRect.Height - 6); i += 2)
                                        g.DrawLine(/*SystemPens.ControlDark*/pen, m_GrabHandleRect.X + 3, m_GrabHandleRect.Top + i + 3, m_GrabHandleRect.X + 5, m_GrabHandleRect.Top + i + 3);
                                }
                                else
                                {
                                    for (int i = 1; i < (m_GrabHandleRect.Width - 6); i += 2)
                                        g.DrawLine(/*SystemPens.ControlDark*/pen, m_GrabHandleRect.Left + i + 3, m_GrabHandleRect.Y + 2, m_GrabHandleRect.Left + i + 3, m_GrabHandleRect.Y + 5);
                                }
                                pen.Dispose();
                            }
                            break;
                        }
                    case eGrabHandleStyle.CaptionTaskPane:
                    case eGrabHandleStyle.CaptionDotted:
                        {
                            Rectangle targetRect = m_GrabHandleRect;
                            Brush brush = null;
                            re = new RenderBarEventArgs(this, g, eBarRenderPart.Caption, m_GrabHandleRect);
                            OnPreRender(re);
                            if (!re.Cancel)
                            {
                                if (m_BarState == eBarState.Floating)
                                {
                                    DisplayHelp.FillRectangle(g, targetRect, pa.Colors.BarCaptionBackground, pa.Colors.BarCaptionBackground2, pa.Colors.BarCaptionBackgroundGradientAngle);
                                }
                                else
                                {
                                    if (!this.CaptionBackColor.IsEmpty)
                                        brush = new SolidBrush(this.CaptionBackColor);
                                    if (pa.Colors.BarBackground2.IsEmpty)
                                    {
                                        if (m_HasFocus && m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
                                            brush = new SolidBrush(pa.Colors.BarCaptionBackground);
                                        else
                                            brush = new SolidBrush(pa.Colors.BarBackground);
                                    }
                                    else
                                    {
                                        brush = BarFunctions.CreateLinearGradientBrush(targetRect, pa.Colors.BarBackground, pa.Colors.BarBackground2, pa.Colors.BarBackgroundGradientAngle);
                                    }

                                    g.FillRectangle(brush, targetRect);

                                    brush.Dispose();
                                    brush = null;
                                }

                                Brush brushDark = null;
                                Brush brushLight = new SolidBrush(ControlPaint.Light(clr));

                                if (!pa.Colors.BarStripeColor.IsEmpty)
                                {
                                    clr = pa.Colors.BarStripeColor;
                                    brushDark = new SolidBrush(clr);
                                }
                                else
                                    brushDark = new SolidBrush(ControlPaint.Dark(clr));
                                int y = m_GrabHandleRect.Top + 4;
                                int x = m_GrabHandleRect.Left + 4;
                                for (int i = y; i <= m_GrabHandleRect.Bottom - 4; i += 5)
                                {
                                    g.FillRectangle(brushLight, x + 1, i + 1, 2, 2);
                                    g.FillRectangle(brushDark, x, i, 2, 2);
                                }
                                if (brushLight != null) brushLight.Dispose();
                                if (brushDark != null) brushDark.Dispose();
                            }

                            targetRect.X += 8;
                            targetRect.Width -= 8;

                            targetRect.Inflate(-1, -1);
                            PaintGrabHandleButtons(pa, ref targetRect);
                            if (m_GrabHandleStyle == eGrabHandleStyle.CaptionDotted)
                                PaintCaptionText(pa, targetRect);
                            break;
                        }
                    case eGrabHandleStyle.Caption:
                        {
                            Rectangle targetRect = m_GrabHandleRect;
                            re = new RenderBarEventArgs(this, g, eBarRenderPart.Caption, m_GrabHandleRect);
                            OnPreRender(re);
                            if (!re.Cancel)
                            {
                                ThemeWindow theme = null;
                                ThemeWindowParts part = ThemeWindowParts.SmallCaption;
                                ThemeWindowStates state = ThemeWindowStates.CaptionInactive;
                                if (this.DrawThemedCaption)
                                    theme = this.ThemeWindow;

                                if (m_DockedBorder == eBorderType.None)
                                    targetRect.Inflate(-1, 0);
                                if (m_CaptionBackColor.IsEmpty)
                                {
                                    if (this.Style == eDotNetBarStyle.Office2000)
                                    {
                                        if (m_HasFocus)
                                            g.FillRectangle(SystemBrushes.ActiveCaption, targetRect);
                                        else
                                            g.FillRectangle(SystemBrushes.InactiveCaption, targetRect);
                                    }
                                    else
                                    {
                                        if (this.DrawThemedCaption)
                                        {
                                            if (m_HasFocus)
                                                state = ThemeWindowStates.CaptionActive;
                                            theme.DrawBackground(g, part, state, targetRect);
                                        }
                                        else
                                        {
                                            if (m_HasFocus)
                                            {
                                                if (pa.Colors.BarCaptionBackground2.IsEmpty)
                                                    DisplayHelp.FillRectangle(g, targetRect, pa.Colors.BarCaptionBackground);
                                                else
                                                {
                                                    using (System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(targetRect, pa.Colors.BarCaptionBackground, pa.Colors.BarCaptionBackground2, pa.Colors.BarCaptionBackgroundGradientAngle))
                                                        g.FillRectangle(gradient, targetRect);
                                                }
                                            }
                                            else
                                            {
                                                if (pa.Colors.BarCaptionInactiveBackground2.IsEmpty)
                                                    DisplayHelp.FillRectangle(g, targetRect, pa.Colors.BarCaptionInactiveBackground);
                                                else
                                                {
                                                    using (System.Drawing.Drawing2D.LinearGradientBrush brush = BarFunctions.CreateLinearGradientBrush(targetRect, pa.Colors.BarCaptionInactiveBackground, pa.Colors.BarCaptionInactiveBackground2, pa.Colors.BarCaptionInactiveBackgroundGAngle))
                                                    {
                                                        g.FillRectangle(brush, targetRect);
                                                    }
                                                }

                                                eDotNetBarStyle effectiveStyle = m_ItemContainer.EffectiveStyle;
                                                if (effectiveStyle != eDotNetBarStyle.VS2005 && effectiveStyle != eDotNetBarStyle.Office2010 && effectiveStyle != eDotNetBarStyle.Metro)
                                                {
                                                    Pen penCap = new Pen(pa.Colors.BarCaptionBackground, 1);
                                                    g.DrawLine(penCap, targetRect.X + 1, targetRect.Y, targetRect.Right - 2, targetRect.Y);
                                                    g.DrawLine(penCap, targetRect.X + 1, targetRect.Bottom - 1, targetRect.Right - 2, targetRect.Bottom - 1);
                                                    g.DrawLine(penCap, targetRect.X, targetRect.Y + 1, targetRect.X, targetRect.Bottom - 2);
                                                    g.DrawLine(penCap, targetRect.Right - 1, targetRect.Y + 1, targetRect.Right - 1, targetRect.Bottom - 2);
                                                    penCap.Dispose();
                                                }
                                            }
                                        }
                                    }
                                }
                                else
                                    DisplayHelp.FillRectangle(g, targetRect, m_CaptionBackColor);
                            }

                            targetRect.Inflate(-1, -1);

                            PaintGrabHandleButtons(pa, ref targetRect);

                            PaintCaptionText(pa, targetRect);
                            break;
                        }
                    case eGrabHandleStyle.ResizeHandle:
                        {
                            re = new RenderBarEventArgs(this, g, eBarRenderPart.ResizeHandle, m_GrabHandleRect);
                            OnPreRender(re);
                            if (!re.Cancel && m_ItemContainer.EffectiveStyle != eDotNetBarStyle.Metro)
                            {
                                // Paint Internet Explorer-style dotted sizer in lower right
                                // draw light 'shadows'
                                Form form = this.FindForm();
                                if (form != null && form.WindowState == FormWindowState.Maximized)
                                    break;
                                int direction = 1;
                                Point startLoc = new Point(this.ClientRectangle.Right, this.ClientRectangle.Bottom);
                                if (this.RightToLeft == RightToLeft.Yes)
                                {
                                    direction = -1;
                                    startLoc = new Point(0, this.ClientRectangle.Bottom - 2);
                                }
                                ColorFunctions.HLSColor hls = ColorFunctions.RGBToHSL(clr);
                                Color lightColor = ColorFunctions.HLSToRGB(hls.Hue, hls.Lightness + .3d, hls.Saturation);
                                Pen pen = new Pen(lightColor, 1);
                                g.DrawLine(pen, startLoc.X - 2 * direction, startLoc.Y - 2,
                                    startLoc.X - 3 * direction, startLoc.Y - 2);
                                g.DrawLine(pen, startLoc.X - 6 * direction, startLoc.Y - 2,
                                    startLoc.X - 7 * direction, startLoc.Y - 2);
                                g.DrawLine(pen, startLoc.X - 10 * direction, startLoc.Y - 2,
                                    startLoc.X - 11 * direction, startLoc.Y - 2);
                                g.DrawLine(pen, startLoc.X - 2 * direction, startLoc.Y - 2,
                                    startLoc.X - 2 * direction, startLoc.Y - 3);
                                g.DrawLine(pen, startLoc.X - 6 * direction, startLoc.Y - 2,
                                    startLoc.X - 6 * direction, startLoc.Y - 3);
                                g.DrawLine(pen, startLoc.X - 10 * direction, startLoc.Y - 2,
                                    startLoc.X - 10 * direction, startLoc.Y - 3);
                                g.DrawLine(pen, startLoc.X - 2 * direction, startLoc.Y - 6,
                                    startLoc.X - 3 * direction, startLoc.Y - 6);
                                g.DrawLine(pen, startLoc.X - 6 * direction, startLoc.Y - 6,
                                    startLoc.X - 7 * direction, startLoc.Y - 6);
                                g.DrawLine(pen, startLoc.X - 2 * direction, startLoc.Y - 6,
                                    startLoc.X - 2 * direction, startLoc.Y - 7);
                                g.DrawLine(pen, startLoc.X - 6 * direction, startLoc.Y - 6,
                                    startLoc.X - 6 * direction, startLoc.Y - 7);
                                g.DrawLine(pen, startLoc.X - 2 * direction, startLoc.Y - 10,
                                    startLoc.X - 3 * direction, startLoc.Y - 10);
                                g.DrawLine(pen, startLoc.X - 2 * direction, startLoc.Y - 10,
                                    startLoc.X - 2 * direction, startLoc.Y - 11);
                                pen.Dispose();

                                // draw dark squares
                                if (m_ItemContainer.EffectiveStyle != eDotNetBarStyle.Metro)
                                {
                                    pen = new Pen(pa.Colors.BarStripeColor/*ControlPaint.Dark(clr)*/, 1);
                                    g.DrawRectangle(pen, startLoc.X - 4 * direction, startLoc.Y - 4, 1, 1);
                                    g.DrawRectangle(pen, startLoc.X - 8 * direction, startLoc.Y - 4, 1, 1);
                                    g.DrawRectangle(pen, startLoc.X - 12 * direction, startLoc.Y - 4, 1, 1);
                                    g.DrawRectangle(pen, startLoc.X - 4 * direction, startLoc.Y - 8, 1, 1);
                                    g.DrawRectangle(pen, startLoc.X - 8 * direction, startLoc.Y - 8, 1, 1);
                                    g.DrawRectangle(pen, startLoc.X - 4 * direction, startLoc.Y - 12, 1, 1);
                                    pen.Dispose();
                                    pen = null;
                                }
                            }
                            break;
                        }
                    case eGrabHandleStyle.Office2003:
                    case eGrabHandleStyle.Office2003SingleDot:
                        {
                            re = new RenderBarEventArgs(this, g, eBarRenderPart.GrabHandle, m_GrabHandleRect);
                            OnPreRender(re);
                            if (!re.Cancel)
                            {
                                int x = m_GrabHandleRect.Left + (m_GrabHandleRect.Width - 3) / 2;
                                int y = m_GrabHandleRect.Top + 4;

                                if (m_GrabHandleStyle == eGrabHandleStyle.Office2003SingleDot)
                                {
                                    x = m_GrabHandleRect.Left + (m_GrabHandleRect.Width - 3) / 2;
                                    y = m_GrabHandleRect.Top + (m_GrabHandleRect.Height - 3) / 2;
                                }
                                else
                                {
                                    if (m_ItemContainer.Orientation == eOrientation.Vertical)
                                    {
                                        x = m_GrabHandleRect.Left + 4;
                                        y = m_GrabHandleRect.Top + (m_GrabHandleRect.Height - 3) / 2;
                                    }
                                }

                                Brush brushDark = null;
                                Brush brushLight = new SolidBrush(ControlPaint.Light(clr));

                                if (!pa.Colors.BarStripeColor.IsEmpty)
                                {
                                    clr = pa.Colors.BarStripeColor;
                                    brushDark = new SolidBrush(clr);
                                }
                                else
                                    brushDark = new SolidBrush(ControlPaint.Dark(clr));

                                if (m_GrabHandleStyle == eGrabHandleStyle.Office2003SingleDot)
                                {
                                    g.FillRectangle(brushLight, x + 1, y + 1, 2, 2);
                                    g.FillRectangle(brushDark, x, y, 2, 2);
                                }
                                else
                                {
                                    if (m_ItemContainer.Orientation == eOrientation.Vertical)
                                    {
                                        for (int i = x; i <= m_GrabHandleRect.Right - 4; i += 5)
                                        {
                                            g.FillRectangle(brushLight, i + 1, y + 1, 2, 2);
                                            g.FillRectangle(brushDark, i, y, 2, 2);
                                        }
                                    }
                                    else
                                    {
                                        for (int i = y; i <= m_GrabHandleRect.Bottom - 4; i += 5)
                                        {
                                            g.FillRectangle(brushLight, x + 1, i + 1, 2, 2);
                                            g.FillRectangle(brushDark, x, i, 2, 2);
                                        }
                                    }
                                }
                                brushDark.Dispose();
                                brushLight.Dispose();
                            }
                            break;
                        }
                }
            }
        }
コード例 #5
0
        protected void PaintDotNet(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            SmoothingMode sm = g.SmoothingMode;
            TextRenderingHint th = g.TextRenderingHint;
            RenderBarEventArgs re = null;

            if (m_AntiAlias)
            {
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
            }

            m_SystemButtons.CustomizeButtonRect = Rectangle.Empty;
            m_SystemButtons.CloseButtonRect = Rectangle.Empty;
            m_SystemButtons.AutoHideButtonRect = Rectangle.Empty;
            m_SystemButtons.CaptionButtonRect = Rectangle.Empty;
            ColorScheme cs = this.GetColorScheme();

            ItemPaintArgs pa = GetItemPaintArgs(g);
            pa.ClipRectangle = e.ClipRectangle;
            Pen p;
            if (m_BarState == eBarState.Popup)
                p = new Pen(pa.Colors.BarPopupBorder, 1);
            else
                p = new Pen(pa.Colors.BarFloatingBorder);

            if (this.DisplayShadow && !this.AlphaShadow && m_ParentItem != null && !BarFunctions.IsOffice2007Style(m_ParentItem.EffectiveStyle))
                SetupRegion();

            if (m_BarState == eBarState.Popup)
            {
                re = new RenderBarEventArgs(this, g, eBarRenderPart.Background, this.ClientRectangle);
                OnPreRender(re);
                if (!re.Cancel)
                {
                    if (m_ParentItem != null && BarFunctions.IsOffice2007Style(m_ParentItem.EffectiveStyle) && GetRenderer() != null)
                    {
                        ToolbarRendererEventArgs tre = new ToolbarRendererEventArgs(this, g, this.DisplayRectangle);
                        tre.ItemPaintArgs = pa;
                        GetRenderer().DrawPopupToolbarBackground(tre);
                    }
                    else
                    {
                        using (SolidBrush brush = new SolidBrush(pa.Colors.BarPopupBackground))
                            g.FillRectangle(brush, this.DisplayRectangle);
                        PaintBackgroundImage(pa.Graphics);

                        PaintSideBar(g);

                        Rectangle borderRectangle = this.ClientRectangle;
                        if (this.DisplayShadow && !this.AlphaShadow)
                            borderRectangle = new Rectangle(0, 0, this.ClientSize.Width - 2, this.ClientSize.Height - 2);

                        if (m_ParentItem != null && BarFunctions.IsOffice2007Style(m_ParentItem.EffectiveStyle))
                            DisplayHelp.DrawRoundedRectangle(g, p, borderRectangle, m_CornerSize);
                        else
                            NativeFunctions.DrawRectangle(g, p, borderRectangle);

                        if (this.DisplayShadow && !this.AlphaShadow)
                        {
                            // Shadow
                            p.Dispose();
                            p = new Pen(SystemColors.ControlDark, 2);
                            Point[] pt = new Point[3];
                            pt[0].X = 2;
                            pt[0].Y = this.ClientSize.Height - 1;
                            pt[1].X = this.ClientSize.Width - 1;
                            pt[1].Y = this.ClientSize.Height - 1;
                            pt[2].X = this.ClientSize.Width - 1;
                            pt[2].Y = 2;
                            g.DrawLines(p, pt);
                        }
                        if (m_ParentItem != null && !BarFunctions.IsOffice2007Style(m_ParentItem.EffectiveStyle) && m_ParentItem is ButtonItem && m_ParentItem.Displayed)
                        {
                            // Determine where to draw the line based on parent position
                            if (m_ParentItemScreenPos.Y < this.Location.Y)
                            {
                                Point p1 = new Point((m_ParentItemScreenPos.X - this.Location.X) + 1, 0);
                                Point p2 = new Point(p1.X + m_ParentItem.WidthInternal - 5, 0);
                                DisplayHelp.DrawLine(g, p1, p2, pa.Colors.ItemExpandedBackground, 1);
                                //g.DrawLine(new Pen(pa.Colors.ItemExpandedBackground, 1), p1, p2);
                            }
                        }
                    }
                }
            }
            else if (m_BarState == eBarState.Floating)
            {
                bool drawCaptionText = true;

                re = new RenderBarEventArgs(this, g, eBarRenderPart.Background, this.ClientRectangle);
                OnPreRender(re);
                if (!re.Cancel)
                {
                    if (BarFunctions.IsOffice2007Style(this.Style) && this.GetRenderer() != null)
                    {
                        ToolbarRendererEventArgs tre = new ToolbarRendererEventArgs(this, g, this.DisplayRectangle);
                        tre.ItemPaintArgs = pa;
                        this.GetRenderer().DrawToolbarBackground(tre);
                    }
                    else
                    {
                        sm = g.SmoothingMode;
                        g.SmoothingMode = SmoothingMode.Default;
                        if (this.MenuBar)
                            DisplayHelp.FillRectangle(g, this.ClientRectangle, pa.Colors.MenuBarBackground, pa.Colors.MenuBarBackground2, pa.Colors.MenuBarBackgroundGradientAngle);
                        else
                            DisplayHelp.FillRectangle(g, this.ClientRectangle, pa.Colors.BarBackground, pa.Colors.BarBackground2, pa.Colors.BarBackgroundGradientAngle);

                        PaintBackgroundImage(pa.Graphics);
                        g.SmoothingMode = sm;
                    }
                }

                Rectangle r = new Rectangle(0, 0, this.Width, this.Height);

                ThemeWindow theme = null;
                ThemeWindowParts part = ThemeWindowParts.SmallFrameLeft;
                ThemeWindowStates state = ThemeWindowStates.FrameActive;

                re = new RenderBarEventArgs(this, g, eBarRenderPart.Caption, Rectangle.Empty);

                if (this.DrawThemedCaption)
                {
                    re.Bounds = new Rectangle(0, 0, this.Width, m_ThemeWindowMargins.Top + 1);
                    OnPreRender(re);
                    if (!re.Cancel)
                    {
                        theme = this.ThemeWindow;
                        if (this.LayoutType == eLayoutType.DockContainer && !m_HasFocus)
                            state = ThemeWindowStates.FrameInactive;

                        theme.DrawBackground(g, part, state, new Rectangle(0, 0, m_ThemeWindowMargins.Left, this.Height));
                        part = ThemeWindowParts.SmallFrameRight;
                        theme.DrawBackground(g, part, state, new Rectangle(this.Width - m_ThemeWindowMargins.Right, 0, m_ThemeWindowMargins.Left, this.Height));
                        part = ThemeWindowParts.SmallFrameBottom;
                        theme.DrawBackground(g, part, state, new Rectangle(0, this.Height - m_ThemeWindowMargins.Bottom, this.Width, m_ThemeWindowMargins.Bottom));

                        if (this.LayoutType == eLayoutType.DockContainer && !m_HasFocus)
                            state = ThemeWindowStates.CaptionInactive;
                        part = ThemeWindowParts.SmallCaption;
                    }
                    r = new Rectangle(0, 0, this.Width, m_ThemeWindowMargins.Top + 1);
                    theme.DrawBackground(g, part, state, r);
                    r.Offset(0, 1);
                }
                else if (m_GrabHandleStyle == eGrabHandleStyle.Caption && this.LayoutType == eLayoutType.DockContainer && this.Style == eDotNetBarStyle.Office2000)
                {
                    Rectangle rback = new Rectangle(3, 3, this.Width - 6, GetGrabHandleCaptionHeight());
                    re.Bounds = rback;
                    OnPreRender(re);
                    if (!re.Cancel)
                    {
                        ControlPaint.DrawBorder3D(g, r, Border3DStyle.Raised, Border3DSide.All);
                        eDrawCaption flags = eDrawCaption.DC_SMALLCAP | eDrawCaption.DC_GRADIENT | eDrawCaption.DC_TEXT;
                        if (m_HasFocus) flags |= eDrawCaption.DC_ACTIVE;
                        IntPtr hdc = g.GetHdc();
                        NativeFunctions.RECT rect = new NativeFunctions.RECT(rback.X, rback.Y, rback.Right, rback.Bottom);
                        try
                        {
                            NativeFunctions.DrawCaption(this.Handle, hdc, ref rect, flags);
                        }
                        finally
                        {
                            g.ReleaseHdc(hdc);
                        }
                    }
                    drawCaptionText = false;
                    r = rback;
                }
                else
                {
                    Rectangle rback = new Rectangle(3, 3, this.Width - 6, GetGrabHandleCaptionHeight());
                    re.Bounds = rback;
                    OnPreRender(re);

                    if (!re.Cancel)
                    {
                        Pen p1 = new Pen(pa.Colors.BarFloatingBorder, 1);
                        NativeFunctions.DrawRectangle(g, p, r);
                        r.Inflate(-1, -1);
                        NativeFunctions.DrawRectangle(g, p, r);

                        p1.Dispose();
                        p1 = new Pen(pa.Colors.BarFloatingBorder, 1);
                        g.DrawLine(p1, 1, 2, 2, 2);
                        g.DrawLine(p1, this.Width - 3, 2, this.Width - 2, 2);
                        g.DrawLine(p1, 1, this.Height - 3, 2, this.Height - 3);
                        g.DrawLine(p1, this.Width - 3, this.Height - 3, this.Width - 2, this.Height - 3);
                        p1.Dispose();
                        p1 = null;

                        if (this.GrabHandleStyle != eGrabHandleStyle.CaptionTaskPane)
                        {
                            sm = g.SmoothingMode;
                            g.SmoothingMode = SmoothingMode.Default;

                            if (m_CaptionBackColor.IsEmpty)
                            {
                                if (this.LayoutType == eLayoutType.Toolbar || m_HasFocus)
                                    DisplayHelp.FillRectangle(g, rback, pa.Colors.BarCaptionBackground, pa.Colors.BarCaptionBackground2, pa.Colors.BarCaptionBackgroundGradientAngle);
                                else
                                    DisplayHelp.FillRectangle(g, rback, pa.Colors.BarCaptionInactiveBackground, pa.Colors.BarCaptionInactiveBackground2, pa.Colors.BarCaptionInactiveBackgroundGAngle);
                            }
                            else
                                DisplayHelp.FillRectangle(g, new Rectangle(3, 3, this.Width - 6, GetGrabHandleCaptionHeight()), m_CaptionBackColor, Color.Empty);

                            g.SmoothingMode = sm;
                        }
                    }
                    r = rback;
                }

                r.Inflate(-1, -1);

                if (this.GrabHandleStyle != eGrabHandleStyle.CaptionTaskPane)
                {
                    if (this.CanHideResolved)
                    {
                        m_SystemButtons.CloseButtonRect = new Rectangle(r.Right - (m_SystemButtons.ButtonSize.Width + 3), r.Y + (r.Height - m_SystemButtons.ButtonSize.Height) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
                        re = new RenderBarEventArgs(this, g, eBarRenderPart.CloseButton, m_SystemButtons.CloseButtonRect);
                        OnPreRender(re);
                        m_SystemButtons.CloseButtonRect = re.Bounds;
                        r.Width -= (m_SystemButtons.CloseButtonRect.Width + 3);
                        if (!re.Cancel)
                            PaintCloseButton(pa);
                    }
                    if (this.ShowCustomizeMenuButton)
                    {
                        m_SystemButtons.CustomizeButtonRect = new Rectangle(r.Right - (m_SystemButtons.ButtonSize.Width + 1), r.Y + (r.Height - m_SystemButtons.ButtonSize.Height) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
                        re = new RenderBarEventArgs(this, g, eBarRenderPart.CustomizeButton, m_SystemButtons.CustomizeButtonRect);
                        OnPreRender(re);
                        m_SystemButtons.CustomizeButtonRect = re.Bounds;
                        r.Width -= (m_SystemButtons.CustomizeButtonRect.Width + 2);
                        if (!re.Cancel)
                            PaintCustomizeButton(pa);
                    }
                    r.X += 2;
                    r.Width -= 2;
                    if (r.Width > 0 && drawCaptionText)
                    {
                        re = new RenderBarEventArgs(this, g, eBarRenderPart.CaptionText, r);
                        OnPreRender(re);
                        if (!re.Cancel)
                        {
                            System.Drawing.Font objFont = null;
                            try
                            {
                                objFont = new Font(this.Font, FontStyle.Bold);
                            }
                            catch
                            {
                                objFont = SystemFonts.MenuFont; // (Font)System.Windows.Forms.SystemInformation.MenuFont.Clone();
                            }
                            eTextFormat sf = eTextFormat.Default | eTextFormat.EndEllipsis | eTextFormat.SingleLine | eTextFormat.VerticalCenter;
                            if (m_CaptionForeColor.IsEmpty)
                            {
                                if (this.DrawThemedCaption)
                                {
                                    if (m_HasFocus)
                                        state = ThemeWindowStates.CaptionActive;
                                    else
                                        state = ThemeWindowStates.CaptionInactive;
                                    r.Y += 1;
                                    //theme.DrawText(g, this.Text, objFont, r, part, state, ThemeTextFormat.Left | ThemeTextFormat.VCenter);
                                }
                                //else
                                TextDrawing.DrawString(g, this.Text, objFont, ((m_HasFocus || this.LayoutType == eLayoutType.Toolbar) ? pa.Colors.BarCaptionText : pa.Colors.BarCaptionInactiveText), r, sf);
                            }
                            else
                                TextDrawing.DrawString(g, this.Text, objFont, m_CaptionForeColor, r, sf);
                            objFont.Dispose();
                            objFont = null;
                        }
                    }
                }
                else
                {
                    this.PaintGrabHandle(pa);
                }
            }
            else if (m_BarState == eBarState.Docked && BarFunctions.IsOffice2007Style(this.Style) && this.GetRenderer() != null && (!this.IsThemed || this.MenuBar))
            {
                re = new RenderBarEventArgs(this, g, eBarRenderPart.Background, this.DisplayRectangle);
                OnPreRender(re);
                if (!re.Cancel && this.BackColor != Color.Transparent)
                {
                    ToolbarRendererEventArgs tre = new ToolbarRendererEventArgs(this, g, this.DisplayRectangle);
                    tre.ItemPaintArgs = pa;
                    this.GetRenderer().DrawToolbarBackground(tre);
                }
                else
                    PaintGrabHandle(pa);
            }
            else
            {
                p.Dispose();
                p = null;
                bool drawBorder = true;
                // Docked state
                if (m_ItemContainer.m_BackgroundColor.IsEmpty && this.BackColor != Color.Transparent)
                {
                    if (this.IsThemed)
                    {
                        Rectangle r = new Rectangle(-this.Location.X, -this.Location.Y, this.Parent.Width, this.Parent.Height);
                        ThemeRebar theme = this.ThemeRebar;
                        theme.DrawBackground(g, ThemeRebarParts.Background, ThemeRebarStates.Normal, r);
                    }
                    else
                    {
                        sm = g.SmoothingMode;
                        g.SmoothingMode = SmoothingMode.Default;
                        re = new RenderBarEventArgs(this, g, eBarRenderPart.Background, this.ClientRectangle);
                        OnPreRender(re);
                        if (!re.Cancel)
                        {
                            if (this.MenuBar)
                            {
                                if (!pa.Colors.MenuBarBackground2.IsEmpty && pa.Colors.MenuBarBackground2.A > 0)
                                {
                                    System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(this.ClientRectangle, pa.Colors.MenuBarBackground, pa.Colors.MenuBarBackground2, pa.Colors.MenuBarBackgroundGradientAngle);
                                    g.FillRectangle(gradient, this.ClientRectangle);
                                    gradient.Dispose();
                                }
                                else if (IsGradientStyle && this.Parent != null && !pa.Colors.DockSiteBackColor2.IsEmpty && !pa.Colors.DockSiteBackColor.IsEmpty)
                                {
                                    System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(new Rectangle(-this.Left, -this.Top, this.Parent.Width, this.Parent.Height), pa.Colors.DockSiteBackColor, pa.Colors.DockSiteBackColor2, 0f);
                                    g.FillRectangle(gradient, -this.Left, -this.Top, this.Parent.Width, this.Parent.Height);
                                    gradient.Dispose();
                                }
                                else
                                {
                                    using (SolidBrush brush = new SolidBrush(pa.Colors.MenuBarBackground))
                                        g.FillRectangle(brush, this.DisplayRectangle);
                                }
                            }
                            else
                            {
                                if (this.Style == eDotNetBarStyle.VS2005 && this.LayoutType == eLayoutType.DockContainer && !this.BackColor.IsEmpty)
                                {
                                    DisplayHelp.FillRectangle(g, this.ClientRectangle, this.BackColor, Color.Empty);
                                }
                                else if (this.GradientBackground)
                                    DisplayHelp.FillRectangle(g, this.ClientRectangle, pa.Colors.BarBackground, pa.Colors.BarBackground2, pa.Colors.BarBackgroundGradientAngle);
                                else
                                {
                                    using (SolidBrush brush = new SolidBrush(pa.Colors.BarBackground))
                                        g.FillRectangle(brush, this.ClientRectangle);
                                }
                            }
                        }
                        else
                            drawBorder = false;
                        g.SmoothingMode = sm;
                    }
                }
                else if (!m_ItemContainer.BackColor.IsEmpty)
                {
                    sm = g.SmoothingMode;
                    g.SmoothingMode = SmoothingMode.Default;
                    re = new RenderBarEventArgs(this, g, eBarRenderPart.Background, this.DisplayRectangle);
                    OnPreRender(re);
                    if (!re.Cancel)
                    {
                        using (SolidBrush brush = new SolidBrush(m_ItemContainer.BackColor))
                            g.FillRectangle(brush, this.DisplayRectangle);
                    }
                    else
                        drawBorder = false;
                    g.SmoothingMode = sm;
                }

                if (this.Parent != null && this.Parent.BackgroundImage != null && this.Parent is DockSite)
                {
                    Rectangle r = new Rectangle(-this.Location.X, -this.Location.Y, this.Parent.Width, this.Parent.Height);
                    DockSite site = this.Parent as DockSite;
                    BarFunctions.PaintBackgroundImage(g, r, site.BackgroundImage, site.BackgroundImagePosition, site.BackgroundImageAlpha);
                }
                else
                    PaintBackgroundImage(pa.Graphics);

                if (drawBorder)
                {
                    if (IsGradientStyle && !this.IsThemed && this.LayoutType == eLayoutType.Toolbar && !this.MenuBar && this.BarType == eBarType.Toolbar && this.BackColor != Color.Transparent)
                    {
                        if (p != null) p.Dispose();
                        p = new Pen(pa.Colors.BarDockedBorder, 1);
                        g.DrawLine(p, 0, this.Height - 1, this.Width, this.Height - 1);
                        p.Dispose();
                        p = null;
                    }
                    else
                    {
                        Rectangle border = this.ClientRectangle;
                        border.Inflate(-2, -2);
                        BarFunctions.DrawBorder(g, m_DockedBorder, border, m_SingleLineColor);
                    }
                }
                PaintGrabHandle(pa);
            }
            m_ItemContainer.Paint(pa);
            if (m_BarType == eBarType.StatusBar && this.GrabHandleStyle == eGrabHandleStyle.ResizeHandle)
            {
                PaintGrabHandle(pa);
            }
            if (p != null) p.Dispose();
            g.SmoothingMode = sm;
            g.TextRenderingHint = th;

            if (HasPostRender)
            {
                re = new RenderBarEventArgs(this, g, eBarRenderPart.All, this.ClientRectangle);
                OnPostRender(re);
            }
        }