Beispiel #1
0
		public static void ShowSplash(int fadeinTime,bool showVersion) {
			//	Only show if not showing already
			if (Instance == null) {
				Instance = new Splash();
                Instance.ShowVersionBox = showVersion;
				
				//	Hide initially so as to avoid a nasty pre paint flicker
				Instance.Opacity = 0;
				Instance.Show();
				
				//	Process the initial paint events
				Application.DoEvents();
				
				// Perform the fade in
				if (fadeinTime > 0) {
					//	Set the timer interval so that we fade out at the same speed.
					int fadeStep = (int)System.Math.Round((double)fadeinTime/20);
					Instance.fadeTimer.Interval = fadeStep;

					for (int i = 0; i <= fadeinTime; i += fadeStep){
						System.Threading.Thread.Sleep(fadeStep);
						Instance.Opacity += 0.05;
					}
				} else {
					//	Set the timer interval so that we fade out instantly.
					Instance.fadeTimer.Interval = 1;
				}
				Instance.Opacity = 1;
			}
		}
Beispiel #2
0
		protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
		{
			base.OnClosing(e);
			
			//	Close immediatly is the timer interval is set to 1 indicating no fade.
			if (this.fadeTimer.Interval == 1) {
				e.Cancel = false;
				return;
			}

			//	Only use the timer to fade out if we have a mainform running otherwise there will be no message pump
			if (Application.OpenForms.Count > 1) {
				if (this.Opacity > 0) {
					e.Cancel = true;
					this.Opacity -= 0.05;
					
					//	use the timer to iteratively call the close method thereby keeping the GUI thread available for other processes.
					this.fadeTimer.Tick -= new System.EventHandler(this.FadeoutTick);
					this.fadeTimer.Tick += new System.EventHandler(this.FadeoutTick);
					this.fadeTimer.Start();
				} else {
					e.Cancel = false;
					this.fadeTimer.Stop();
					
					//	Clear the instance variable so we can reshow the splash, and ensure that we don't try to close it twice
					Instance = null;
				}
			} else {
				if (this.Opacity > 0) {
					//	Sleep on this thread to slow down the fade as there is no message pump running
					System.Threading.Thread.Sleep(this.fadeTimer.Interval);
					Instance.Opacity -= 0.05;
					
					//	iteratively call the close method
					this.Close();
				} else {
					e.Cancel = false;

					//	Clear the instance variable so we can reshow the splash, and ensure that we don't try to close it twice
					Instance = null;
				}
			}
				
		}	
Beispiel #3
0
		protected override void OnClick(System.EventArgs e) {
			//	If we are displaying as a about dialog we need to provide a way out.
			this.Close();
            Instance.Dispose();
            Instance = null;
		}