开发者

page turning animation

I am building an application. This shows a form, header and footer are to be kept fixed.

In 开发者_高级运维the middle there is a Group Box that hold a question with different option. When user clicks Next button at the bottom, Group Box loads next question. I want to make this change animated. I wish to show a page-turning animation that runs when Next button is clicked...................

Please help Thanks Furqan


There is a very nicely written tutorial for doing this in C# and GDI but it's fairly complicated.

There is also a simpler tutorial, also on CodeProject, for doing this with Silverlight.


How to create a Loading screen in VB.Net

To create a loading screen you need to understand the ‘BackgroundWorker’ which is part of the Imports System.ComponentModel

  1. Create a Loading form with your loading message and picture. This form will act as a popup form
  2. I called my form ‘frmPleaseWait’ and placed the following code in it

Public Class frmPleaseWait

Private _worker As BackgroundWorker

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
    MyBase.OnLoad(e)
    _worker = New BackgroundWorker()
    AddHandler _worker.DoWork, AddressOf WorkerDoWork
    AddHandler _worker.RunWorkerCompleted, AddressOf WorkerCompleted
    _worker.RunWorkerAsync()
End Sub

Private Sub WorkerDoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
    Threading.Thread.Sleep(5000)
    'your loading animation code goes here
End Sub

Private Sub WorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs)
    Me.DialogResult = Windows.Forms.DialogResult.OK
    Me.Close()
End Sub

End Class

  1. In your main form in between the code that’s taking the processing time place
Dim frm As New frmPleaseWait
frm.ShowDialog()
'your time consuming main processing code goes here
frm.Close()
  1. That’s all, if you want to make the popup form appear longer then change the threading time in WorkerDoWork method.

@Furqan, in your case, in this section you need to put your animation code in the WorkerDoWork method

Dont forget to use Imports System.ComponentModel at the top of the loading form class

Thanks Eddy Jawed

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜