Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/17/12 21:46:00 (11 years ago)
Author:
jkarder
Message:

#1926:

  • added OpenArgument
  • refactored argument handling infrastructure
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Starter/StarterForm.cs

    r8748 r8818  
    3939    private const string pluginManagerItemName = "Plugin Manager";
    4040    private const string updatePluginsItemName = "Updates Available";
     41    private const string optimizerItemName = "Optimizer";
    4142
    4243    private readonly ICommandLineArgument[] arguments;
     
    8485
    8586    protected override void SetVisibleCore(bool value) {
    86       value &= !arguments.OfType<HideStarterArgument>().Any();
     87      value &= !(arguments.OfType<HideStarterArgument>().Any() || arguments.OfType<OpenArgument>().Any());
    8788      if (!value) HandleArguments();
    8889      base.SetVisibleCore(value);
     
    144145        } else {
    145146          ApplicationDescription app = (ApplicationDescription)applicationsListView.SelectedItems[0].Tag;
    146           StartApplication(app);
     147          StartApplication(app, arguments);
    147148        }
    148149      }
     
    171172    private void splashScreen_VisibleChanged(object sender, EventArgs e) {
    172173      // 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()))
    174176        Close();
    175177    }
     
    263265    private void HandleArguments() {
    264266      try {
     267        if (arguments.OfType<OpenArgument>().Any() && !arguments.OfType<StartArgument>().Any()) {
     268          InitiateApplicationStart(optimizerItemName);
     269        }
    265270        foreach (var argument in arguments) {
    266271          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);
    278274          }
    279275        }
     
    284280    }
    285281
    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) {
    287297      splashScreen.Show("Loading " + app.Name);
    288298      Thread t = new Thread(delegate() {
     
    291301          try {
    292302            if (!abortRequested) {
    293               pluginManager.Run(app);
     303              pluginManager.Run(app, args);
    294304            }
    295305            stopped = true;
Note: See TracChangeset for help on using the changeset viewer.