You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

58 lines
1.2 KiB

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Test
{
class TBtn : Button
{
public TBtn()
{
//this.UseVisualStyleBackColor = true;
this.BackColor = Color.FromArgb(51, 133, 255);
this.ForeColor = Color.White;
this.FlatStyle = FlatStyle.Flat;
this.FlatAppearance.BorderSize = 0;
this.FlatAppearance.BorderColor = Color.FromArgb(45, 204, 112);
}
protected override void OnMouseDown(MouseEventArgs mevent)
{
if (mevent.Button == MouseButtons.Left)
{
this.BackColor = Color.Red;
}
base.OnMouseDown(mevent);
}
protected override void OnClick(EventArgs e)
{
try
{
this.Enabled = false;
base.OnClick(e);
}
finally
{
this.Enabled = true;
}
}
protected override void OnEnabledChanged(EventArgs e)
{
base.OnEnabledChanged(e);
if (Enabled)
{
this.BackColor = Color.FromArgb(51, 133, 255);
}
else
{
this.BackColor = Color.FromArgb(209, 213, 216);
}
}
}
}