Changeset 599 for branches/3.1/sources/HeuristicLab/SplashScreen.cs
- Timestamp:
- 09/26/08 11:32:58 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/sources/HeuristicLab/SplashScreen.cs
r17 r599 30 30 namespace HeuristicLab { 31 31 public partial class SplashScreen : Form { 32 private int myDisplayTime = 1000; 33 public int DisplayTime { 34 get { return (myDisplayTime); } 35 set { 36 if(value > 0) { 37 myDisplayTime = value; 38 waitTimer.Interval = value; 39 } 40 } 41 } 32 private const int FADE_INTERVAL = 50; 33 private System.Timers.Timer fadeTimer; 34 private int initialInterval; 35 private object bigLock = new object(); 36 private bool closing = false; 42 37 43 38 public SplashScreen() { … … 77 72 companyLabel.Text = "-"; 78 73 } 79 waitTimer.Start();80 74 } 81 75 82 public SplashScreen(int displayTime, string initialText)76 public SplashScreen(int initialInterval, string initialText) 83 77 : this() { 84 waitTimer.Stop(); 85 DisplayTime = displayTime; 86 waitTimer.Start(); 78 this.initialInterval = initialInterval; 87 79 infoLabel.Text = initialText; 88 80 } … … 93 85 94 86 public void Manager_Action(object sender, PluginManagerActionEventArgs e) { 95 if(!this.Disposing && !this.IsDisposed) { 96 waitTimer.Stop(); 97 string info; 98 if(e.Action == PluginManagerAction.Initializing) info = "Initializing ..."; 99 else if(e.Action == PluginManagerAction.InitializingPlugin) info = "Initializing Plugin " + e.Id + " ..."; 100 else if(e.Action == PluginManagerAction.InitializedPlugin) info = "Initializing Plugin " + e.Id + " ... Initialized"; 101 else if(e.Action == PluginManagerAction.Initialized) info = "Initialization Completed"; 102 else { 103 if(e.Id != null) info = e.Action.ToString() + " (" + e.Id + ")"; 104 else info = e.Action.ToString(); 105 } 106 SetInfoText(info); 107 Application.DoEvents(); 108 waitTimer.Start(); 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(); 102 } 103 SetInfoText(info); 104 Application.DoEvents(); 105 } 106 107 private void fadeTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { 108 fadeTimer.Stop(); 109 if(InvokeRequired) { 110 Invoke((MethodInvoker)UpdateOpacity); 111 } else { 112 UpdateOpacity(); 109 113 } 110 114 } 111 115 112 private void waitTimer_Tick(object sender, System.EventArgs e) { 113 if(!this.Disposing && !this.IsDisposed) { 114 waitTimer.Stop(); 115 fadeTimer.Start(); 116 } 117 } 118 119 private void fadeTimer_Tick(object sender, EventArgs e) { 120 if(InvokeRequired) { 121 Invoke((MethodInvoker)delegate() { 122 if(Opacity > 0.9) { 123 Opacity = 0.9; 124 } else if(this.Opacity > 0) { 125 Opacity -= 0.1; 126 } else { 127 Opacity = 0; 128 fadeTimer.Stop(); 129 Close(); 130 } 131 }); 132 } else { 116 private void UpdateOpacity() { 117 lock(bigLock) { 118 if(closing) return; 133 119 if(Opacity > 0.9) { 134 120 Opacity = 0.9; 121 fadeTimer.Interval = FADE_INTERVAL; 122 fadeTimer.Start(); 135 123 } else if(this.Opacity > 0) { 136 124 Opacity -= 0.1; 125 fadeTimer.Start(); 137 126 } else { 138 127 Opacity = 0; 139 fadeTimer.Stop();140 128 Close(); 141 129 } 142 130 } 143 131 } 144 145 132 146 133 private void SplashScreen_FormClosing(object sender, FormClosingEventArgs e) { … … 149 136 150 137 private void closeButton_Click(object sender, EventArgs e) { 151 waitTimer.Stop(); 152 Close(); 138 lock(bigLock) { 139 closing = true; 140 if(fadeTimer != null) fadeTimer.Stop(); 141 Close(); 142 } 153 143 } 154 144 }
Note: See TracChangeset
for help on using the changeset viewer.