Esempio n. 1
0
        /// <summary>
        /// The display timer event handler that handles updating the contents of the splash screen,
        /// fading it in and out, cleaning it up when it's been dismissed, and signalling the dismiss
        /// timer to end.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private static void OnDisplayTimer(object sender, EventArgs e)
        {
            // Shared resource access follows
            mutex.WaitOne();

            if (_splashScreen != null)
            {
                // Send the splash screen to the back if there's a licensing error
                //if (Sentinelle.Aegis.Model.AegisSessionManager.LicenseError)
                //	_splashScreen.SendToBack();

                // Update the status
                _splashScreen.UpdateStatusText(_status);

                // Update the license
                if (_updateLicenseText)
                {
                    _splashScreen.UpdateLicenseText(_licenseText);
                    _updateLicenseText = false;
                }

                // Update the icons
                while (_assemblies.Count > 0)
                {
                    _splashScreen.AddAssemblyIcon(_assemblies[0]);
                    _assemblies.RemoveAt(0);
                }

                if (_closing)
                {
                    // Wait a fixed amount of time before actually closing the splash screen
                    int timeElapsedSinceClose = Environment.TickCount - _closeStartTime;
                    if (timeElapsedSinceClose >= CloseDelay)
                    {
                        // Fade out, if necessary
                        if (_splashScreen.Opacity > 0)
                        {
                            _splashScreen.UpdateOpacity(_splashScreen.Opacity - OpacityDelta);
                        }
                        else
                        {
                            // We've faded out - flag the dismiss timer to stop
                            _stopDismissTimer = true;
                        }
                    }
                }
                else
                {
                    // Fade in, if necessary
                    if (_splashScreen.Opacity < 1)
                    {
                        _splashScreen.UpdateOpacity(_splashScreen.Opacity + OpacityDelta);
                    }
                }
            }

            // Check to see if it's time to stop the display timer
            if (_stopDisplayTimer)
            {
                // Stop the timer
                _displayTimer.Stop();
                _displayTimer = null;

                // Close the splash screen
                if (_splashScreen != null)
                {
                    _splashScreen.Close();
                    _splashScreen.Dispose();
                    _splashScreen = null;
                }

                // Destroy the thread
                _displayThread = null;
            }

            mutex.ReleaseMutex();
        }