I'm using a timer to create a Splash Screen.
What I want to do is to make the form fade-in and fade-out. I started with making the form opacity 0 in the form's constructor, and by triggering the timer in the Form load method.
Now in my Timer_Tick
method, I keep increasing the opacity by, say, 0.2.
I figured that I'd start decreasing the opacity once the timer hits half its interval, but I'm unable to do that.
I'm not very clear with how the timer works as it is, but I wanted to implement something like this:
if(Whatever_Timer_Value_Is <= Interval/2) //Can't achieve this :s
this.Opacity += 2;
else
this.Opacity -=2 ;
So..is there a way to get the value of the Timer at any instant? Or is there any other way to do this? Please keep it simple. I'm just an amateur. X(
have a look to this, a sample for a splash screen in c#: http://www.codeproject.com/Articles/5454/A-Pretty-Good-Splash-Screen-in-C
Try this method suggested by Servy in this post. I have modified method for Form Fade-Out to hide form.
Try creating a second form for splash:
Just remember the time when you start the timer. That way you can always tell how much time has passed.
You can use
Environment.TickCount
for that. This is a monotonic clock.Incremental computations (like
Opacity += 0.2;
) are to be avoided in timers because it is not guaranteed to receive all ticks or too receive them at the right points in time. You better calculate how much time has passed and calculate the right opacity value from that.