Public Class Form1
Dim TailleEcran As Boolean
Dim TailleRelle As Point
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
TailleEcran = False
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
TailleRelle = Me.PictureBox1.Size
End Sub
Private Sub ButtonTailleEcran_Click(sender As System.Object, e As System.EventArgs) Handles ButtonTaileEcran.Click
Me.PictureBox1.Size = New System.Drawing.Size(Me.Panel2.Size)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
TailleEcran = True
Me.PictureBox1.Cursor = Cursors.Cross
End Sub
Private Sub ButtonTaille100Pourcent_Click(sender As System.Object, e As System.EventArgs) Handles ButtonTaille100pourcent.Click
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
TailleEcran = False
Me.PictureBox1.Cursor = Cursors.Default
End Sub
Private Sub Form1_SizeChanged(sender As System.Object, e As System.EventArgs) Handles MyBase.SizeChanged
If TailleEcran = True Then
Me.PictureBox1.Size = New System.Drawing.Size(Me.Panel2.Size)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
End If
End Sub
Dim loc_x, loc_y As Integer
Dim estEnfonce As Boolean = False
Private Sub PictureBox1_doubleClick(sender As Object, e As System.EventArgs) Handles PictureBox1.DoubleClick
Dim TaillePicture As Point = Me.PictureBox1.Size
Dim coefx As Decimal = TaillePicture.X / TailleRelle.X
Dim coefy As Decimal = TaillePicture.y / TailleRelle.y
Me.PictureBox1.Size = New System.Drawing.Size(TailleRelle)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
TailleEcran = False
Me.PictureBox1.Cursor = Cursors.Default
Dim x = (loc_x / coefx)
Dim y = (loc_y / coefy)
Panel2.AutoScrollPosition = New Point(x, y)
Panel2.Refresh()
End Sub
Private Sub PictureBox1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
If e.Button = MouseButtons.Left Then
estEnfonce = True
loc_x = e.X
loc_y = e.Y
End If
End Sub
Private Sub PictureBox1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If estEnfonce Then
Dim x = (loc_x - e.X) - Panel2.AutoScrollPosition.X
Dim y = (loc_y - e.Y) - Panel2.AutoScrollPosition.Y
Panel2.AutoScrollPosition = New Point(x, y)
Panel2.Refresh()
End If
End Sub
Private Sub PictureBox1_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
If e.Button = MouseButtons.Left Then
estEnfonce = False
End If
End Sub
End Class