usercontrol 画圆角

   protected override void OnResize(EventArgs e)
    {
        this.Region = null;
        SetWindowR();

    }

    private void SetWindowR()
    {
        System.Drawing.Drawing2D.GraphicsPath gPath = new System.Drawing.Drawing2D.GraphicsPath();
        Rectangle rect = new Rectangle(0, 5, this.Width, this.Height - 5);
        gPath = GetRoundedRP(rect, 390); //后面的30是圆的角度,数值越大圆角度越大
        this.Region = new Region(gPath);
    }

    private System.Drawing.Drawing2D.GraphicsPath GetRoundedRP(Rectangle rect, int a)
    {
        int diameter = a;
        Rectangle arcRect = new Rectangle(rect.Location, new Size(diameter, diameter));
        System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
        // 左上角
        //gp.AddArc(arcRect, 180, 90);
        gp.AddArc(0, 0, 70, 70, 180, 90);
        // 右上角
        arcRect.X = rect.Right - diameter;
        gp.AddArc(arcRect, 270, 90);
        // 右下角
        arcRect.Y = rect.Bottom;
        gp.AddArc(this.Width - 50, this.Height - 50, 50, 50, 0, 90);
        //gp.AddArc(arcRect, 0, 90);
        // 左下角
        arcRect.X = rect.Left;
        gp.AddArc(arcRect, 90, 90);
        gp.CloseFigure();
        return gp;
    }
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容