- Timestamp:
- 03/19/10 12:54:40 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure/Starter/SplashScreen.cs
r2922 r3113 36 36 private int initialInterval; 37 37 private PluginManager manager; 38 38 private bool fadeOutForced; 39 39 internal SplashScreen() { 40 40 InitializeComponent(); 41 41 } 42 42 43 internal SplashScreen(PluginManager manager, int initialInterval , string initialText)43 internal SplashScreen(PluginManager manager, int initialInterval) 44 44 : this() { 45 45 this.initialInterval = initialInterval; … … 53 53 manager.PluginUnloaded += new EventHandler<PluginInfrastructureEventArgs>(manager_PluginUnloaded); 54 54 55 infoLabel.Text = initialText;56 55 titleLabel.Text = Application.ProductName; 57 56 versionLabel.Text = "Version " + Application.ProductVersion; … … 96 95 } 97 96 97 public void Show(string initialText) { 98 if (InvokeRequired) Invoke((Action<string>)Show, initialText); 99 else { 100 Opacity = 1; 101 infoLabel.Text = initialText; 102 fadeOutForced = false; 103 ResetFadeTimer(); 104 Show(); 105 } 106 } 107 108 private void ResetFadeTimer() { 109 // wait initialInterval again for the first tick 110 fadeTimer.Stop(); 111 fadeTimer.Interval = initialInterval; 112 fadeTimer.Start(); 113 } 114 115 98 116 private void SetInfoText(string text) { 99 117 if (InvokeRequired) Invoke((Action<string>)SetInfoText, text); … … 107 125 Invoke((Action<string>)UpdateMessage, msg); 108 126 } else { 109 ResetFadeTimer(); 127 // when the user forced a fade-out (by closing the splashscreen) 128 // don't reset the fadeTimer 129 if (!fadeOutForced) { 130 ResetFadeTimer(); 131 } 110 132 SetInfoText(msg); 111 133 Application.DoEvents(); // force immediate update of splash screen control … … 113 135 } 114 136 115 private void ResetFadeTimer() { 116 fadeTimer.Stop(); fadeTimer.Start(); 137 // each tick of the timer reduce opacity and restart timer 138 private void fadeTimer_Elapsed(object sender, EventArgs e) { 139 FadeOut(); 117 140 } 118 141 119 private void fadeTimer_Elapsed(object sender, EventArgs e) { 120 FadeOutAndClose(); 121 } 122 123 private void FadeOutAndClose() { 142 // reduces opacity of the splashscreen one step and restarts the fade-timer 143 private void FadeOut() { 124 144 fadeTimer.Stop(); 125 145 fadeTimer.Interval = FADE_INTERVAL; … … 130 150 Opacity = 0; 131 151 fadeTimer.Stop(); 132 fadeTimer.Dispose(); 133 // remove event before calling close 134 manager.ApplicationStarted -= new EventHandler<PluginInfrastructureEventArgs>(manager_ApplicationStarted); 135 manager.ApplicationStarting -= new EventHandler<PluginInfrastructureEventArgs>(manager_ApplicationStarting); 136 manager.Initializing -= new EventHandler<PluginInfrastructureEventArgs>(manager_Initialized); 137 manager.Initialized -= new EventHandler<PluginInfrastructureEventArgs>(manager_Initializing); 138 manager.PluginLoaded -= new EventHandler<PluginInfrastructureEventArgs>(manager_PluginLoaded); 139 manager.PluginUnloaded -= new EventHandler<PluginInfrastructureEventArgs>(manager_PluginUnloaded); 140 Close(); 152 Hide(); 141 153 } 142 154 } 143 155 156 // force fade out 144 157 private void closeButton_Click(object sender, EventArgs e) { 145 FadeOutAndClose(); 158 fadeOutForced = true; 159 FadeOut(); 146 160 } 147 161 }
Note: See TracChangeset
for help on using the changeset viewer.