【问题标题】:C# windows App one specific rounded cornerC# windows App 一个特定的圆角
【发布时间】:2020-08-26 10:44:27
【问题描述】:

有人可以帮我制作一个类,它可以创建一个带有特定圆角的按钮吗?

    GraphicsPath GetRoundPath(RectangleF Rect, int radius, float width=0)
    {

        //Fix radius to rect size
        radius = (int) Math.Max(( Math.Min(radius, Math.Min(Rect.Width, Rect.Height)) - width),1);

        float r2 = radius / 2f;
        float w2 = width / 2f;            
        GraphicsPath GraphPath = new GraphicsPath();

        //Top-Left Arc
        GraphPath.AddArc(Rect.X + w2, Rect.Y + w2, radius, radius, 180, 90);

        //Top-Right Arc
        GraphPath.AddArc(Rect.X + Rect.Width - radius - w2, Rect.Y + w2, radius, radius, 270, 90);

        //Bottom-Right Arc
        GraphPath.AddArc(Rect.X + Rect.Width - w2 - radius,
                           Rect.Y + Rect.Height - w2 - radius, radius, radius, 0, 90);
        //Bottom-Left Arc
        GraphPath.AddArc(Rect.X + w2, Rect.Y - w2 + Rect.Height - radius, radius, radius, 90, 90);

        //Close line ( Left)           
        GraphPath.AddLine(Rect.X + w2, Rect.Y + Rect.Height - r2 - w2, Rect.X + w2,Rect.Y + r2 + w2);
                   
            
        
        return GraphPath;
    }

【问题讨论】:

  • 请出示您对此问题的尝试/代码。谢谢你:)
  • 您好,我添加了代码,我需要一些解释,如何让一些角不圆?

标签: c# class button


【解决方案1】:

【讨论】:

  • 对不起,我是新人,我需要有人解释一下,如果这种方法绘制圆角,我想如何创建一个圆角按钮,我的意思是,我想如何正常填充整个按钮并只留下一个圆角?
猜你喜欢
  • 1970-01-01
  • 2019-11-07
  • 2018-12-29
  • 2021-12-04
  • 1970-01-01
  • 2014-06-25
  • 1970-01-01
  • 1970-01-01
  • 2014-05-20
相关资源
最近更新 更多