public class TestButton : Button
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private enum MouseActionType//定义鼠标的点击类型
{
None,
Hover,
Click
}
private MouseActionType mouseAction;
private ImageAttributes imgAttr = new ImageAttributes();
private Bitmap buttonBitmap;
private Rectangle buttonBitmapRectangle;
public TestButton()
{
// 该调用是 Windows.Forms 窗体设计器所必需的。
InitializeComponent();
// TODO: 在 InitComponent 调用后添加任何初始化
mouseAction = MouseActionType.None;
//应用双缓冲技术是画面不闪烁
this.SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.DoubleBuffer |
ControlStyles.UserPaint, true);
//修改默认的字体,背景色,大小
this.Font = new Font("宋体", 12, FontStyle.Bold);
this.BackColor = Color.DarkTurquoise;
this.Size = new Size(100, 40);
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{