2021-06-05 14:17:30 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
|
|
namespace CleanMachineHMI
|
|
|
|
|
|
{
|
|
|
|
|
|
[ToolboxItem(true)]
|
|
|
|
|
|
public class CircleButton : Button//继承按钮类 重新生成解决方案就能看见我啦
|
|
|
|
|
|
{
|
2021-12-26 21:30:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnResize(EventArgs e)
|
2021-06-05 14:17:30 +08:00
|
|
|
|
{
|
2021-12-26 21:30:02 +08:00
|
|
|
|
|
|
|
|
|
|
base.OnResize(e);
|
2021-06-05 14:17:30 +08:00
|
|
|
|
System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
|
2021-12-26 21:30:02 +08:00
|
|
|
|
|
2021-06-05 14:17:30 +08:00
|
|
|
|
path.AddEllipse(2, 2, this.Width - 6, this.Height - 6);
|
2021-12-26 21:30:02 +08:00
|
|
|
|
Region = new Region(path);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnPaint(PaintEventArgs e)//重新设置控件的形状
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnPaint(e);//递归 每次重新都发生此方法,保证其形状为自定义形状
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-06-05 14:17:30 +08:00
|
|
|
|
Graphics g = e.Graphics;
|
|
|
|
|
|
g.DrawEllipse(new Pen(Color.White, 0), 2, 2, Width - 6, Height - 6);
|
2021-12-26 21:30:02 +08:00
|
|
|
|
|
2021-06-05 14:17:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|