Questo sito utilizza cookies, anche di terze parti, per mostrare pubblicità e servizi in linea con il tuo account. Leggi l'informativa sui cookies.
Username: Password: oppure
Mini Cad - Disegno.vb

Disegno.vb

Caricato da: Poggi Marco
Scarica il programma completo

  1. Imports System
  2. Imports System.Drawing
  3.  
  4. Public Class Disegno
  5.     Private penna As Pen
  6.     Private dove As Graphics
  7.     Private limiti As Point
  8.     Private origine As Point
  9.     Private Sub calcolaILimiti()
  10.         Dim i As Integer = 0
  11.         Dim j As Integer = 0
  12.         limiti = New Point(0, 0)
  13.         While dove.IsVisible(i, j)
  14.             i += 1
  15.         End While
  16.         limiti.X = i
  17.         i = 0
  18.         While dove.IsVisible(i, j)
  19.             j += 1
  20.         End While
  21.         limiti.Y = j
  22.     End Sub
  23.     Public Sub New(ByVal posizione As Graphics)
  24.         dove = posizione
  25.         penna = New Pen(Color.Black, 1)
  26.         Call calcolaILimiti()
  27.         origine = New Point(0, limiti.Y)
  28.     End Sub
  29.     Public Sub New(ByVal posizione As Graphics, ByVal p As Pen)
  30.         dove = posizione
  31.         penna = p
  32.         Call calcolaILimiti()
  33.         origine = New Point(0, limiti.Y)
  34.     End Sub
  35.     Public ReadOnly Property getMaxX() As Integer
  36.         Get
  37.             Return limiti.X
  38.         End Get
  39.     End Property
  40.     Public ReadOnly Property getMaxY() As Integer
  41.         Get
  42.             Return limiti.Y
  43.         End Get
  44.     End Property
  45.     Public Property pennino() As Pen
  46.         Get
  47.             Return penna
  48.         End Get
  49.         Set(ByVal value As Pen)
  50.             penna = value
  51.         End Set
  52.     End Property
  53.     Public Property foglio() As Graphics
  54.         Get
  55.             Return dove
  56.         End Get
  57.         Set(ByVal value As Graphics)
  58.             dove.Dispose()
  59.             dove = value
  60.         End Set
  61.     End Property
  62.     Public Property puntoDiOrigine() As Point
  63.         Get
  64.             Return origine
  65.         End Get
  66.         Set(ByVal value As Point)
  67.             origine = value
  68.         End Set
  69.     End Property
  70.     Public Sub linea(ByVal x1 As Integer, ByVal y1 As Integer, ByVal x2 As Integer, ByVal y2 As Integer)
  71.         x1 = origine.X + x1
  72.         x2 = origine.X + x2
  73.         y1 = origine.Y - y1
  74.         y2 = origine.Y - y2
  75.         dove.DrawLine(penna, x1, y1, x2, y2)
  76.     End Sub
  77.     Public Sub punto(ByVal x As Integer, ByRef y As Integer)
  78.         x = origine.X + x
  79.         y = origine.Y - y
  80.         dove.DrawLine(penna, x, y, x, y)
  81.     End Sub
  82.  
  83.     Public Sub cancella()
  84.         dove.Clear(Color.White)
  85.     End Sub
  86. End Class