Changeset 8818
- Timestamp:
- 10/17/12 21:46:00 (12 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs ¶
r7259 r8818 68 68 } 69 69 70 private IEnumerable<ICommandLineArgument> arguments; 71 public IEnumerable<ICommandLineArgument> Arguments { 72 get { return arguments; } 73 set { 74 if (arguments == null) arguments = value; 75 else throw new InvalidOperationException("Arguments can only be set once and were already set."); 76 } 77 } 78 70 79 public override Cursor Cursor { 71 80 get { return base.Cursor; } -
TabularUnified trunk/sources/HeuristicLab.MainForm/3.3/Interfaces/IMainForm.cs ¶
r7259 r8818 23 23 using System.Collections.Generic; 24 24 using HeuristicLab.Common; 25 using HeuristicLab.PluginInfrastructure; 25 26 26 27 namespace HeuristicLab.MainForm { 27 28 public interface IMainForm { 28 29 string Title { get; set; } 30 IEnumerable<ICommandLineArgument> Arguments { get; set; } 29 31 30 32 IView ActiveView { get; } -
TabularUnified trunk/sources/HeuristicLab.Optimizer/3.3/FileManager.cs ¶
r8587 r8818 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using System.Windows.Forms; … … 59 60 60 61 if (openFileDialog.ShowDialog() == DialogResult.OK) { 61 foreach (string filename in openFileDialog.FileNames) { 62 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).SetAppStartingCursor(); 63 ContentManager.LoadAsync(filename, LoadingCompleted); 64 } 62 OpenFiles(openFileDialog.FileNames); 65 63 } 66 64 } 65 66 public static void OpenFiles(IEnumerable<string> fileNames) { 67 foreach (string filename in fileNames) { 68 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).SetAppStartingCursor(); 69 ContentManager.LoadAsync(filename, LoadingCompleted); 70 } 71 } 72 67 73 private static void LoadingCompleted(IStorableContent content, Exception error) { 68 74 try { -
TabularUnified trunk/sources/HeuristicLab.Optimizer/3.3/Plugin.cs.frame ¶
r8246 r8818 20 20 #endregion 21 21 22 using System.Linq; 22 23 using System.Windows.Forms; 23 24 using HeuristicLab.Clients.Access; … … 48 49 [Application("Optimizer", "HeuristicLab Optimizer 3.3.7.$WCREV$")] 49 50 internal class HeuristicLabOptimizerApplication : ApplicationBase { 50 public override void Run( ) {51 HeuristicLab.MainForm.WindowsForms.MainForm mainForm = null;51 public override void Run(ICommandLineArgument[] args) { 52 HeuristicLab.MainForm.WindowsForms.MainForm mainForm = null; 52 53 53 54 if (Settings.Default.MainFormType == OptimizerMainFormTypes.DockingMainForm) { … … 64 65 65 66 mainForm.ShowContentInViewHost = true; 67 mainForm.Arguments = args; 68 var filesToOpen = mainForm.Arguments.OfType<OpenArgument>().Select(x => x.Value); 69 mainForm.Load += (sender, eventArgs) => FileManager.OpenFiles(filesToOpen); 66 70 Application.Run(mainForm); 67 71 } else { -
TabularUnified trunk/sources/HeuristicLab.Persistence.GUI/3.3/Plugin.cs.frame ¶
r8246 r8818 13 13 [Application("Persistence Configuration", "Configure type mappings of persistence")] 14 14 public class HeuristicLabPersistenceGUIApplication : ApplicationBase { 15 public override void Run( ) {15 public override void Run(ICommandLineArgument[] args) { 16 16 Application.EnableVisualStyles(); 17 17 Application.SetCompatibleTextRenderingDefault(false); -
TabularUnified trunk/sources/HeuristicLab.PluginInfrastructure/3.3/BaseClasses/ApplicationBase.cs ¶
r7259 r8818 67 67 /// Runs the application. 68 68 /// </summary> 69 public abstract void Run( );69 public abstract void Run(ICommandLineArgument[] args); 70 70 71 71 #endregion -
TabularUnified trunk/sources/HeuristicLab.PluginInfrastructure/3.3/CommandLineArgumentHandling/Arguments/HideStarterArgument.cs ¶
r8748 r8818 20 20 #endregion 21 21 22 using System; 23 22 24 namespace HeuristicLab.PluginInfrastructure { 25 [Serializable] 23 26 public class HideStarterArgument : CommandLineArgument<bool> { 24 27 public const string TOKEN = "hideStarter"; -
TabularUnified trunk/sources/HeuristicLab.PluginInfrastructure/3.3/CommandLineArgumentHandling/Arguments/StartArgument.cs ¶
r8748 r8818 20 20 #endregion 21 21 22 using System; 23 22 24 namespace HeuristicLab.PluginInfrastructure { 25 [Serializable] 23 26 public class StartArgument : CommandLineArgument<string> { 24 27 public const string TOKEN = "start"; -
TabularUnified trunk/sources/HeuristicLab.PluginInfrastructure/3.3/CommandLineArgumentHandling/CommandLineArgument.cs ¶
r8748 r8818 20 20 #endregion 21 21 22 using System; 23 22 24 namespace HeuristicLab.PluginInfrastructure { 25 [Serializable] 23 26 public abstract class CommandLineArgument<T> : ICommandLineArgument<T> { 24 27 object ICommandLineArgument.Value { get { return Value; } } -
TabularUnified trunk/sources/HeuristicLab.PluginInfrastructure/3.3/CommandLineArgumentHandling/CommandLineArgumentHandling.cs ¶
r8748 r8818 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.IO; 24 25 using System.Linq; 25 26 using System.Text.RegularExpressions; … … 43 44 private static ICommandLineArgument ParseArgument(string entry) { 44 45 var regex = new Regex(@"^/[A-Za-z]+(:[A-Za-z0-9\s]+)?$"); 45 if (!regex.IsMatch(entry)) return null; 46 entry = entry.Remove(0, 1); 47 var parts = entry.Split(':'); 48 string key = parts[0].Trim(); 49 string value = parts.Length == 2 ? parts[1].Trim() : string.Empty; 50 switch (key) { 51 case StartArgument.TOKEN: return new StartArgument(value); 52 case HideStarterArgument.TOKEN: return new HideStarterArgument(value); 53 default: return null; 54 } 46 bool isFile = File.Exists(entry); 47 if (!regex.IsMatch(entry) && !isFile) return null; 48 if (!isFile) { 49 entry = entry.Remove(0, 1); 50 var parts = entry.Split(':'); 51 string key = parts[0].Trim(); 52 string value = parts.Length == 2 ? parts[1].Trim() : string.Empty; 53 switch (key) { 54 case StartArgument.TOKEN: return new StartArgument(value); 55 case HideStarterArgument.TOKEN: return new HideStarterArgument(value); 56 default: return null; 57 } 58 } else return new OpenArgument(entry); 55 59 } 56 60 } -
TabularUnified trunk/sources/HeuristicLab.PluginInfrastructure/3.3/HeuristicLab.PluginInfrastructure-3.3.csproj ¶
r8748 r8818 215 215 <DependentUpon>PluginView.cs</DependentUpon> 216 216 </Compile> 217 <Compile Include="CommandLineArgumentHandling\Arguments\OpenArgument.cs" /> 217 218 <Compile Include="CommandLineArgumentHandling\Arguments\HideStarterArgument.cs" /> 218 219 <Compile Include="CommandLineArgumentHandling\Arguments\StartArgument.cs" /> -
TabularUnified trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Interfaces/IApplication.cs ¶
r7259 r8818 37 37 /// Main entry point for the application. 38 38 /// </summary> 39 void Run( );39 void Run(ICommandLineArgument[] args); 40 40 } 41 41 } -
TabularUnified trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginManager.cs ¶
r7259 r8818 110 110 /// </summary> 111 111 /// <param name="appInfo">application to run</param> 112 public void Run(ApplicationDescription appInfo ) {112 public void Run(ApplicationDescription appInfo, ICommandLineArgument[] args) { 113 113 if (!initialized) throw new InvalidOperationException("PluginManager is not initialized. DiscoverAndCheckPlugins() must be called before Run()"); 114 114 // create a separate AppDomain for the application … … 129 129 applicationManager.PrepareApplicationDomain(applications, plugins); 130 130 OnApplicationStarted(new PluginInfrastructureEventArgs(appInfo)); 131 applicationManager.Run(appInfo );131 applicationManager.Run(appInfo, args); 132 132 } 133 133 finally { -
TabularUnified trunk/sources/HeuristicLab.PluginInfrastructure/3.3/SandboxApplicationManager.cs ¶
r8571 r8818 115 115 /// </summary> 116 116 /// <param name="appInfo">Description of the application to run</param> 117 internal void Run(ApplicationDescription appInfo ) {117 internal void Run(ApplicationDescription appInfo, ICommandLineArgument[] args) { 118 118 IApplication runnablePlugin = (IApplication)Activator.CreateInstance(appInfo.DeclaringAssemblyName, appInfo.DeclaringTypeName).Unwrap(); 119 119 try { 120 runnablePlugin.Run( );120 runnablePlugin.Run(args); 121 121 } 122 122 finally { -
TabularUnified trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Starter/StarterForm.cs ¶
r8748 r8818 39 39 private const string pluginManagerItemName = "Plugin Manager"; 40 40 private const string updatePluginsItemName = "Updates Available"; 41 private const string optimizerItemName = "Optimizer"; 41 42 42 43 private readonly ICommandLineArgument[] arguments; … … 84 85 85 86 protected override void SetVisibleCore(bool value) { 86 value &= ! arguments.OfType<HideStarterArgument>().Any();87 value &= !(arguments.OfType<HideStarterArgument>().Any() || arguments.OfType<OpenArgument>().Any()); 87 88 if (!value) HandleArguments(); 88 89 base.SetVisibleCore(value); … … 144 145 } else { 145 146 ApplicationDescription app = (ApplicationDescription)applicationsListView.SelectedItems[0].Tag; 146 StartApplication(app );147 StartApplication(app, arguments); 147 148 } 148 149 } … … 171 172 private void splashScreen_VisibleChanged(object sender, EventArgs e) { 172 173 // close hidden starter form 173 if (!splashScreen.Visible && arguments != null && arguments.OfType<HideStarterArgument>().Any()) 174 if (!splashScreen.Visible && arguments != null && 175 (arguments.OfType<HideStarterArgument>().Any() || arguments.OfType<OpenArgument>().Any())) 174 176 Close(); 175 177 } … … 263 265 private void HandleArguments() { 264 266 try { 267 if (arguments.OfType<OpenArgument>().Any() && !arguments.OfType<StartArgument>().Any()) { 268 InitiateApplicationStart(optimizerItemName); 269 } 265 270 foreach (var argument in arguments) { 266 271 if (argument is StartArgument) { 267 var appDesc = (from desc in pluginManager.Applications 268 where desc.Name.Equals(argument.Value) 269 select desc).SingleOrDefault(); 270 if (appDesc != null) { 271 StartApplication(appDesc); 272 } else { 273 MessageBox.Show("Cannot start application " + argument.Value + ".", 274 "HeuristicLab", 275 MessageBoxButtons.OK, 276 MessageBoxIcon.Warning); 277 } 272 var arg = (StartArgument)argument; 273 InitiateApplicationStart(arg.Value); 278 274 } 279 275 } … … 284 280 } 285 281 286 private void StartApplication(ApplicationDescription app) { 282 private void InitiateApplicationStart(string appName) { 283 var appDesc = (from desc in pluginManager.Applications 284 where desc.Name.Equals(appName) 285 select desc).SingleOrDefault(); 286 if (appDesc != null) { 287 StartApplication(appDesc, arguments); 288 } else { 289 MessageBox.Show("Cannot start application " + appName + ".", 290 "HeuristicLab", 291 MessageBoxButtons.OK, 292 MessageBoxIcon.Warning); 293 } 294 } 295 296 private void StartApplication(ApplicationDescription app, ICommandLineArgument[] args) { 287 297 splashScreen.Show("Loading " + app.Name); 288 298 Thread t = new Thread(delegate() { … … 291 301 try { 292 302 if (!abortRequested) { 293 pluginManager.Run(app );303 pluginManager.Run(app, args); 294 304 } 295 305 stopped = true;
Note: See TracChangeset
for help on using the changeset viewer.