using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace TransColorControl
{
public sealed partial class CControl : Control
{
#region 构造函数
public CControl()
{
InitializeComponent();
SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint
| ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
}
#endregion
#region 重写属性
protected override CreateParams CreateParams
{
get
{
var result = base.CreateParams;
result.ExStyle |= 0x00000020;
return result;
}
}
#endregion
#region 重写方法
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
pe.Graphics.FillPie(new SolidBrush(Color.Blue), 0, 0, 30, 30, 0, 270);
}
#endregion
}
}