- Timestamp:
- 11/24/15 19:02:57 (9 years ago)
- Location:
- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure.UI
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure.UI/HeuristicLab.PluginInfrastructure.UI-4.0.csproj
r13363 r13389 74 74 <DependentUpon>SplashScreen.cs</DependentUpon> 75 75 </Compile> 76 <Compile Include="StarterForm.cs">77 <SubType>Form</SubType>78 </Compile>79 <Compile Include="StarterForm.Designer.cs">80 <DependentUpon>StarterForm.cs</DependentUpon>81 </Compile>82 76 <Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" /> 83 77 </ItemGroup> -
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure.UI/Properties
-
Property
svn:ignore
set to
AssemblyInfo.cs
-
Property
svn:ignore
set to
-
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure.UI/SplashScreen.cs
r13353 r13389 24 24 using System.Reflection; 25 25 using System.Windows.Forms; 26 using HeuristicLab.PluginInfrastructure.Manager;27 26 28 27 namespace HeuristicLab.PluginInfrastructure.UI { 29 internalpartial class SplashScreen : Form {28 public partial class SplashScreen : Form { 30 29 private const int FADE_INTERVAL = 50; 31 30 private Timer fadeTimer; 32 31 private int initialInterval; 33 private PluginManager pluginManager;34 32 35 internalSplashScreen() {33 private SplashScreen() { 36 34 InitializeComponent(); 37 35 } 38 36 39 internal SplashScreen(PluginManager manager, int initialInterval)37 public SplashScreen(string initialText, int initialInterval) 40 38 : this() { 41 39 this.initialInterval = initialInterval; 42 this.pluginManager = manager;43 40 44 41 var entryAssembly = Assembly.GetEntryAssembly(); 45 RegisterPluginManagerEventHandlers();42 // RegisterPluginManagerEventHandlers(); 46 43 47 versionLabel.Text = "Version " + entryAssembly.GetFileVersion() + " " 44 versionLabel.Text = "Version " + entryAssembly.GetFileVersion() + " " 48 45 + entryAssembly.GetCustomAttributes().OfType<AssemblyInformationalVersionAttribute>().First().InformationalVersion; // code name 49 46 infoLabel.Text = ""; … … 55 52 fadeTimer.Tick += fadeTimer_Elapsed; 56 53 fadeTimer.Interval = initialInterval; 54 fadeTimer.Start(); 55 56 Opacity = 1; 57 infoLabel.Text = initialText; 58 57 59 } 58 60 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); 67 } 68 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); 76 } 77 78 private void manager_PluginUnloaded(object sender, PluginInfrastructureEventArgs e) { 79 SafeUpdateMessage("Unloaded " + e.Entity); 80 } 81 82 private void manager_PluginLoaded(object sender, PluginInfrastructureEventArgs e) { 83 SafeUpdateMessage("Loaded " + e.Entity); 84 } 85 86 private void manager_Initialized(object sender, PluginInfrastructureEventArgs e) { 87 SafeUpdateMessage("Initialized"); 88 } 89 90 private void manager_Initializing(object sender, PluginInfrastructureEventArgs e) { 91 SafeUpdateMessage("Initializing"); 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) { 61 public void UpdateMessage(string msg) { 103 62 try { 104 Invoke((Action<string>)UpdateMessage, msg); 63 if (InvokeRequired) Invoke((Action<string>)UpdateMessage, msg); 64 else { 65 ResetFadeTimer(); 66 infoLabel.Text = msg; 67 } 105 68 } catch (ObjectDisposedException) { } 106 69 } … … 111 74 FadeOut(); 112 75 } 113 #endregion114 115 public void Show(string initialText) {116 if (InvokeRequired) Invoke((Action<string>)Show, initialText);117 else {118 Opacity = 1;119 infoLabel.Text = initialText;120 ResetFadeTimer();121 Show();122 }123 }124 125 public void Show(IWin32Window owner, string initialText) {126 if (InvokeRequired) Invoke((Action<IWin32Window, string>)Show, owner, initialText);127 else {128 Opacity = 1;129 infoLabel.Text = initialText;130 ResetFadeTimer();131 Show(owner);132 }133 }134 76 135 77 private void ResetFadeTimer() { … … 138 80 fadeTimer.Interval = initialInterval; 139 81 fadeTimer.Start(); 140 }141 142 private void UpdateMessage(string msg) {143 ResetFadeTimer();144 infoLabel.Text = msg;145 Application.DoEvents(); // force immediate update of splash screen control146 82 } 147 83 … … 156 92 Opacity = 0; 157 93 fadeTimer.Stop(); 158 Hide();94 Close(); 159 95 } 160 }161 162 protected override void OnClosing(System.ComponentModel.CancelEventArgs e) {163 // deregister events when form is closing164 DeregisterPluginManagerEventHandlers();165 base.OnClosing(e);166 96 } 167 97 }
Note: See TracChangeset
for help on using the changeset viewer.