Changeset 13389
- Timestamp:
- 11/24/15 19:02:57 (9 years ago)
- Location:
- branches/RefactorPluginInfrastructure-2522
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RefactorPluginInfrastructure-2522/HeuristicLab.Optimizer/3.3/Plugin.cs.frame
r13321 r13389 50 50 internal class HeuristicLabOptimizerApplication : ApplicationBase { 51 51 public override void Run(ICommandLineArgument[] args) { 52 Application.EnableVisualStyles(); 53 Application.SetCompatibleTextRenderingDefault(false); 52 54 HeuristicLab.MainForm.WindowsForms.MainForm mainForm = null; 53 55 -
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 } -
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/ApplicationDescription.cs
r13341 r13389 22 22 using System; 23 23 24 namespace HeuristicLab.PluginInfrastructure .Manager{24 namespace HeuristicLab.PluginInfrastructure { 25 25 /// <summary> 26 26 /// Class that provides information about an application. -
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginDescription.cs
r13341 r13389 24 24 using System.Linq; 25 25 26 namespace HeuristicLab.PluginInfrastructure .Manager{26 namespace HeuristicLab.PluginInfrastructure { 27 27 /// <summary> 28 28 /// Holds information of loaded plugins that is needed for plugin management. -
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginDescriptionIterator.cs
r12012 r13389 23 23 using System.Linq; 24 24 25 namespace HeuristicLab.PluginInfrastructure .Manager{25 namespace HeuristicLab.PluginInfrastructure { 26 26 internal static class PluginDescriptionIterator { 27 27 internal static IEnumerable<PluginDescription> IterateDependenciesBottomUp(IEnumerable<PluginDescription> pluginDescriptions) { -
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginFile.cs
r13341 r13389 22 22 using System; 23 23 24 namespace HeuristicLab.PluginInfrastructure .Manager{24 namespace HeuristicLab.PluginInfrastructure { 25 25 /// <summary> 26 26 /// Plugin files have a name and a type. -
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginInfrastructureEventArgs.cs
r13341 r13389 22 22 using System; 23 23 24 namespace HeuristicLab.PluginInfrastructure .Manager{24 namespace HeuristicLab.PluginInfrastructure { 25 25 [Serializable] 26 26 public sealed class PluginInfrastructureEventArgs : EventArgs { -
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginManager.cs
r13341 r13389 26 26 using System.Security.Permissions; 27 27 28 namespace HeuristicLab.PluginInfrastructure .Manager{28 namespace HeuristicLab.PluginInfrastructure { 29 29 30 30 // must extend MarshalByRefObject because of event passing between Loader and PluginManager (each in it's own AppDomain) -
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginValidator.cs
r13363 r13389 29 29 30 30 31 namespace HeuristicLab.PluginInfrastructure .Manager{31 namespace HeuristicLab.PluginInfrastructure { 32 32 /// <summary> 33 33 /// Discovers all installed plugins in the plugin directory. Checks correctness of plugin meta-data and if -
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/SandboxApplicationManager.cs
r12012 r13389 25 25 using System.Linq; 26 26 using System.Reflection; 27 using HeuristicLab.PluginInfrastructure.Manager;28 27 29 28 namespace HeuristicLab.PluginInfrastructure { -
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/SandboxManager.cs
r13341 r13389 24 24 using System.Security; 25 25 using System.Security.Permissions; 26 using HeuristicLab.PluginInfrastructure.Manager;27 26 28 namespace HeuristicLab.PluginInfrastructure .Sandboxing{27 namespace HeuristicLab.PluginInfrastructure { 29 28 // used by Hive Slave 30 29 public static class SandboxManager { -
branches/RefactorPluginInfrastructure-2522/HeuristicLab/3.3/HeuristicLab-3.3.csproj
r13340 r13389 193 193 <Private>False</Private> 194 194 </ProjectReference> 195 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj"> 196 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project> 197 <Name>HeuristicLab.PluginInfrastructure-3.3</Name> 198 </ProjectReference> 195 199 </ItemGroup> 196 200 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/RefactorPluginInfrastructure-2522/HeuristicLab/3.3/Program.cs
r13338 r13389 21 21 22 22 using System; 23 using System.IO; 24 using System.Linq; 25 using System.Threading; 26 using System.Threading.Tasks; 23 27 using System.Windows.Forms; 28 using HeuristicLab.PluginInfrastructure; 24 29 using HeuristicLab.PluginInfrastructure.UI; 25 30 … … 41 46 Application.EnableVisualStyles(); 42 47 Application.SetCompatibleTextRenderingDefault(false); 43 Application.Run(new StarterForm(args)); 48 49 string pluginPath = Path.GetFullPath(Application.StartupPath); 50 51 var pluginManager = new PluginManager(pluginPath); 52 53 var splashScreen = new SplashScreen("Loading plugins...", 3000); 54 pluginManager.Initializing += (sender, eventArgs) => splashScreen.UpdateMessage("Loading plugins..."); 55 pluginManager.PluginLoaded += (sender, eventArgs) => splashScreen.UpdateMessage("Loaded " + eventArgs.Entity.ToString()); 56 pluginManager.ApplicationStarting += (sender, eventArgs) => splashScreen.UpdateMessage("Starting " + eventArgs.Entity.ToString()); 57 pluginManager.ApplicationStarted += (sender, eventArgs) => splashScreen.UpdateMessage("Started " + eventArgs.Entity.ToString()); 58 59 60 DiscoverPluginsAndRunOptimizerAsync(pluginManager, args); 61 62 Application.Run(splashScreen); 44 63 } catch (Exception ex) { 45 64 MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); … … 47 66 } 48 67 } 68 69 private static void DiscoverPluginsAndRunOptimizerAsync(PluginManager pluginManager, string[] args) { 70 // STAThread is necessary for a UI component we are using in the application 71 var t = new Thread(() => { 72 try { 73 pluginManager.DiscoverAndCheckPlugins(); 74 var optimizerApp = pluginManager.Applications.FirstOrDefault(app => app.Name == "Optimizer"); 75 pluginManager.Run(optimizerApp, CommandLineArgumentHandling.GetArguments(args)); 76 } catch (Exception ex) { 77 MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); 78 } 79 }); 80 81 // cannot use a task because we need to set STA 82 t.SetApartmentState(ApartmentState.STA); 83 t.Start(); 84 } 49 85 } 50 86 }
Note: See TracChangeset
for help on using the changeset viewer.