-3

Can someone please help me to make a class which creates a button with one specific corner rounded?

    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;
    }
Smithy
  • 2,170
  • 6
  • 29
  • 61

1 Answers1

1
Here is a detailed example

https://www.codeproject.com/Articles/1275672/Button-with-Rounded-Edges-Csharp

Rounded edges in button C# (WinForms)

Razack
  • 1,826
  • 2
  • 16
  • 37
  • Sorry , im new, i need someone to explain me how i suppose to create one corner rounded button if this method draws arctangles , i mean , how i suppose to fill the entire button normally and leave only one corner rounded? – Kostas Skutulas Aug 26 '20 at 11:42