Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' --------------------------------------------------------------------
- ' Class File: frmAnimation.vb
- '---------------------------------------------------------------------
- Imports System.Drawing.Imaging
- Public Class frmAnimation
- Private animation As Bitmap = Nothing
- Private animationFrames As Integer = 0
- Private currentFrame As Integer = 0
- Private animationMaxLoops As Integer = 1
- Private loops As Integer = 0
- Public Sub New()
- InitializeComponent()
- animation = My.Resources.icon_confirmation
- PictureBox1.Size = animation.Size
- End Sub
- Protected Overrides Sub OnShown(e As EventArgs)
- MyBase.OnShown(e)
- animationFrames = animation.GetFrameCount(New FrameDimension(animation.FrameDimensionsList(0)))
- AnimateImage()
- End Sub
- Public Sub AnimateImage()
- If ImageAnimator.CanAnimate(animation) Then
- ImageAnimator.Animate(animation, AddressOf OnFrameChanged)
- End If
- End Sub
- Private Sub OnFrameChanged(o As Object, e As EventArgs)
- If currentFrame >= animationFrames Then
- currentFrame = 0
- loops += 1
- If loops >= animationMaxLoops Then
- animationFrames = 0
- loops = 0
- animation?.Dispose()
- ImageAnimator.StopAnimate(animation, AddressOf OnFrameChanged)
- End If
- Else
- PictureBox1.Invalidate()
- currentFrame += 1
- End If
- End Sub
- Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
- If animationFrames > 0 Then
- ImageAnimator.UpdateFrames()
- e.Graphics.DrawImage(animation, New Point(0, 0))
- End If
- End Sub
- Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
- Close()
- End Sub
- End Class
- ' --------------------------------------------------------------------
- ' Designer File: frmAnimation.Designer.vb
- '---------------------------------------------------------------------
- <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
- Partial Class frmAnimation
- Inherits System.Windows.Forms.Form
- <System.Diagnostics.DebuggerNonUserCode()>
- Protected Overrides Sub Dispose(ByVal disposing As Boolean)
- Try
- If disposing AndAlso components IsNot Nothing Then
- components.Dispose()
- End If
- Finally
- MyBase.Dispose(disposing)
- End Try
- End Sub
- Private components As System.ComponentModel.IContainer
- <System.Diagnostics.DebuggerStepThrough()>
- Private Sub InitializeComponent()
- Me.PictureBox1 = New System.Windows.Forms.PictureBox()
- Me.btnClose = New System.Windows.Forms.Button()
- Me.Panel1 = New System.Windows.Forms.Panel()
- CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
- Me.Panel1.SuspendLayout()
- Me.SuspendLayout()
- '
- 'PictureBox1
- '
- Me.PictureBox1.Location = New System.Drawing.Point(0, 0)
- Me.PictureBox1.Name = "PictureBox1"
- Me.PictureBox1.Size = New System.Drawing.Size(513, 333)
- Me.PictureBox1.TabIndex = 80
- Me.PictureBox1.TabStop = False
- '
- 'btnClose
- '
- Me.btnClose.Anchor = System.Windows.Forms.AnchorStyles.Bottom
- Me.btnClose.BackColor = System.Drawing.Color.FromArgb(CType(CType(48, Byte), Integer), CType(CType(48, Byte), Integer), CType(CType(48, Byte), Integer))
- Me.btnClose.FlatAppearance.BorderSize = 0
- Me.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.Flat
- Me.btnClose.Location = New System.Drawing.Point(213, 6)
- Me.btnClose.Name = "btnClose"
- Me.btnClose.Size = New System.Drawing.Size(116, 33)
- Me.btnClose.TabIndex = 81
- Me.btnClose.Text = "Close"
- Me.btnClose.UseVisualStyleBackColor = False
- '
- 'Panel1
- '
- Me.Panel1.Controls.Add(Me.btnClose)
- Me.Panel1.Dock = System.Windows.Forms.DockStyle.Bottom
- Me.Panel1.Location = New System.Drawing.Point(0, 333)
- Me.Panel1.Name = "Panel1"
- Me.Panel1.Size = New System.Drawing.Size(512, 46)
- Me.Panel1.TabIndex = 82
- '
- 'frmAnimation
- '
- Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!)
- Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi
- Me.AutoSize = True
- Me.BackColor = System.Drawing.Color.FromArgb(CType(CType(32, Byte), Integer), CType(CType(32, Byte), Integer), CType(CType(32, Byte), Integer))
- Me.ClientSize = New System.Drawing.Size(512, 379)
- Me.Controls.Add(Me.Panel1)
- Me.Controls.Add(Me.PictureBox1)
- Me.Font = New System.Drawing.Font("Segoe UI", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
- Me.ForeColor = System.Drawing.Color.White
- Me.Name = "frmAnimation"
- Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
- Me.Text = "frmAnimation"
- CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
- Me.Panel1.ResumeLayout(False)
- Me.ResumeLayout(False)
- End Sub
- Private WithEvents PictureBox1 As PictureBox
- Friend WithEvents btnClose As Button
- Friend WithEvents Panel1 As Panel
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement