I want to create an usercontrol that displays a programmatically generated animation.
As a minimalistic example, here is how its currently laid out:
Public Class AnimatedUC
Public WithEvents tim as new Timers.Timer With {.Interval = 40}
Public Sub New()
InitializeComponent()
'do other initialization here like loading fonts and images to be stored in private class fields
If Not System.ComponentModel.LicenseManager.UsageMode = System.ComponentModel.LicenseUsageMode.Designtime Then
tim.Enabled = true
End If
End Sub
Public Sub DrawAnim() Handles tim.Elapsed
'draw a frame of the animation using loaded images and fonts
End Sub
End Class
The fonts and images are stored in the project resources, at first I had the UC throwing errors because it couldn't use them during design time even though they loaded up fine (i think). Then, I had a problem with the timer running in the design time which caused it to draw one frame and then crash VS. Then, after arriving in the state its in now, the UC doesn't do anything anymore. If I put a messagebox in the If block thats inside the constructor, it draws one frame, If i don't, It doesn't do anything.
What would be the way to run the animation timer so it would work?
Aucun commentaire:
Enregistrer un commentaire