首页 > Windows开发 > 详细

winform 窗体圆角设计

时间:2017-01-03 07:26:07      阅读:247      评论:0      收藏:0      [点我收藏+]

  网上看到的很多winform窗体圆角设计代码都比较累赘,这里分享一个少量代码就可以实现的圆角。主要运用了System.Drawing.Drawing2D。

  效果图

技术分享

  代码如下。

        private void BeautiLoginForm_Paint(object sender, PaintEventArgs e)
        {
            Type(this, 25, 0.1);
        }
        private void Type(Control sender, int p_1, double p_2)
        {
            GraphicsPath oPath = new GraphicsPath();
            oPath.AddClosedCurve(new Point[] {
                new Point(0, sender.Height / p_1),
                new Point(sender.Width / p_1, 0),
                new Point(sender.Width - sender.Width / p_1, 0),
                new Point(sender.Width, sender.Height / p_1),
                new Point(sender.Width, sender.Height - sender.Height / p_1),
                new Point(sender.Width - sender.Width / p_1, sender.Height),
                new Point(sender.Width / p_1, sender.Height),
                new Point(0, sender.Height - sender.Height / p_1) }, (float)p_2);
            sender.Region = new Region(oPath);
        }

        private void BeautiLoginForm_Resize(object sender, EventArgs e)
        {
            Type(this, 25, 0.1);
        }

  代码比较简单,希望有所帮助。

 

winform 窗体圆角设计

原文:http://www.cnblogs.com/Jurieo/p/winform_rounded_form.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!