BrightIdeasSoftware.HeaderControl.DrawUnthemedBackground C# (CSharp) Method

DrawUnthemedBackground() protected method

Draw a background for the header, without using Themes.
protected DrawUnthemedBackground ( Graphics g, Rectangle r, int columnIndex, bool isSelected, BrightIdeasSoftware.HeaderStateStyle stateStyle ) : void
g System.Drawing.Graphics
r System.Drawing.Rectangle
columnIndex int
isSelected bool
stateStyle BrightIdeasSoftware.HeaderStateStyle
return void
        protected void DrawUnthemedBackground(Graphics g, Rectangle r, int columnIndex, bool isSelected, HeaderStateStyle stateStyle)
        {
            if (stateStyle.BackColor.IsEmpty)
                // I know we're supposed to be drawing the unthemed background, but let's just see if we
                // can draw something more interesting than the dull raised block
                if (VisualStyleRenderer.IsSupported &&
                    VisualStyleRenderer.IsElementDefined(VisualStyleElement.Header.Item.Normal))
                    this.DrawThemedBackground(g, r, columnIndex, isSelected);
                else
                    ControlPaint.DrawBorder3D(g, r, Border3DStyle.RaisedInner);
            else {
                using (Brush b = new SolidBrush(stateStyle.BackColor))
                    g.FillRectangle(b, r);
            }

            // Draw the frame if the style asks for one
            if (!stateStyle.FrameColor.IsEmpty && stateStyle.FrameWidth > 0f) {
                RectangleF r2 = r;
                r2.Inflate(-stateStyle.FrameWidth, -stateStyle.FrameWidth);
                g.DrawRectangle(new Pen(stateStyle.FrameColor, stateStyle.FrameWidth),
                    r2.X, r2.Y, r2.Width, r2.Height);
            }
        }