1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
Public Class Form1
Dim BpDessin As Bitmap
Dim GraphDessin As Graphics
Dim rect As Rectangle
Dim p1 As New Drawing.Pen(Color.Black, 1)
Dim X1_DepartRectangle, Y1_DepartRectangle, X2_LongRectangle, Y2_HautRectangle As Integer
Dim X1_DepartLigne, Y1_DepartLigne, X2_LongLigne, Y2_HautLigne As Integer
Dim NumeroRectangle, NumeroLigne As Integer
Dim NomRectangle As String = "Rectangle_"
Dim NonLigne As String = "Ligne_"
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
X1_DepartRectangle = 0
Y1_DepartRectangle = 0
X2_LongRectangle = 50
Y2_HautRectangle = 50
X1_DepartLigne = 80
Y1_DepartLigne = 10
X2_LongLigne = 400
Y2_HautLigne = 10
NumeroRectangle = 0
NumeroLigne = 0
BpDessin = New Bitmap(PictureBox1.Width, PictureBox1.Height)
GraphDessin = Graphics.FromImage(BpDessin)
End Sub
Private Sub ButtonAjouterRectangle_Click(sender As Object, e As EventArgs) Handles ButtonAjouterRectangle.Click
NumeroRectangle = NumeroRectangle + 1
rect = New Rectangle(X1_DepartRectangle, Y1_DepartRectangle, X2_LongRectangle, Y2_HautRectangle)
GraphDessin.DrawRectangle(p1, rect)
PictureBox1.Image = CType(BpDessin.Clone, Image)
ListBoxElements.Items.Add(NomRectangle & NumeroRectangle)
Y1_DepartRectangle = Y1_DepartRectangle + Y2_HautRectangle + 10
End Sub
Private Sub ButtonAjouterLigne_Click(sender As Object, e As EventArgs) Handles ButtonAjouterLigne.Click
NumeroLigne = NumeroLigne + 1
GraphDessin.DrawLine(p1, X1_DepartLigne, Y1_DepartLigne, X2_LongLigne, Y2_HautLigne)
PictureBox1.Image = CType(BpDessin.Clone, Image)
ListBoxElements.Items.Add(NonLigne & NumeroLigne)
Y1_DepartLigne = Y1_DepartLigne + 10
Y2_HautLigne = Y2_HautLigne + 10
End Sub
End Class |
Partager