public static void DrawBorder(ControlBorderStyle Style, Color BorderColor, Graphics g, Rectangle r) { switch (Style) { case ControlBorderStyle.Dotted: { r.Width --; r.Height --; g.DrawRectangle(new Pen(SystemColors.Control), r); Pen p = new Pen(BorderColor); p.DashStyle = DashStyle.Dot; g.DrawRectangle(p, r); break; } case ControlBorderStyle.Dashed: { r.Width --; r.Height --; g.DrawRectangle(new Pen(SystemColors.Control), r); Pen p = new Pen(BorderColor); p.DashStyle = DashStyle.Dash; g.DrawRectangle(p, r); break; } case ControlBorderStyle.Sunken: { if (BorderColor == Color.Black) BorderColor = SystemColors.Control; //System.Windows.Forms.ControlPaint.DrawBorder3D (g,r,Border3DStyle.Sunken); DrawingTools.DrawBorder(Border3DStyle.Sunken, BorderColor, g, r); break; } case ControlBorderStyle.FixedSingle: { r.Width --; r.Height --; g.DrawRectangle(new Pen(BorderColor), r); break; } case ControlBorderStyle.FixedDouble: { g.DrawRectangle(new Pen(BorderColor), r.Left, r.Top, r.Width - 1, r.Height - 1); g.DrawRectangle(new Pen(BorderColor), r.Left + 1, r.Top + 1, r.Width - 3, r.Height - 3); break; } case ControlBorderStyle.Raised: { if (BorderColor == Color.Black) BorderColor = SystemColors.Control; DrawingTools.DrawBorder(Border3DStyle.Raised, BorderColor, g, r); //System.Windows.Forms.ControlPaint.DrawBorder3D (g,r,Border3DStyle.Raised); break; } case ControlBorderStyle.RaisedThin: { if (BorderColor == Color.Black) BorderColor = Color.FromArgb(SystemColors.Control.R, SystemColors.Control.G, SystemColors.Control.B); DrawingTools.DrawBorder(Border3DStyle.RaisedInner, BorderColor, g, r); //System.Windows.Forms.ControlPaint.DrawBorder3D (g,r,Border3DStyle.Raised); break; } case ControlBorderStyle.SunkenThin: { if (BorderColor == Color.Black) BorderColor = Color.FromArgb(SystemColors.Control.R, SystemColors.Control.G, SystemColors.Control.B); DrawingTools.DrawBorder(Border3DStyle.SunkenOuter, BorderColor, g, r); //System.Windows.Forms.ControlPaint.DrawBorder3D (g,r,Border3DStyle.Raised); break; } case ControlBorderStyle.Etched: { if (BorderColor == Color.Black) BorderColor = SystemColors.Control; System.Windows.Forms.ControlPaint.DrawBorder3D(g, r, Border3DStyle.Etched); break; } case ControlBorderStyle.Bump: { if (BorderColor == Color.Black) BorderColor = SystemColors.Control; SolidBrush b = new SolidBrush(BorderColor); g.FillRectangle(b, r.Left, r.Top, r.Width, 4); g.FillRectangle(b, r.Left, r.Bottom - 4, r.Width, 4); g.FillRectangle(b, r.Left, r.Top, 4, r.Height); g.FillRectangle(b, r.Right - 4, r.Top, 4, r.Height); b.Dispose(); DrawingTools.DrawBorder(Border3DStyle.Raised, BorderColor, g, r); DrawingTools.DrawBorder(Border3DStyle.Sunken, BorderColor, g, new Rectangle(r.Left + 4, r.Top + 4, r.Width - 8, r.Height - 8)); break; } case ControlBorderStyle.Column: { SolidBrush normal = new SolidBrush(BorderColor); SolidBrush light = new SolidBrush(MixColors(BorderColor, Color.White, 1)); SolidBrush dark = new SolidBrush(MixColors(BorderColor, Color.Black, 0.4)); SolidBrush darkdark = new SolidBrush(Color.FromArgb(BorderColor.A, System.Windows.Forms.ControlPaint.DarkDark(BorderColor))); g.FillRectangle(light, r.Left, r.Top, r.Width, 1); g.FillRectangle(light, r.Left, r.Top + 3, 1, r.Height - 1 - 6); g.FillRectangle(dark, r.Right - 1, r.Top + 3, 1, r.Height - 6); g.FillRectangle(dark, r.Left, r.Bottom - 1, r.Width, 1); break; } case ControlBorderStyle.Row: { SolidBrush normal = new SolidBrush(BorderColor); SolidBrush light = new SolidBrush(MixColors(BorderColor, Color.White, 1)); SolidBrush dark = new SolidBrush(MixColors(BorderColor, Color.Black, 0.4)); SolidBrush darkdark = new SolidBrush(Color.FromArgb(BorderColor.A, System.Windows.Forms.ControlPaint.DarkDark(BorderColor))); g.FillRectangle(light, r.Left + 3, r.Top, r.Width - 6, 1); g.FillRectangle(light, r.Left, r.Top, 1, r.Height - 1); g.FillRectangle(dark, r.Right - 1, r.Top, 1, r.Height); g.FillRectangle(dark, r.Left + 3, r.Bottom - 1, r.Width - 6, 1); break; } } }
public static void DrawBorder(ControlBorderStyle Style, Color BorderColor, Graphics g, Rectangle r) { switch (Style) { case ControlBorderStyle.Dotted: { r.Width--; r.Height--; g.DrawRectangle(new Pen(SystemColors.Control), r); Pen p = new Pen(BorderColor); p.DashStyle = DashStyle.Dot; g.DrawRectangle(p, r); break; } case ControlBorderStyle.Dashed: { r.Width--; r.Height--; g.DrawRectangle(new Pen(SystemColors.Control), r); Pen p = new Pen(BorderColor); p.DashStyle = DashStyle.Dash; g.DrawRectangle(p, r); break; } case ControlBorderStyle.Sunken: { if (BorderColor == Color.Black) { BorderColor = SystemColors.Control; } //System.Windows.Forms.ControlPaint.DrawBorder3D (g,r,Border3DStyle.Sunken); DrawingTools.DrawBorder(Border3DStyle.Sunken, BorderColor, g, r); break; } case ControlBorderStyle.FixedSingle: { r.Width--; r.Height--; g.DrawRectangle(new Pen(BorderColor), r); break; } case ControlBorderStyle.FixedDouble: { g.DrawRectangle(new Pen(BorderColor), r.Left, r.Top, r.Width - 1, r.Height - 1); g.DrawRectangle(new Pen(BorderColor), r.Left + 1, r.Top + 1, r.Width - 3, r.Height - 3); break; } case ControlBorderStyle.Raised: { if (BorderColor == Color.Black) { BorderColor = SystemColors.Control; } DrawingTools.DrawBorder(Border3DStyle.Raised, BorderColor, g, r); //System.Windows.Forms.ControlPaint.DrawBorder3D (g,r,Border3DStyle.Raised); break; } case ControlBorderStyle.RaisedThin: { if (BorderColor == Color.Black) { BorderColor = Color.FromArgb(SystemColors.Control.R, SystemColors.Control.G, SystemColors.Control.B); } DrawingTools.DrawBorder(Border3DStyle.RaisedInner, BorderColor, g, r); //System.Windows.Forms.ControlPaint.DrawBorder3D (g,r,Border3DStyle.Raised); break; } case ControlBorderStyle.SunkenThin: { if (BorderColor == Color.Black) { BorderColor = Color.FromArgb(SystemColors.Control.R, SystemColors.Control.G, SystemColors.Control.B); } DrawingTools.DrawBorder(Border3DStyle.SunkenOuter, BorderColor, g, r); //System.Windows.Forms.ControlPaint.DrawBorder3D (g,r,Border3DStyle.Raised); break; } case ControlBorderStyle.Etched: { if (BorderColor == Color.Black) { BorderColor = SystemColors.Control; } System.Windows.Forms.ControlPaint.DrawBorder3D(g, r, Border3DStyle.Etched); break; } case ControlBorderStyle.Bump: { if (BorderColor == Color.Black) { BorderColor = SystemColors.Control; } SolidBrush b = new SolidBrush(BorderColor); g.FillRectangle(b, r.Left, r.Top, r.Width, 4); g.FillRectangle(b, r.Left, r.Bottom - 4, r.Width, 4); g.FillRectangle(b, r.Left, r.Top, 4, r.Height); g.FillRectangle(b, r.Right - 4, r.Top, 4, r.Height); b.Dispose(); DrawingTools.DrawBorder(Border3DStyle.Raised, BorderColor, g, r); DrawingTools.DrawBorder(Border3DStyle.Sunken, BorderColor, g, new Rectangle(r.Left + 4, r.Top + 4, r.Width - 8, r.Height - 8)); break; } case ControlBorderStyle.Column: { SolidBrush normal = new SolidBrush(BorderColor); SolidBrush light = new SolidBrush(MixColors(BorderColor, Color.White, 1)); SolidBrush dark = new SolidBrush(MixColors(BorderColor, Color.Black, 0.4)); SolidBrush darkdark = new SolidBrush(Color.FromArgb(BorderColor.A, System.Windows.Forms.ControlPaint.DarkDark(BorderColor))); g.FillRectangle(light, r.Left, r.Top, r.Width, 1); g.FillRectangle(light, r.Left, r.Top + 3, 1, r.Height - 1 - 6); g.FillRectangle(dark, r.Right - 1, r.Top + 3, 1, r.Height - 6); g.FillRectangle(dark, r.Left, r.Bottom - 1, r.Width, 1); break; } case ControlBorderStyle.Row: { SolidBrush normal = new SolidBrush(BorderColor); SolidBrush light = new SolidBrush(MixColors(BorderColor, Color.White, 1)); SolidBrush dark = new SolidBrush(MixColors(BorderColor, Color.Black, 0.4)); SolidBrush darkdark = new SolidBrush(Color.FromArgb(BorderColor.A, System.Windows.Forms.ControlPaint.DarkDark(BorderColor))); g.FillRectangle(light, r.Left + 3, r.Top, r.Width - 6, 1); g.FillRectangle(light, r.Left, r.Top, 1, r.Height - 1); g.FillRectangle(dark, r.Right - 1, r.Top, 1, r.Height); g.FillRectangle(dark, r.Left + 3, r.Bottom - 1, r.Width - 6, 1); break; } } }