using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace UAS_MES_NEW.CustomControl.GroupBoxWithBorder
{
public partial class GroupBoxWithBorder : GroupBox
{
///
/// 获取和设置控件高亮色
///
/// 高亮色
[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);
}
}
}