ZForge.Controls.ExplorerBar.Expando.OnPaintBorder C# (CSharp) Method

OnPaintBorder() protected method

Paints the borders
protected OnPaintBorder ( Graphics g ) : void
g System.Drawing.Graphics The Graphics used to paint the border
return void
        protected void OnPaintBorder(Graphics g)
        {
            // get the current border and border colors
            Border border = this.Border;
            Color c = this.BorderColor;

            // check if we are currently animating a fade
            if (this.animatingFade)
            {
                // calculate the alpha value for the color
                int alpha = (int) (255 * (((float) (this.Height - this.HeaderHeight)) / ((float) (this.ExpandedHeight - this.HeaderHeight))));

                // make sure it doesn't go past 0 or 255
                if (alpha < 0)
                {
                    alpha = 0;
                }
                else if (alpha > 255)
                {
                    alpha = 255;
                }

                // update the color with the alpha value
                c = Color.FromArgb(alpha, c.R, c.G, c.B);
            }

            // draw the borders
            using (SolidBrush brush = new SolidBrush(c))
            {
                g.FillRectangle(brush, border.Left, this.HeaderHeight, this.Width-border.Left-border.Right, border.Top); // top border
                g.FillRectangle(brush, 0, this.HeaderHeight, border.Left, this.Height-this.HeaderHeight); // left border
                g.FillRectangle(brush, this.Width-border.Right, this.HeaderHeight, border.Right, this.Height-this.HeaderHeight); // right border
                g.FillRectangle(brush, border.Left, this.Height-border.Bottom, this.Width-border.Left-border.Right, border.Bottom); // bottom border
            }
        }