Changeset 3113
- Timestamp:
- 03/19/10 12:54:40 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.PluginInfrastructure/Starter
- Files:
-
- 2 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 } -
trunk/sources/HeuristicLab.PluginInfrastructure/Starter/StarterForm.cs
r3092 r3113 45 45 private bool abortRequested; 46 46 private PluginManager pluginManager; 47 private SplashScreen splashScreen; 47 48 48 49 /// <summary> … … 56 57 string pluginPath = Path.GetFullPath(Application.StartupPath); 57 58 pluginManager = new PluginManager(pluginPath); 58 SplashScreen splashScreen = new SplashScreen(pluginManager, 1000, "Loading HeuristicLab...");59 splashScreen.Show( );59 splashScreen = new SplashScreen(pluginManager, 1000); 60 splashScreen.Show("Loading HeuristicLab..."); 60 61 61 62 pluginManager.DiscoverAndCheckPlugins(); … … 129 130 130 131 private void StartApplication(ApplicationDescription app) { 131 SplashScreen splashScreen = new SplashScreen(pluginManager, 2000, "Loading " + app.Name);132 splashScreen.Show( );132 //new SplashScreen(pluginManager, 2000, ); 133 splashScreen.Show("Loading " + app.Name); 133 134 Thread t = new Thread(delegate() { 134 135 bool stopped = false;
Note: See TracChangeset
for help on using the changeset viewer.