منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : System.Drawing2D
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
كاتب الموضوع : jafaronly


Imports System.Drawing.Drawing2D
قد لا يثير هذا العنوان اهتمامك كثيراً لكنه يعطيك امكانات كبيرة لتحويل مشروعك الى لوحه فنية
حيث يعطيك امكانية رسم ما تريد رسمه على الفورم
حتى لا يكون حدث ال (form paint) من الاحداث الي لا تسترعي اهتمامك جرب مثلا" ان تضع الكود ادناه في الحدث اعلاه

كود :
Dim m As String
m = "jafaronly@yahoo.com" & vbCrLf
m &= " vb4arab"

Dim graphics_path As New Drawing2D.GraphicsPath
graphics_path.AddString(m, _
New FontFamily("Times New Roman"), CInt(FontStyle.Bold), 40, New Point(10, 10), StringFormat.GenericTypographic)
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
e.Graphics.FillPath(Brushes.Blue, graphics_path)
e.Graphics.DrawPath(New Pen(Color.Yellow, 2), graphics_path)
حسنا قد لا يهمك كثيرا ان ترسم مجرد نص معين على الفورم
لقد قلنا انك سترسم كل ما تريد رسمه
جرب اذا احببت الكود التالي ودائماً في حدث (form paint)

كود :
Dim x As Integer = 10
Dim y As Integer = 10
Dim wid As Integer = 150
Dim hgt As Integer = 150

Dim cx As Integer = x + wid \ 2
Dim cy As Integer = y + hgt \ 2
Dim r1 As Integer = CInt(wid * 0.5)
Dim r2 As Integer = CInt(hgt * 0.25)
Dim star_pts(9) As Point
For i As Integer = 0 To 9 Step 2
star_pts(i).X = cx + CInt(r1 * Cos(i * PI / 5 - PI / 2))
star_pts(i).Y = cy + CInt(r1 * Sin(i * PI / 5 - PI / 2))
star_pts(i + 1).X = cx + CInt(r2 * Cos((i + 1) * PI / 5 - PI / 2))
star_pts(i + 1).Y = cy + CInt(r2 * Sin((i + 1) * PI / 5 - PI / 2))
Next i
Dim star_path As New GraphicsPath
star_path.AddPolygon(star_pts)
Dim star_brush As New PathGradientBrush(star_pts)
star_brush.CenterColor = Color.Yellow
star_brush.SurroundColors = New Color() { _
Color.YellowGreen, Color.White, _
Color.YellowGreen, Color.White, _
Color.YellowGreen, Color.White, _
Color.YellowGreen, Color.White, _
Color.YellowGreen, Color.White }
e.Graphics.FillPolygon(star_brush, star_pts)
ولكن الكود اعلاه وكما تلاحظ مليئ بالزوايا والعلاقات الرياظية لذلك يتوجب عليك استيراد
name space اخرى اضافة الى Imports System.Drawing.Drawing2D
الا وهي Imports System.Math
وهكذا فان هواة الرسم لن تخيب آمالهم في الفيجوال
كان هذا مجرد مثال والا فان بأمكانك ان كما قلنا ان ترسم ماشئت