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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
| Option Explicit On
Public Class Form1
Public sngZPLZoom As Double
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
picZPLView.Image = Nothing
sngZPLZoom = 6
picZPLView.Width = (Convert.ToDouble(txtetiquette0.Text) * sngZPLZoom) + &H2
picZPLView.Height = (Convert.ToDouble(txtetiquette0.Text) * sngZPLZoom) + &H6
Call Form_Resize()
End Sub
Private Sub Form_Resize()
Dim lngX As Long
Dim lngY As Long
Dim lngI As Long
Dim lngJ As Long
Dim sngI As Single
Dim x As Single
Dim y As Single
If Me.WindowState <> 1 Then
lngX = Me.Width
lngY = Me.Height
picContainer.Width = lngX - 35
picContainer.Height = lngY - 135
Dim fond As Bitmap = New Bitmap(picContainer.Width, picContainer.Height)
picContainer.Image = fond
Dim ft As Font = New Font("arial", 10, FontStyle.Bold)
Dim g As Graphics = Graphics.FromImage(picContainer.Image)
picZPLView.Left = picContainer.Left + ((picContainer.Width - picZPLView.Width) / 2)
picZPLView.Top = picContainer.Top + ((picContainer.Height - picZPLView.Height) / 2)
picContainer.Image = Nothing
g.DrawLine(Pens.DarkSeaGreen, (picZPLView.Left - picContainer.Left), 0, (picZPLView.Left - picContainer.Left), picContainer.Height)
g.DrawLine(Pens.DarkSeaGreen, (picZPLView.Left + picZPLView.Width - picContainer.Left) - 1, 0, (picZPLView.Left + picZPLView.Width - picContainer.Left) - 1, picContainer.Height)
g.DrawLine(Pens.DarkSeaGreen, 0, (picZPLView.Top - picContainer.Top), picContainer.Width, (picZPLView.Top - picContainer.Top))
g.DrawLine(Pens.DarkSeaGreen, 0, (picZPLView.Top + picZPLView.Height - picContainer.Top) - 1, picContainer.Width, (picZPLView.Top + picZPLView.Height - picContainer.Top) - 1)
lngI = 0
For sngI = ((picZPLView.Width) / txtetiquette0.Text) To picZPLView.Width - 1 Step ((picZPLView.Width) / txtetiquette0.Text)
lngI = lngI + 1
If lngI < 10 Then
If lngI <> 5 Then
g.DrawLine(Pens.Blue, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top - 4 - picContainer.Top, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top - picContainer.Top)
g.DrawLine(Pens.Blue, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top + picZPLView.Height - picContainer.Top, picZPLView.Left + sngI - picContainer.Left, (picZPLView.Top + picZPLView.Height) + 4 - picContainer.Top)
Else
g.DrawLine(Pens.Blue, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top - 8 - picContainer.Top, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top - picContainer.Top)
g.DrawLine(Pens.Blue, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top + picZPLView.Height - picContainer.Top, picZPLView.Left + sngI - picContainer.Left, (picZPLView.Top + picZPLView.Height) + 8 - picContainer.Top)
End If
Else
lngI = 0
lngJ = lngJ + 10
g.DrawLine(Pens.Blue, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top - 18 - picContainer.Top, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top - picContainer.Top)
g.DrawLine(Pens.Blue, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top + picZPLView.Height - picContainer.Top, picZPLView.Left + sngI - picContainer.Left, (picZPLView.Top + picZPLView.Height) + 18 - picContainer.Top)
x = ((picZPLView.Left + sngI) - ((g.MeasureString(lngJ, ft).Width) / 2)) - 4 - picContainer.Left
y = picZPLView.Top - 32 - picContainer.Top
g.DrawString(lngJ, ft, New SolidBrush(Color.White), x, y)
x = ((picZPLView.Left + sngI) - ((g.MeasureString(lngJ, ft).Width) / 2)) - 4 - picContainer.Left
y = picZPLView.Top + picZPLView.Height + &H11 - picContainer.Top
g.DrawString(lngJ, ft, New SolidBrush(Color.White), x, y)
End If
Next sngI
lngI = 0
lngJ = 0
For sngI = ((picZPLView.Height) / txtetiquette1.Text) To picZPLView.Height - &H1 Step ((picZPLView.Height) / txtetiquette1.Text)
lngI = lngI + 1
If lngI < 10 Then
If lngI <> 5 Then
g.DrawLine(Pens.Blue, picZPLView.Left - 4 - picContainer.Left, picZPLView.Top + sngI - picContainer.Top, picZPLView.Left - picContainer.Left, picZPLView.Top + sngI - picContainer.Top)
g.DrawLine(Pens.Blue, picZPLView.Left + picZPLView.Width - picContainer.Left, picZPLView.Top + sngI - picContainer.Top, (picZPLView.Left + picZPLView.Width) + &H4 - picContainer.Left, picZPLView.Top + sngI - picContainer.Top)
Else
g.DrawLine(Pens.Blue, picZPLView.Left - &H8 - picContainer.Left, picZPLView.Top + sngI - picContainer.Top, picZPLView.Left - picContainer.Left, picZPLView.Top + sngI - picContainer.Top)
g.DrawLine(Pens.Blue, picZPLView.Left + picZPLView.Width - picContainer.Left, picZPLView.Top + sngI - picContainer.Top, (picZPLView.Left + picZPLView.Width) + &H8 - picContainer.Left, picZPLView.Top + sngI - picContainer.Top)
End If
Else
lngI = &H0
lngJ = lngJ + 10
g.DrawLine(Pens.Blue, picZPLView.Left - 18 - picContainer.Left, picZPLView.Top + sngI - picContainer.Top, picZPLView.Left - picContainer.Left, picZPLView.Top + sngI - picContainer.Top)
g.DrawLine(Pens.Blue, picZPLView.Left + picZPLView.Width - picContainer.Left, picZPLView.Top + sngI - picContainer.Top, (picZPLView.Left + picZPLView.Width) + 18 - picContainer.Left, picZPLView.Top + sngI - picContainer.Top)
x = picZPLView.Left - (g.MeasureString(lngJ, ft).Width) + &H1A - picContainer.Left - 42
y = ((picZPLView.Top + sngI) - ((g.MeasureString(lngJ, ft).Width)) / &H2) - picContainer.Top
g.DrawString(lngJ, ft, New SolidBrush(Color.White), x, y)
x = (picZPLView.Left + picZPLView.Width) + 18 - picContainer.Left
y = ((picZPLView.Top + sngI) - ((g.MeasureString(lngJ, ft).Width)) / &H2) - picContainer.Top
g.DrawString(lngJ, ft, New SolidBrush(Color.White), x, y)
End If
Next
picContainer.Image = fond
End If
End Sub
Private Sub cmdAction1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAction1.Click
sngZPLZoom = 6.2
picZPLView.Image = Nothing
picZPLView.Width = (txtetiquette0.Text * sngZPLZoom) + &H2
picZPLView.Height = (txtetiquette1.Text * sngZPLZoom) + &H6
Call Form_Resize()
End Sub
Private Sub cmdAction2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAction2.Click
If sngZPLZoom < 10 Then
sngZPLZoom = sngZPLZoom + 0.2
picZPLView.Image = Nothing
picZPLView.Width = (txtetiquette0.Text * sngZPLZoom) + &H2
picZPLView.Height = (txtetiquette1.Text * sngZPLZoom) + &H6
Call Form_Resize()
End If
End Sub
Private Sub cmdAction3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAction3.Click
If sngZPLZoom > 2.4 Then
sngZPLZoom = sngZPLZoom - 0.2
picZPLView.Image = Nothing
picZPLView.Width = (txtetiquette0.Text * sngZPLZoom) + &H2
picZPLView.Height = (txtetiquette1.Text * sngZPLZoom) + &H6
Call Form_Resize()
End If
End Sub
Private Sub txtetiquette0_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtetiquette0.TextChanged
If txtetiquette0.Text > 110 Then
txtetiquette0.Text = 110
End If
End Sub
End Class |
Partager