منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
لرسم مستطيل منحني الأطراف - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : الأقسام التعليمية - المنتدى القديم (http://vb4arb.com/vb/forumdisplay.php?fid=90)
+--- قسم : مكتبة أكواد المنتدى (http://vb4arb.com/vb/forumdisplay.php?fid=111)
+---- قسم : مكتبة أكواد .net (http://vb4arb.com/vb/forumdisplay.php?fid=117)
+---- الموضوع : لرسم مستطيل منحني الأطراف (/showthread.php?tid=6181)



لرسم مستطيل منحني الأطراف - RaggiTech - 17-10-12

كاتب الموضوع : AhmedEssawy

منقول من هنا :
http://snippets.dzone.com/tag/csharp/4

VB.net:



كود :
Public Sub DrawRoundRect(ByVal g As Graphics, ByVal p As Pen, ByVal X As Single, ByVal Y As Single, ByVal width As Single, ByVal height As Single, ByVal radius As Single)
Dim gp As GraphicsPath = New GraphicsPath
gp.AddLine((X + radius), Y, (X _
+ (width _
- (radius * 2))), Y)
gp.AddArc((X _
+ (width _
- (radius * 2))), Y, (radius * 2), (radius * 2), 270, 90)
gp.AddLine((X + width), (Y + radius), (X + width), (Y _
+ (height _
- (radius * 2))))
gp.AddArc((X _
+ (width _
- (radius * 2))), (Y _
+ (height _
- (radius * 2))), (radius * 2), (radius * 2), 0, 90)
gp.AddLine((X _
+ (width _
- (radius * 2))), (Y + height), (X + radius), (Y + height))
gp.AddArc(X, (Y _
+ (height _
- (radius * 2))), (radius * 2), (radius * 2), 90, 90)
gp.AddLine(X, (Y _
+ (height _
- (radius * 2))), X, (Y + radius))
gp.AddArc(X, Y, (radius * 2), (radius * 2), 180, 90)
gp.CloseFigure
g.DrawPath(p, gp)
gp.Dispose
End Sub

C# :


كود :
public void DrawRoundRect(Graphics g, Pen p, float X, float Y, float width, float height, float radius)
{
GraphicsPath gp = new GraphicsPath(); gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);
gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90);
gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2));
gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);
gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);
gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);
gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);
gp.CloseFigure();

g.DrawPath(p, gp);
gp.Dispose();
}