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
| Public Class frmPicturesAnimes
'liste des picbox =>contient toutes les rangees
Private Pictures As New List(Of PictureBox)
'vitesse de defilement
Private VelocityX As Integer = 5
Public Sub New()
' Cet appel est requis par le concepteur.
InitializeComponent()
' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
Me.ResizeRedraw = True
Me.AutoScroll = True
Me.DoubleBuffered = True
AddPictures()
Timer1.Interval = 10
End Sub
Private Sub AddPictures()
For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is PictureBox Then
Dim itemPic As PictureBox = CType(ctrl, PictureBox)
itemPic.Tag = itemPic.BackColor
Pictures.Add(itemPic)
End If
Next
End Sub
'liste des picbox =>contient la rangee cliquee
Private PicturesClicked As New List(Of PictureBox)
Private Sub PictureBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick,
PictureBox2.MouseClick, PictureBox3.MouseClick, PictureBox4.MouseClick,
PictureBox5.MouseClick, PictureBox6.MouseClick, PictureBox8.MouseClick,
PictureBox9.MouseClick, PictureBox10.MouseClick
Dim tagColor As Object = Nothing
tagColor = CType(sender, PictureBox).Tag
PicturesClicked.Clear()
For Each itemPic As PictureBox In Pictures
If itemPic.Tag = tagColor Then
PicturesClicked.Add(itemPic)
End If
Next
Timer1.Enabled = Not Timer1.Enabled
Me.Text = CType(sender, PictureBox).Name + " ," + tagColor.ToString
End Sub
Private flag As Boolean = True
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'DEFILEMENT ÀVANT (DROITE)
For Each itemPic As PictureBox In PicturesClicked
itemPic.Left += VelocityX
Next
'RE-APPARITON A GAUCHE
Dim pic As PictureBox = PicturesClicked(PicturesClicked.Count - 1)
If pic.Left > Me.Right Then ' si dernier pic a disparu à droite
'on les replace au bord gauche du form...
For Each item As PictureBox In PicturesClicked
item.Left -= Me.Width
Next
End If
End Sub
Private Sub frmImageAnimes_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
Pictures.Clear()
For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is PictureBox Then
Dim itemPic As PictureBox = CType(ctrl, PictureBox)
itemPic.Tag = itemPic.BackColor
Pictures.Add(itemPic)
End If
Next
End Sub
End Class |
Partager