System.Windows.Forms.HexBox.OnPaintBackground C# (CSharp) Method

OnPaintBackground() protected method

Paints the background.
protected OnPaintBackground ( PaintEventArgs e ) : void
e PaintEventArgs A PaintEventArgs that contains the event data.
return void
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            switch(_borderStyle)
            {
                case BorderStyle.Fixed3D:
                {
                    if(TextBoxRenderer.IsSupported)
                    {
                        VisualStyleElement state = VisualStyleElement.TextBox.TextEdit.Normal;
                        Color backColor = this.BackColor;

                        if (this.Enabled)
                        {
                            if (this.ReadOnly)
                                state = VisualStyleElement.TextBox.TextEdit.ReadOnly;
                            else if (this.Focused)
                                state = VisualStyleElement.TextBox.TextEdit.Focused;
                        }
                        else
                        {
                            state = VisualStyleElement.TextBox.TextEdit.Disabled;
                            backColor = this.BackColorDisabled;
                        }

                        VisualStyleRenderer vsr = new VisualStyleRenderer(state);
                        vsr.DrawBackground(e.Graphics, this.ClientRectangle);

                        Rectangle rectContent = vsr.GetBackgroundContentRectangle(e.Graphics, this.ClientRectangle);
                        e.Graphics.FillRectangle(new SolidBrush(backColor), rectContent);
                    }
                    else
                    {
                        // draw background
                        e.Graphics.FillRectangle(new SolidBrush(BackColor), ClientRectangle);

                        // draw default border
                        ControlPaint.DrawBorder3D(e.Graphics, ClientRectangle, Border3DStyle.Sunken);
                    }

                    break;
                }
                case BorderStyle.FixedSingle:
                {
                    // draw background
                    e.Graphics.FillRectangle(new SolidBrush(BackColor), ClientRectangle);

                    // draw fixed single border
                    ControlPaint.DrawBorder(e.Graphics, ClientRectangle, Color.Black, ButtonBorderStyle.Solid);
                    break;
                }
            }
        }