private void CountdownTimerSetup()
{
if (m_countdownTimer == null) {
Rectangle screenBounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
m_countdownTimer = new Thread((ThreadStart)delegate() {
int x = 0;
while (true) {
if (!Visible) {
break;
} else if (Bounds.Contains(Cursor.Position)) {
x = 0;
Thread.Sleep(1000);
} else if (x < 5) {
x++;
Thread.Sleep(1000);
} else {
break;
}
}
int startMSec = System.Environment.TickCount;
while (true) {
int elapsedMSec = System.Environment.TickCount - startMSec;
double percentRemaining = 1 - (Math.Min(elapsedMSec, s_animationDurationMSec) / (double)s_animationDurationMSec);
int newLeft = (int)(Math.Min(percentRemaining * percentRemaining * percentRemaining, 1) * Width);
try {
Invoke((MethodInvoker)delegate() {
Left = screenBounds.Right - newLeft;
});
} catch (Exception) { }
if (elapsedMSec >= s_animationDurationMSec) {
break;
}
Thread.Sleep((int)(1000 / 33d)); // 33 fps
}
m_countdownTimer = null;
try {
Invoke((MethodInvoker)delegate() {
Close();
});
} catch (Exception) { }
});
m_countdownTimer.Start();
}
}