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
|
Public Class Form1
Private _zone As New System.Drawing.Rectangle(0, 0, 100, 100)
Private _imgsombre As System.Drawing.Image = Image.FromFile("C:\Users\Stève\Desktop\testCalqueNoir\sombre.png")
Private _imgclaire As System.Drawing.Image = Image.FromFile("C:\Users\Stève\Desktop\testCalqueNoir\normal.png")
Private _move As Boolean = False
Private _ecartX As Integer
Private _ecartY As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox1.Image = _imgsombre
End Sub
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
e.Graphics.DrawImage(_imgsombre, PictureBox1.ClientSize)
e.Graphics.DrawImage(_imgclaire, _zone, _zone, GraphicsUnit.Pixel)
End Sub
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
_move = True
_ecartX = e.X - _zone.X
_ecartY = e.Y - _zone.Y
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If _move = True Then
If _zone.Contains(New Point(e.X, e.Y)) Then
_zone = New System.Drawing.Rectangle(e.X - _ecartX, e.Y - _ecartY, 100, 100)
PictureBox1.Refresh()
End If
End If
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
_move = False
End Sub
End Class |
Partager