如何解决C#Windows App一个特定的圆角
有人可以帮我上一堂课,创建一个带有一个特定角的圆角的按钮吗?
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,180,90);
//Top-Right Arc
GraPHPath.AddArc(Rect.X + Rect.Width - radius - w2,270,90);
//Bottom-Right Arc
GraPHPath.AddArc(Rect.X + Rect.Width - w2 - radius,Rect.Y + Rect.Height - w2 - radius,90);
//Bottom-Left Arc
GraPHPath.AddArc(Rect.X + w2,Rect.Y - w2 + Rect.Height - 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;
}
解决方法
Here is a detailed example
https://www.codeproject.com/Articles/1275672/Button-with-Rounded-Edges-Csharp
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。