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
|
Dim BtnToutDown As Integer = 7
Private Sub BtnDown_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles BtnDown.Click
' Storyboard
Dim DownStoryboard As New Storyboard
DownStoryboard.Duration = New Duration(TimeSpan.FromMilliseconds(400))
' Créer les 7 animations et les ajoute au storyboard
Dim TabAnimation(7) As DoubleAnimation
For i As Integer = 1 To 7
' Créer les animation qui doivent descendre
TabAnimation(i) = New DoubleAnimation
TabAnimation(i).Duration = New Duration(TimeSpan.FromMilliseconds(400))
Storyboard.SetTargetName(TabAnimation(i), "Button" & i)
Storyboard.SetTargetProperty(TabAnimation(i), New PropertyPath(Canvas.TopProperty))
TabAnimation(i).To = Canvas.GetTop(Canvas1.Children(i - 1)) + 90
DownStoryboard.Children.Add(TabAnimation(i))
Next
' Créer L'animation qui remet le dernier control en place
Dim AnimReplace As New DoubleAnimation
AnimReplace.BeginTime = TimeSpan.FromMilliseconds(400)
AnimReplace.Duration = New Duration(TimeSpan.FromMilliseconds(0.00001))
Storyboard.SetTargetName(AnimReplace, "Button" & BtnToutDown)
Storyboard.SetTargetProperty(AnimReplace, New PropertyPath(Canvas.TopProperty))
AnimReplace.To = 10
DownStoryboard.Children.Add(AnimReplace)
' Mise à jour du bouton tout en bas
If BtnToutDown = 1 Then
BtnToutDown = 7
Else
BtnToutDown -= 1
End If
' Lance le storyboard
DownStoryboard.Begin(Button1)
End Sub |
Partager