06-08-20, 08:32 PM
كود :
Public Class Form1
Dim g As Graphics
Dim clic As Integer = 1
Dim pnt, pnt2 As Point
Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles Me.MouseUp
If e.Button = MouseButtons.Left Then
If clic = 1 Then
pnt = New Point(e.X, e.Y)
clic += 1
g.FillEllipse(Brushes.Black, New Rectangle(pnt.X - 4, pnt.Y - 4, 7, 7))
Label1.Text = e.Location.ToString
ElseIf clic = 2 Then
pnt2 = New Point(e.X, e.Y)
g.FillEllipse(Brushes.Black, New Rectangle(pnt2.X - 4, pnt2.Y - 4, 7, 7))
'==================================================================='
g.DrawLine(Pens.Red, pnt, pnt2)
clic = 1
Label2.Text = e.Location.ToString
End If
End If
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
g = CreateGraphics()
g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
End Sub
End Class