Toto som načmáral narýchlo dúfam, že to aspoň trochu pomôže.
Public Class Form1
Private Structure myLineStr
Dim x, y As System.Collections.Generic.Stack(Of Integer)
End Structure
Dim line As myLineStr
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
line.x = New System.Collections.Generic.Stack(Of Integer)
line.y = New System.Collections.Generic.Stack(Of Integer)
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
line.x.Push(e.X)
line.y.Push(e.Y)
If line.x.Count >= 2 Then Me.Invalidate()
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
If line.x.Count >= 2 And line.y.Count >= 2 Then
Dim p As New Pen(Color.Blue, 3)
If Not e.Graphics Is Nothing Then e.Graphics.DrawLine(p, _
line.x.Pop, _
line.y.Pop, _
line.x.Pop, _
line.y.Pop)
End If
End Sub
End Class
|