将要画的图形写成各种控件,向一个容器内动态添加,并可修改它们的属性
/// <summary>
/// 椭圆
/// </summary>
public partial class OvalShape : UserControl
{
public OvalShape()
{
SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.Selectable, false);
InitializeComponent();
}
[UserBrowerAble(), Browsable(true), Description("文本"), Category("椭圆框属性")]
public string text
{
get
{
return this.Text;
}
set
{
this.Text = value;
}
}
[UserBrowerAble(), Browsable(true), Description("控件位置"), Category("椭圆框属性")]
public Point location
{
get
{
return this.Location;
}
set
{
this.Location = value;
}
}
[UserBrowerAble(), Browsable(true), Description("控件大小"), Category("椭圆框属性")]
public Size size
{
get
{
return this.Size;
}
set
{
this.Size = value;
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawEllipse(new Pen(this.ForeColor, 1F),0,0,this.Width-2,this.Height-2);
}
}
[
本帖最后由 xydddaxia 于 2011-11-25 17:56 编辑 ]