Imports System
Imports System.Drawing
Public Class Disegno
Private penna As Pen
Private dove As Graphics
Private limiti As Point
Private origine As Point
Private Sub calcolaILimiti()
Dim i As Integer = 0
Dim j As Integer = 0
limiti = New Point(0, 0)
While dove.IsVisible(i, j)
i += 1
End While
limiti.X = i
i = 0
While dove.IsVisible(i, j)
j += 1
End While
limiti.Y = j
End Sub
Public Sub New(ByVal posizione As Graphics)
dove = posizione
penna = New Pen(Color.Black, 1)
Call calcolaILimiti()
origine = New Point(0, limiti.Y)
End Sub
Public Sub New(ByVal posizione As Graphics, ByVal p As Pen)
dove = posizione
penna = p
Call calcolaILimiti()
origine = New Point(0, limiti.Y)
End Sub
Public ReadOnly Property getMaxX() As Integer
Get
Return limiti.X
End Get
End Property
Public ReadOnly Property getMaxY() As Integer
Get
Return limiti.Y
End Get
End Property
Public Property pennino() As Pen
Get
Return penna
End Get
Set(ByVal value As Pen)
penna = value
End Set
End Property
Public Property foglio() As Graphics
Get
Return dove
End Get
Set(ByVal value As Graphics)
dove.Dispose()
dove = value
End Set
End Property
Public Property puntoDiOrigine() As Point
Get
Return origine
End Get
Set(ByVal value As Point)
origine = value
End Set
End Property
Public Sub linea(ByVal x1 As Integer, ByVal y1 As Integer, ByVal x2 As Integer, ByVal y2 As Integer)
x1 = origine.X + x1
x2 = origine.X + x2
y1 = origine.Y - y1
y2 = origine.Y - y2
dove.DrawLine(penna, x1, y1, x2, y2)
End Sub
Public Sub punto(ByVal x As Integer, ByRef y As Integer)
x = origine.X + x
y = origine.Y - y
dove.DrawLine(penna, x, y, x, y)
End Sub
Public Sub cancella()
dove.Clear(Color.White)
End Sub
End Class