zoukankan      html  css  js  c++  java
  • 圆角窗口绘制

            对于form, 当BorderStyle = None时, 绘制圆角, 需要使用graphicspath的AddArc方法。

            程序如下

           protected override void OnPaint(PaintEventArgs e)
           {
                base.OnPaint(e);
                //圆弧半径
                int iRadius = 7;
                //边框工作区
                Rectangle rect = this.ClientRectangle;
                GraphicsPath path= new GraphicsPath();
                // 添加圆弧
                path.AddArc(0, 0, iRadius* 2, iRadius* 2, 180, 90);
                path.AddArc(rect.Width - iRadius* 2-1, 0, iRadius* 2, iRadius* 2, 270, 90);
                path.AddArc(rect.Width - iRadius* 2-1,  rect.Height - iRadius* 2-1, iRadius* 2, iRadius* 2, 0, 90);
                path.AddArc(0, rect.Height - iRadius* 2-1, iRadius* 2, iRadius* 2, 90, 90);
                path.CloseFigure();
                e.Graphics.DrawPath(SystemPens.ActiveBorder, path);

            }
               
           

           从控件左边起点画可以出席那边框,但是当从控件右边框使用 理论值画时,右边框不会出现边框,不清楚是为什么,我只好把横坐标左移1像素,即(rect.Height - iRadius * 2-1), 可以出现边框。

     如果周围有多个控件,看不到边框效果,可以适当修改Pen.Width=2 ,不要太大,否则边框加粗

  • 相关阅读:
    Ubuntu下VSFTPD(五)(匿名FTP设置方法)
    Ubuntu下VSFTPD(六)(常见FTP命令及其功能) (
    ubuntu13.04装配oracle11gR2
    oracle之报错:ORA-00054: 资源正忙,要求指定 NOWAIT_数据库的几种锁
    oracle建索引的可选项
    Oracle自定义函数
    C# WinForm开发系列
    为C#自定义控件添加自定义事件
    python 爬虫抓取心得
    C# 正则表达式学习
  • 原文地址:https://www.cnblogs.com/jason2004/p/6112261.html
Copyright © 2011-2022 走看看