XPTable.Models.Table.OnPaintBorder C# (CSharp) Method

OnPaintBorder() protected method

Paints the Table's border
protected OnPaintBorder ( PaintEventArgs e ) : void
e PaintEventArgs A PaintEventArgs that contains the event data
return void
        protected void OnPaintBorder(PaintEventArgs e)
        {
            //e.Graphics.SetClip(e.ClipRectangle);

            if (this.BorderStyle == BorderStyle.Fixed3D)
            {
                if (ThemeManager.VisualStylesEnabled)
                {
                    TextBoxState state = TextBoxState.Normal;
                    if (!this.Enabled)
                    {
                        state = TextBoxState.Disabled;
                    }

                    // draw the left border
                    Rectangle clipRect = new Rectangle(0, 0, SystemInformation.Border3DSize.Width, this.Height);
                    if (clipRect.IntersectsWith(e.ClipRectangle))
                    {
                        ThemeManager.DrawTextBox(e.Graphics, this.ClientRectangle, clipRect, state);
                    }

                    // draw the top border
                    clipRect = new Rectangle(0, 0, this.Width, SystemInformation.Border3DSize.Height);
                    if (clipRect.IntersectsWith(e.ClipRectangle))
                    {
                        ThemeManager.DrawTextBox(e.Graphics, this.ClientRectangle, clipRect, state);
                    }

                    // draw the right border
                    clipRect = new Rectangle(this.Width - SystemInformation.Border3DSize.Width, 0, this.Width, this.Height);
                    if (clipRect.IntersectsWith(e.ClipRectangle))
                    {
                        ThemeManager.DrawTextBox(e.Graphics, this.ClientRectangle, clipRect, state);
                    }

                    // draw the bottom border
                    clipRect = new Rectangle(0, this.Height - SystemInformation.Border3DSize.Height, this.Width, SystemInformation.Border3DSize.Height);
                    if (clipRect.IntersectsWith(e.ClipRectangle))
                    {
                        ThemeManager.DrawTextBox(e.Graphics, this.ClientRectangle, clipRect, state);
                    }
                }
                else
                {
                    ControlPaint.DrawBorder3D(e.Graphics, 0, 0, this.Width, this.Height, Border3DStyle.Sunken);
                }
            }
            else if (this.BorderStyle == BorderStyle.FixedSingle)
            {
                Color color = this.Focused ? color = this.BorderColor : color = this.UnfocusedBorderColor;

                using (Pen borderPen = new Pen(color))
                {
                    e.Graphics.DrawRectangle(borderPen, 0, 0, this.Width - 1, this.Height - 1);
                }
            }

            if (this.HScroll && this.VScroll)
            {
                Rectangle rect = new Rectangle(this.Width - this.BorderWidth - SystemInformation.VerticalScrollBarWidth,
                    this.Height - this.BorderWidth - SystemInformation.HorizontalScrollBarHeight,
                    SystemInformation.VerticalScrollBarWidth,
                    SystemInformation.HorizontalScrollBarHeight);

                if (rect.IntersectsWith(e.ClipRectangle))
                {
                    e.Graphics.FillRectangle(SystemBrushes.Control, rect);
                }
            }
        }
Table