BF2Statistics.MyGroupBox.OnPaint C# (CSharp) Method

OnPaint() protected method

protected OnPaint ( PaintEventArgs e ) : void
e PaintEventArgs
return void
        protected override void OnPaint(PaintEventArgs e)
        {
            // === Draw Rectangle

            Size tSize = TextRenderer.MeasureText(this.Text, this.Font);

            // Create Border Rectangle
            Rectangle borderRect = e.ClipRectangle;
            borderRect.Y += tSize.Height / 2;
            borderRect.Height -= tSize.Height / 2;

            GraphicsPath gPath = CreatePath(0, borderRect.Y, (float)(this.Width - 1), borderRect.Height - 1, 5, true, true, true, true);
            e.Graphics.FillPath(new SolidBrush(ActualBackColor), gPath);
            e.Graphics.DrawPath(new Pen(BorderColor), gPath);

            // === Draw Text

            // Create Text Rectangle
            Rectangle textRect = e.ClipRectangle;
            textRect.X += 6;
            textRect.Width = tSize.Width;
            textRect.Height = tSize.Height;
            e.Graphics.FillRectangle(new SolidBrush(this.TextBackColor), textRect);

            // Draw Text inside text rectangle
            e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), textRect);
        }