- Timestamp:
- 09/27/10 14:01:04 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Starter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Starter/SplashScreen.cs
r4482 r4515 32 32 private Timer fadeTimer; 33 33 private int initialInterval; 34 private PluginManager pluginManager; 34 35 35 36 internal SplashScreen() { … … 40 41 : this() { 41 42 this.initialInterval = initialInterval; 43 this.pluginManager = manager; 42 44 43 manager.ApplicationStarted += new EventHandler<PluginInfrastructureEventArgs>(manager_ApplicationStarted); 44 manager.ApplicationStarting += new EventHandler<PluginInfrastructureEventArgs>(manager_ApplicationStarting); 45 manager.Initializing += new EventHandler<PluginInfrastructureEventArgs>(manager_Initializing); 46 manager.Initialized += new EventHandler<PluginInfrastructureEventArgs>(manager_Initialized); 47 manager.PluginLoaded += new EventHandler<PluginInfrastructureEventArgs>(manager_PluginLoaded); 48 manager.PluginUnloaded += new EventHandler<PluginInfrastructureEventArgs>(manager_PluginUnloaded); 45 RegisterPluginManagerEventHandlers(); 49 46 50 47 FileVersionInfo pluginInfrastructureVersion = FileVersionInfo.GetVersionInfo(GetType().Assembly.Location); … … 60 57 } 61 58 62 void manager_PluginUnloaded(object sender, PluginInfrastructureEventArgs e) { 63 UpdateMessage("Unloaded " + e.Entity); 59 #region events 60 private void RegisterPluginManagerEventHandlers() { 61 pluginManager.ApplicationStarted += new EventHandler<PluginInfrastructureEventArgs>(manager_ApplicationStarted); 62 pluginManager.ApplicationStarting += new EventHandler<PluginInfrastructureEventArgs>(manager_ApplicationStarting); 63 pluginManager.Initializing += new EventHandler<PluginInfrastructureEventArgs>(manager_Initializing); 64 pluginManager.Initialized += new EventHandler<PluginInfrastructureEventArgs>(manager_Initialized); 65 pluginManager.PluginLoaded += new EventHandler<PluginInfrastructureEventArgs>(manager_PluginLoaded); 66 pluginManager.PluginUnloaded += new EventHandler<PluginInfrastructureEventArgs>(manager_PluginUnloaded); 64 67 } 65 68 66 void manager_PluginLoaded(object sender, PluginInfrastructureEventArgs e) { 67 UpdateMessage("Loaded " + e.Entity); 69 private void DeregisterPluginManagerEventHandlers() { 70 pluginManager.ApplicationStarted -= new EventHandler<PluginInfrastructureEventArgs>(manager_ApplicationStarted); 71 pluginManager.ApplicationStarting -= new EventHandler<PluginInfrastructureEventArgs>(manager_ApplicationStarting); 72 pluginManager.Initializing -= new EventHandler<PluginInfrastructureEventArgs>(manager_Initializing); 73 pluginManager.Initialized -= new EventHandler<PluginInfrastructureEventArgs>(manager_Initialized); 74 pluginManager.PluginLoaded -= new EventHandler<PluginInfrastructureEventArgs>(manager_PluginLoaded); 75 pluginManager.PluginUnloaded -= new EventHandler<PluginInfrastructureEventArgs>(manager_PluginUnloaded); 68 76 } 69 77 70 void manager_Initialized(object sender, PluginInfrastructureEventArgs e) {71 UpdateMessage("Initialized");78 private void manager_PluginUnloaded(object sender, PluginInfrastructureEventArgs e) { 79 SafeUpdateMessage("Unloaded " + e.Entity); 72 80 } 73 81 74 void manager_Initializing(object sender, PluginInfrastructureEventArgs e) {75 UpdateMessage("Initializing");82 private void manager_PluginLoaded(object sender, PluginInfrastructureEventArgs e) { 83 SafeUpdateMessage("Loaded " + e.Entity); 76 84 } 77 85 78 void manager_ApplicationStarting(object sender, PluginInfrastructureEventArgs e) {79 UpdateMessage("Starting " + e.Entity);86 private void manager_Initialized(object sender, PluginInfrastructureEventArgs e) { 87 SafeUpdateMessage("Initialized"); 80 88 } 81 89 82 void manager_ApplicationStarted(object sender, PluginInfrastructureEventArgs e) {83 UpdateMessage("Started " + e.Entity);90 private void manager_Initializing(object sender, PluginInfrastructureEventArgs e) { 91 SafeUpdateMessage("Initializing"); 84 92 } 93 94 private void manager_ApplicationStarting(object sender, PluginInfrastructureEventArgs e) { 95 SafeUpdateMessage("Starting " + e.Entity); 96 } 97 98 private void manager_ApplicationStarted(object sender, PluginInfrastructureEventArgs e) { 99 SafeUpdateMessage("Started " + e.Entity); 100 } 101 // called from event handlers 102 private void SafeUpdateMessage(string msg) { 103 try { 104 Invoke((Action<string>)UpdateMessage, msg); 105 } 106 catch (ObjectDisposedException) { } 107 } 108 109 // each tick of the timer reduce opacity and restart timer 110 private void fadeTimer_Elapsed(object sender, EventArgs e) { 111 // only called from local timer: no need to invoke here 112 FadeOut(); 113 } 114 #endregion 85 115 86 116 public void Show(string initialText) { … … 95 125 96 126 public void Show(IWin32Window owner, string initialText) { 97 if (InvokeRequired) Invoke((Action< string>)Show, initialText);127 if (InvokeRequired) Invoke((Action<IWin32Window, string>)Show, owner, initialText); 98 128 else { 99 129 Opacity = 1; … … 111 141 } 112 142 113 114 private void SetInfoText(string text) {115 if (InvokeRequired) Invoke((Action<string>)SetInfoText, text);116 else {117 infoLabel.Text = text;118 }119 }120 121 143 private void UpdateMessage(string msg) { 122 if (InvokeRequired) { 123 Invoke((Action<string>)UpdateMessage, msg); 124 } else { 125 ResetFadeTimer(); 126 SetInfoText(msg); 127 Application.DoEvents(); // force immediate update of splash screen control 128 } 129 } 130 131 // each tick of the timer reduce opacity and restart timer 132 private void fadeTimer_Elapsed(object sender, EventArgs e) { 133 FadeOut(); 144 ResetFadeTimer(); 145 infoLabel.Text = msg; 146 Application.DoEvents(); // force immediate update of splash screen control 134 147 } 135 148 … … 147 160 } 148 161 } 162 163 protected override void OnClosing(System.ComponentModel.CancelEventArgs e) { 164 // deregister events when form is closing 165 DeregisterPluginManagerEventHandlers(); 166 base.OnClosing(e); 167 } 149 168 } 150 169 } -
trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Starter/StarterForm.cs
r4482 r4515 176 176 177 177 private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { 178 splashScreen.Close(); 178 179 abortRequested = true; 179 180 }
Note: See TracChangeset
for help on using the changeset viewer.