Changeset 596
- Timestamp:
- 09/26/08 10:58:14 (16 years ago)
- Location:
- trunk/sources/HeuristicLab
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab/MainForm.cs
r595 r596 89 89 } else { 90 90 ApplicationInfo app = (ApplicationInfo)applicationsListView.SelectedItems[0].Tag; 91 SplashScreen splashScreen = new SplashScreen( 3000, "Loading " + app.Name);91 SplashScreen splashScreen = new SplashScreen(2000, "Loading " + app.Name); 92 92 splashScreen.Owner = this; 93 93 splashScreen.Show(); -
trunk/sources/HeuristicLab/SplashScreen.cs
r595 r596 31 31 public partial class SplashScreen : Form { 32 32 private const int FADE_INTERVAL = 50; 33 private System.Timers.Timer waitTimer;34 33 private System.Timers.Timer fadeTimer; 34 private int initialInterval; 35 35 private object bigLock = new object(); 36 37 private int displayTime = 1000; 38 public int DisplayTime { 39 get { return (displayTime); } 40 set { 41 if(value > 0) { 42 displayTime = value; 43 } 44 } 45 } 36 private bool closing = false; 46 37 47 38 public SplashScreen() { … … 83 74 } 84 75 85 public SplashScreen(int displayTime, string initialText)76 public SplashScreen(int initialInterval, string initialText) 86 77 : this() { 87 DisplayTime = displayTime;78 this.initialInterval = initialInterval; 88 79 infoLabel.Text = initialText; 89 80 } … … 94 85 95 86 public void Manager_Action(object sender, PluginManagerActionEventArgs e) { 96 lock(bigLock) { 97 if(!this.Disposing && !this.IsDisposed) { 98 if(waitTimer == null) { 99 waitTimer = new System.Timers.Timer(); 100 waitTimer.SynchronizingObject = this; 101 waitTimer.Elapsed += new System.Timers.ElapsedEventHandler(waitTimer_Elapsed); 102 } 103 waitTimer.Stop(); 104 waitTimer.Interval = DisplayTime; 105 waitTimer.AutoReset = true; 106 string info; 107 if(e.Action == PluginManagerAction.Initializing) info = "Initializing ..."; 108 else if(e.Action == PluginManagerAction.InitializingPlugin) info = "Initializing Plugin " + e.Id + " ..."; 109 else if(e.Action == PluginManagerAction.InitializedPlugin) info = "Initializing Plugin " + e.Id + " ... Initialized"; 110 else if(e.Action == PluginManagerAction.Initialized) info = "Initialization Completed"; 111 else { 112 if(e.Id != null) info = e.Action.ToString() + " (" + e.Id + ")"; 113 else info = e.Action.ToString(); 114 } 115 SetInfoText(info); 116 Application.DoEvents(); 117 waitTimer.Start(); 118 } 87 string info; 88 if(e.Action == PluginManagerAction.Initializing) info = "Initializing ..."; 89 else if(e.Action == PluginManagerAction.InitializingPlugin) info = "Initializing Plugin " + e.Id + " ..."; 90 else if(e.Action == PluginManagerAction.InitializedPlugin) info = "Initializing Plugin " + e.Id + " ... Initialized"; 91 else if(e.Action == PluginManagerAction.Initialized) { 92 info = "Initialization Completed"; 93 fadeTimer = new System.Timers.Timer(); 94 fadeTimer.SynchronizingObject = this; 95 fadeTimer.Elapsed += new System.Timers.ElapsedEventHandler(fadeTimer_Elapsed); 96 fadeTimer.Interval = initialInterval; 97 fadeTimer.AutoReset = true; 98 fadeTimer.Start(); 99 } else { 100 if(e.Id != null) info = e.Action.ToString() + " (" + e.Id + ")"; 101 else info = e.Action.ToString(); 119 102 } 120 } 121 122 private void waitTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { 123 lock(bigLock) { 124 if(!this.Disposing && !this.IsDisposed) { 125 if(fadeTimer == null) { 126 fadeTimer = new System.Timers.Timer(); 127 fadeTimer.SynchronizingObject = this; 128 fadeTimer.Elapsed += new System.Timers.ElapsedEventHandler(fadeTimer_Elapsed); 129 fadeTimer.Interval = FADE_INTERVAL; 130 fadeTimer.AutoReset = true; 131 fadeTimer.Start(); 132 } 133 } 134 } 103 SetInfoText(info); 104 Application.DoEvents(); 135 105 } 136 106 137 107 private void fadeTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { 138 lock(bigLock) { 139 if(!this.Disposing && !this.IsDisposed) { 140 fadeTimer.Stop(); 141 if(InvokeRequired) { 142 Invoke((MethodInvoker)UpdateOpacity); 143 } else { 144 UpdateOpacity(); 145 } 146 } 108 fadeTimer.Stop(); 109 if(InvokeRequired) { 110 Invoke((MethodInvoker)UpdateOpacity); 111 } else { 112 UpdateOpacity(); 147 113 } 148 114 } 149 115 150 116 private void UpdateOpacity() { 151 if(Opacity > 0.9) { 152 Opacity = 0.9; 153 fadeTimer.Start(); 154 } else if(this.Opacity > 0) { 155 Opacity -= 0.1; 156 fadeTimer.Start(); 157 } else { 158 Opacity = 0; 159 Close(); 117 lock(bigLock) { 118 if(closing) return; 119 if(Opacity > 0.9) { 120 Opacity = 0.9; 121 fadeTimer.Interval = FADE_INTERVAL; 122 fadeTimer.Start(); 123 } else if(this.Opacity > 0) { 124 Opacity -= 0.1; 125 fadeTimer.Start(); 126 } else { 127 Opacity = 0; 128 Close(); 129 } 160 130 } 161 131 } … … 167 137 private void closeButton_Click(object sender, EventArgs e) { 168 138 lock(bigLock) { 139 closing = true; 169 140 if(fadeTimer != null) fadeTimer.Stop(); 170 if(waitTimer != null) waitTimer.Stop();171 141 Close(); 172 142 }
Note: See TracChangeset
for help on using the changeset viewer.