Public Class Form2
Dim gif As Bitmap = New Bitmap("C:\arrived.gif")
Dim intFreamCount As Long
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If ImageAnimator.CanAnimate(gif) Then
ImageAnimator.Animate(gif, New EventHandler(AddressOf gif_FrameChanged))
End If
End Sub
Private Sub gif_StoAnimation(ByVal sender As Object, ByVal e As EventArgs)
MessageBox.Show("Done")
End Sub
Private Sub gif_FrameChanged(ByVal sender As Object, ByVal e As EventArgs)
intFreamCount += 1
If intFreamCount > gif.GetFrameCount(FrameDimension.Time) Then
ImageAnimator.StopAnimate(gif, New EventHandler(AddressOf gif_StoAnimation))
Else
Me.Invalidate()
End If
End Sub
Private Sub AnimationForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
ImageAnimator.UpdateFrames(gif)
Dim g As Graphics = e.Graphics
Dim rect As Rectangle = Me.ClientRectangle
rect.Height = rect.Height
g.DrawImage(gif, rect)
End Sub
End Class
|