تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
لرسم مستطيل منحني الأطراف
#1
كاتب الموضوع : 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();
}
}}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  لرسم خط علي WindowsForm فيجوال بيسك RaggiTech 0 2,057 17-10-12, 05:29 PM
آخر رد: RaggiTech

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم