/// <summary> /// An entry point for the display thread that creates a splash screen form and begins a /// timer to handle fading it in and out and updating it. A timer is used so that the /// splash screen form accessed through the same thread it was created in. This avoids /// cross-threading form exceptions. /// </summary> private static void CreateSplashScreen() { // Shared resource access follows mutex.WaitOne(); // Create the splash screen _splashScreen = new SplashScreen(); // Reset the 'stop timer' flags _stopDismissTimer = false; _stopDisplayTimer = false; mutex.ReleaseMutex(); // Initialize the display timer _displayTimer = new System.Windows.Forms.Timer(); _displayTimer.Tick += new EventHandler(OnDisplayTimer); _displayTimer.Interval = TimerInterval; _displayTimer.Start(); System.Windows.Forms.Application.Run(_splashScreen); }
/// <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(); }
private void Initialize() { // No status at first SetStatusText(string.Empty); // Initialize the version text to the executing assembly's _version.Text = String.Format(SplashScreenSettings.Default.VersionTextFormat, ProductInformation.GetVersion(true, true, true)); //_copyright.Text = ProductInformation.Copyright; _copyright.Text = " 2014 Inc. All rights reserved."; _license.Text = ProductInformation.License; // Make the window completely transparent Opacity = 0; // Set the manifest warning. _manifest.Visible = !ManifestVerification.Valid; // Apply any splash screen settings, if requested if (SplashScreenSettings.Default.UseSplashScreenSettings) { this.SuspendLayout(); try { var stream = SplashScreen.OpenSplashImageResourceStream(); if (stream != null) { // GDI+ resource management quirk: don't dispose the source stream (or create an independent copy of the bitmap) BackgroundImage = new Bitmap(stream); ClientSize = BackgroundImage.Size; } } catch (Exception ex) { Platform.Log(LogLevel.Warn, ex, "Failed to resolve splash screen resources."); } this._status.Visible = SplashScreenSettings.Default.StatusVisible; this._status.Location = SplashScreenSettings.Default.StatusLocation; this._status.Size = SplashScreenSettings.Default.StatusSize; this._status.AutoSize = SplashScreenSettings.Default.StatusAutoSize; this._status.ForeColor = SplashScreenSettings.Default.StatusForeColor; this._status.Font = SplashScreenSettings.Default.StatusFontBold ? new Font(this._status.Font, FontStyle.Bold) : this._status.Font; this._status.TextAlign = SplashScreenSettings.Default.StatusTextAlign; this._copyright.Visible = SplashScreenSettings.Default.CopyrightVisible; this._copyright.Location = SplashScreenSettings.Default.CopyrightLocation; this._copyright.Size = SplashScreenSettings.Default.CopyrightSize; this._copyright.AutoSize = SplashScreenSettings.Default.CopyrightAutoSize; this._copyright.ForeColor = SplashScreenSettings.Default.CopyrightForeColor; this._copyright.Font = SplashScreenSettings.Default.CopyrightFontBold ? new Font(this._copyright.Font, FontStyle.Bold) : this._copyright.Font; this._copyright.TextAlign = SplashScreenSettings.Default.CopyrightTextAlign; this._version.Visible = SplashScreenSettings.Default.VersionVisible; this._version.Location = SplashScreenSettings.Default.VersionLocation; this._version.Size = SplashScreenSettings.Default.VersionSize; this._version.AutoSize = SplashScreenSettings.Default.VersionAutoSize; this._version.ForeColor = SplashScreenSettings.Default.VersionForeColor; this._version.Font = SplashScreenSettings.Default.VersionFontBold ? new Font(this._version.Font, FontStyle.Bold) : this._version.Font; this._version.TextAlign = SplashScreenSettings.Default.VersionTextAlign; this._license.Visible = SplashScreenSettings.Default.LicenseVisible; this._license.Location = SplashScreenSettings.Default.LicenseLocation; this._license.Size = SplashScreenSettings.Default.LicenseSize; this._license.AutoSize = SplashScreenSettings.Default.LicenseAutoSize; this._license.ForeColor = SplashScreenSettings.Default.LicenseForeColor; this._license.Font = SplashScreenSettings.Default.LicenseFontBold ? new Font(this._license.Font, FontStyle.Bold) : this._license.Font; this._license.TextAlign = SplashScreenSettings.Default.LicenseTextAlign; this._manifest.Location = SplashScreenSettings.Default.ManifestLocation; this._manifest.Size = SplashScreenSettings.Default.ManifestSize; this._manifest.AutoSize = SplashScreenSettings.Default.ManifestAutoSize; this._manifest.ForeColor = SplashScreenSettings.Default.ManifestForeColor; this._manifest.Font = SplashScreenSettings.Default.ManifestFontBold ? new Font(this._manifest.Font, FontStyle.Bold) : this._manifest.Font; this._manifest.TextAlign = SplashScreenSettings.Default.ManifestTextAlign; this._pluginIconsRectangle = SplashScreenSettings.Default.PluginIconsRectangle; this._nextIconPositionX = _pluginIconsRectangle.Left + IconPaddingX / 2; this._nextIconPositionY = _pluginIconsRectangle.Top; this.ResumeLayout(); } }