Winform实现圆角窗口程序

xingyun86 1月前 139

Winform实现圆角窗口程序

List<PointF> list = new List<PointF>();
int width = this.Width;
int height = this.Height;
#region 四个圆角
//左上
list.Add(new PointF(0, 5));
list.Add(new PointF(1, 5));
list.Add(new PointF(1, 3));
list.Add(new PointF(2, 3));
list.Add(new PointF(2, 2));
list.Add(new PointF(3, 2));
list.Add(new PointF(3, 1));
list.Add(new PointF(5, 1));
list.Add(new PointF(5, 0));
//右上
list.Add(new PointF(width - 5, 0));
list.Add(new PointF(width - 5, 1));
list.Add(new PointF(width - 3, 1));
list.Add(new PointF(width - 3, 2));
list.Add(new PointF(width - 2, 2));
list.Add(new PointF(width - 2, 3));
list.Add(new PointF(width - 1, 3));
list.Add(new PointF(width - 1, 5));
list.Add(new PointF(width - 0, 5));
//右下
list.Add(new PointF(width - 0, height - 5));
list.Add(new PointF(width - 1, height - 5));
list.Add(new PointF(width - 1, height - 3));
list.Add(new PointF(width - 2, height - 3));
list.Add(new PointF(width - 2, height - 2));
list.Add(new PointF(width - 3, height - 2));
list.Add(new PointF(width - 3, height - 1));
list.Add(new PointF(width - 5, height - 1));
list.Add(new PointF(width - 5, height - 0));
//左下
list.Add(new PointF(5, height - 0));
list.Add(new PointF(5, height - 1));
list.Add(new PointF(3, height - 1));
list.Add(new PointF(3, height - 2));
list.Add(new PointF(2, height - 2));
list.Add(new PointF(2, height - 3));
list.Add(new PointF(1, height - 3));
list.Add(new PointF(1, height - 5));
list.Add(new PointF(0, height - 5));
#endregion
PointF[] points = list.ToArray();
GraphicsPath path = new GraphicsPath();
path.AddPolygon(points);
this.Region = new System.Drawing.Region(path);


×
打赏作者
最新回复 (0)
只看楼主
全部楼主
返回