BrightIdeasSoftware.HeaderControl.DrawThemedBackground C# (CSharp) Method

DrawThemedBackground() protected method

Draw a more-or-less pure themed header background.
protected DrawThemedBackground ( Graphics g, Rectangle r, int columnIndex, bool isSelected ) : void
g System.Drawing.Graphics
r System.Drawing.Rectangle
columnIndex int
isSelected bool
return void
        protected void DrawThemedBackground(Graphics g, Rectangle r, int columnIndex, bool isSelected)
        {
            int part = 1; // normal item
            if (columnIndex == 0 &&
                VisualStyleRenderer.IsElementDefined(VisualStyleElement.Header.ItemLeft.Normal))
                part = 2; // left item
            if (columnIndex == this.ListView.Columns.Count - 1 &&
                VisualStyleRenderer.IsElementDefined(VisualStyleElement.Header.ItemRight.Normal))
                part = 3; // right item

            int state = 1; // normal state
            if (isSelected)
                state = 3; // pressed
            else if (columnIndex == this.ColumnIndexUnderCursor)
                state = 2; // hot

            VisualStyleRenderer renderer = new VisualStyleRenderer("HEADER", part, state);
            renderer.DrawBackground(g, r);
        }