In dieser PictureBox kann man animierte GIF Bilder einfügen um diese dann auch animiert anzuzeigen.
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Public Class GifAnimator
Inherits PictureBox
Private mImage As Image
Public Sub New()
Me.SetStyle(ControlStyles.DoubleBuffer Or _
ControlStyles.UserPaint Or _
ControlStyles.AllPaintingInWmPaint, True)
End Sub
Public Shadows Property Image() As Image
Get
Return mImage
End Get
Set(ByVal value As Image)
mImage = value
ImageAnimator.Animate(value, New EventHandler(AddressOf Me.AnimateHandler))
End Set
End Property
Public Sub AnimateHandler(ByVal sender As Object, ByVal e As EventArgs)
Me.Invalidate()
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
If Me.Image IsNot Nothing Then
ImageAnimator.UpdateFrames()
e.Graphics.DrawImage(Me.Image, 0, 0)
End If
End Sub
End Class
Kommentare zum Snippet