PDA

View Full Version : سوال: رسم خط



KhanDaii
چهارشنبه 04 آذر 1388, 13:48 عصر
سلام بر جامعه ی برنامه نویس
سوالی که دارم اینه که چجوری میشه که کاربر با زدن یک دکمه بین دو نقطه ای که مختصاتش با تکس باکس وارد میشه خطی رسم بشه؟
آیا تابع با دستور خاصی داره؟
با تشکر:خجالت:

milad.biroonvand
چهارشنبه 04 آذر 1388, 16:59 عصر
این کد رو امتحان کن


Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

Public Class Form1

Dim g As System.Drawing.Graphics
Dim pen1 As New System.Drawing.Pen(Color.Blue, 2)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click g = PictureBox1.CreateGraphics
g.DrawLine(pen1, 250, 50, 400, 200)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click g = PictureBox1.CreateGraphics
g.DrawEllipse(pen1, 50, 50, 100, 150)
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click g = PictureBox1.CreateGraphics
g.DrawRectangle(pen1, 30, 30, 50, 60)
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click g = PictureBox1.CreateGraphics
g.DrawArc(pen1, 150, 100, 150, 200, 150, 160)
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click g = PictureBox1.CreateGraphics
g.DrawPie(pen1, 50, 50, 150, 150, 0, 170)
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Dim p(5) As System.Drawing.Point
p(0).X = 0
p(0).Y = 0
p(1).X = 53
p(1).Y = 111
p(2).X = 114
p(2).Y = 86
p(3).X = 34
p(3).Y = 34
p(4).X = 165
p(4).Y = 7
g = PictureBox1.CreateGraphics
g.DrawPolygon(pen1, p)
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click g = PictureBox1.CreateGraphics
g.DrawBezier(pen1, 100, 200, 240, 250, 100, 200, 150, 30)
End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click PictureBox1.Refresh()
End Sub
End Class

KhanDaii
چهارشنبه 04 آذر 1388, 17:50 عصر
[QUOTE=milad.biroonvand;856119]این کد رو امتحان کن

[CODE]Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

Public Class Form1

Dim g As System.Drawing.Graphics
Dim pen1 As New System.Drawing.Pen(Color.Blue, 2)
...
متشکرم. ولی یه کم طولانیه.
آقا میلاد مطمئنی که راه دیگه ندارد؟ یعنی تابع خاصی،دستور کمتری، هیچی راه دیگه نداره؟

milad.biroonvand
پنج شنبه 05 آذر 1388, 12:01 عصر
اینهم ساده ترین راه


Dim g As Graphics
g = Me.CreateGraphics()
g.DrawLine(Pens.Black, New Point(100, 10), New Point(80, 90))