CamTimer.NotifyForm.AnimateIn C# (CSharp) Method

AnimateIn() private method

private AnimateIn ( ) : void
return void
        private void AnimateIn()
        {
            if (m_windowAnimator == null) {
                Rectangle screenBounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds;

                m_windowAnimator = new Thread((ThreadStart)delegate() {
                    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-(Width-newLeft);
                            });
                        } catch (Exception) { }
                        if (elapsedMSec >= s_animationDurationMSec) {
                            break;
                        }

                        Thread.Sleep((int)(1000 / 33d));	// 33 fps
                    }

                    m_windowAnimator = null;
                    try {
                        Invoke((MethodInvoker)delegate() {
                            TakePicture();
                        });
                    } catch (Exception) { }
                });
                NativeMethods.SetWindowPos(this.Handle, NativeMethods.HWND_TOPMOST, screenBounds.Right, screenBounds.Top + 100, 0, 0, NativeMethods.SWP_NOACTIVATE | NativeMethods.SWP_NOSIZE | NativeMethods.SWP_SHOWWINDOW);
                Visible = true;
                m_windowAnimator.Start();
            }
        }