Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How we can Create Eye Wink Wall Paper in VB.Net.

Author: DevASP
Download Source Code : 529_EyeWinkAnimation.zip

In this article I Will How we can Create Eye Wink Wall Paper in VB.Net. It is An Easy Think .I hope after Running Project You will like it.

Creating the Eye Wink Wall Paper in VB.net seems to be critical but In fact theses types of things are not critical. For such type of application we have the easiest way to create them using Timer component given .Net Studio.

 

To create Animated Eye Wink application Follow Some Steps and Trying to Understand Code Below.

 

1. Create new application Using File menu and Choose vb.net project.

Now you will see the form Open in your application.

 

2. Now Drag the timer component from Toolbox on your Form.

 

3. Now Double click on timer. That action will make an event of Timer.

 

4. Use the Properties window to set the individual properties of the Timer you created.

 

5. Now Initialize some Variables Before the Load Event Means Globally.

 

Const WINK_TIMER_INTERVAL As Integer = 150 ' In milliseconds

Protected arrImages(4) As Image

Protected intCurrentImage As Integer = 0

Protected j As Integer = 1

 

6. Now Double Click On Your Form. You Will See That In Code File The Auto Generated Function Appears. Which is In fact Form’s Load Event. Now you can use that Function in your own way. Write these Lines of code in forms load event.

 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim i As Integer

        For i = 0 To 3

            arrImages(i) = New Bitmap("..\Eye" & (i + 1).ToString & ".png")

        Next i

    End Sub

 

 

7. Now write this Routine which is the Auto generated Event By Timer.

 

This routine in fact Obtain the Graphics object exposed by the Form. Call DrawImage, using Overload #8, which takes the current image to be displayed, the X and Y coordinates (which, in this case centers the image in the client area), and the image's width and height. It is always a good idea to call Dispose for objects that expose this method instead of waiting for the Garbage Collector to do it for you.

 

This almost always increases the application's performance. Loop through the images. This is the last image of the four, so reverse the animationorder so that the eye closes. This is the first image of the four, so reverse the animation order so that the eye opens again.

 

 

Protected Overridable Sub TimerOnTick(ByVal obj As Object, ByVal ea As EventArgs) Handles tmrAnimation.Tick

 

        Dim grfx As Graphics = CreateGraphics()

      

        grfx.DrawImage(arrImages(intCurrentImage), _

        CInt((ClientSize.Width - arrImages(intCurrentImage).Width) / 2), _

        CInt((ClientSize.Height - arrImages(intCurrentImage).Height) / 2), _

        arrImages(intCurrentImage).Width, _

        arrImages(intCurrentImage).Height)

      

        grfx.Dispose()

 

        intCurrentImage += j

        If intCurrentImage = 3 Then

          

            j = -1

        ElseIf intCurrentImage = 0 Then

       

            j = 1

        End If

 

    End Sub

 

Now Built and run the Project Your You will see the animated Eye Wink On Your Form. The source Code is given by this article for your Complete Understanding. Just run it You Can understand How easily we can create animated Things in vb.net.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How we can Utilize Menus and Menu Items Component in Easy Way Using VB.Net

Disclaimer - Privacy
© 2002-2017 DevASP.net