123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System.ComponentModel;
- using System.Drawing;
- using System.Windows.Forms;
- namespace UAS_MES_NEW.CustomControl.GroupBoxWithBorder
- {
- public partial class GroupBoxWithBorder : GroupBox
- {
- /// <summary>
- /// 获取和设置控件高亮色
- /// </summary>
- /// <value>高亮色</value>
- [TypeConverter("System.Drawing.ColorConverter"),
- Category("LoadingCircle"),
- Description("获取和设置控件高亮色")]
- public Color TextColor
- {
- get
- {
- return textcolor;
- }
- set
- {
- textcolor = value;
- Invalidate();
- }
- }
- public Color BorderColor
- {
- get
- {
- return bordercolor;
- }
- set
- {
- bordercolor = value;
- Invalidate();
- }
- }
- private Color textcolor;
- private Color bordercolor;
- public GroupBoxWithBorder()
- {
- InitializeComponent();
- this.Paint += this.groupBox1_Paint;
- }
- private void groupBox1_Paint(object sender, PaintEventArgs e)
- {
- e.Graphics.Clear(BackColor);
- Brush br = new SolidBrush(textcolor);
- e.Graphics.DrawString(Text, Font, br, 10, 1);
- Pen LineColor = new Pen(bordercolor);
- e.Graphics.DrawLine(LineColor, 1, 7, 8, 7);
- e.Graphics.DrawLine(LineColor, e.Graphics.MeasureString(Text, Font).Width + 8, 7, Width - 2, 7);
- e.Graphics.DrawLine(LineColor, 1, 7, 1, Height - 2);
- e.Graphics.DrawLine(LineColor, 1, Height - 2, Width - 2, Height - 2);
- e.Graphics.DrawLine(LineColor, Width - 2, 7, Width - 2, Height - 2);
- }
- }
- }
|