Private Sub animation(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) If anime_counter < counter Then Dim daX As New DoubleAnimation Dim daY As New DoubleAnimation If anime_counter = 0 Then daX.From = Pict1.Margin.Left daY.From = Pict1.Margin.Top Else daX.From = path(anime_counter - 1).X - Pict1.Margin.Left daY.From = path(anime_counter - 1).Y - Pict1.Margin.Top End If daX.To = path(anime_counter).X - Pict1.Margin.Left daY.To = path(anime_counter).Y - Pict1.Margin.Top Dim pixelsPerSecond As Double = 200 Dim distance As Double = Math.Sqrt((daX.To - daX.From) * (daX.To - daX.From) + (daY.To - daY.From) * (daY.To - daY.From)) daX.Duration = TimeSpan.FromSeconds(distance / pixelsPerSecond) daY.Duration = TimeSpan.FromSeconds(distance / pixelsPerSecond) AddHandler daX.Completed, AddressOf animation Dim tt As New TranslateTransform Pict1.RenderTransform = tt tt.BeginAnimation(TranslateTransform.XProperty, daX) tt.BeginAnimation(TranslateTransform.YProperty, daY) anime_counter += 1 Else anime_counter = 0 End If End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)