码迷,mamicode.com
首页 > Windows程序 > 详细

winform重绘窗体成圆角(网上借鉴)

时间:2015-05-01 11:51:59      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:

winform做圆角窗体:

 1 //重绘窗体为圆角
 2         private void frmMain_Paint(object sender, PaintEventArgs e)
 3         {
 4             #region
 5 
 6             List<Point> list = new List<Point>();
 7             int width = this.Width;
 8             int height = this.Height;
 9 
10             #region 四个圆角
11 
12             //左上  
13             list.Add(new Point(0, 5));
14             list.Add(new Point(1, 5));
15             list.Add(new Point(1, 3));
16             list.Add(new Point(2, 3));
17             list.Add(new Point(2, 2));
18             list.Add(new Point(3, 2));
19             list.Add(new Point(3, 1));
20             list.Add(new Point(5, 1));
21             list.Add(new Point(5, 0));
22 
23             //右上  
24             list.Add(new Point(width - 5, 0));
25             list.Add(new Point(width - 5, 1));
26             list.Add(new Point(width - 3, 1));
27             list.Add(new Point(width - 3, 2));
28             list.Add(new Point(width - 2, 2));
29             list.Add(new Point(width - 2, 3));
30             list.Add(new Point(width - 1, 3));
31             list.Add(new Point(width - 1, 5));
32             list.Add(new Point(width - 0, 5));
33 
34             //右下  
35             list.Add(new Point(width - 0, height - 5));
36             list.Add(new Point(width - 1, height - 5));
37             list.Add(new Point(width - 1, height - 3));
38             list.Add(new Point(width - 2, height - 3));
39             list.Add(new Point(width - 2, height - 2));
40             list.Add(new Point(width - 3, height - 2));
41             list.Add(new Point(width - 3, height - 1));
42             list.Add(new Point(width - 5, height - 1));
43             list.Add(new Point(width - 5, height - 0));
44 
45             //左下  
46             list.Add(new Point(5, height - 0));
47             list.Add(new Point(5, height - 1));
48             list.Add(new Point(3, height - 1));
49             list.Add(new Point(3, height - 2));
50             list.Add(new Point(2, height - 2));
51             list.Add(new Point(2, height - 3));
52             list.Add(new Point(1, height - 3));
53             list.Add(new Point(1, height - 5));
54             list.Add(new Point(0, height - 5));
55             #endregion
56 
57             Point[] points = list.ToArray();
58 
59             GraphicsPath shape = new GraphicsPath();
60 
61             shape.AddPolygon(points);
62 
63             this.Region = new System.Drawing.Region(shape);
64             #endregion
65         }

 

winform重绘窗体成圆角(网上借鉴)

标签:

原文地址:http://www.cnblogs.com/strongZZ/p/4470478.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!