Free cookie consent management tool by TermsFeed Policy Generator

source: branches/CEDMA-Refactoring-Ticket419/HeuristicLab/Program.cs @ 1265

Last change on this file since 1265 was 877, checked in by swagner, 16 years ago

Implemented a quick way to pass the name of an application as commandline option in order to start this application automatically. (#45)

File size: 2.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Windows.Forms;
25using System.Xml;
26using System.Threading;
27using HeuristicLab.PluginInfrastructure;
28
29namespace HeuristicLab {
30  static class Program {
31    [STAThread]
32    static void Main(string[] args) {
33      if (args.Length == 0) {  // normal mode
34        Application.EnableVisualStyles();
35        Application.SetCompatibleTextRenderingDefault(false);
36        Application.Run(new MainForm());
37      } else if (args.Length == 1) {  // start specific application
38        PluginManager.Manager.Initialize();
39
40        ApplicationInfo app = null;
41        foreach (ApplicationInfo info in PluginManager.Manager.InstalledApplications) {
42          if (info.Name == args[0])
43            app = info;
44        }
45        if (app == null) {  // application not found
46          MessageBox.Show("Cannot start application.\nApplication " + args[0] + " is not installed.\n\nStarting HeuristicLab in normal mode ...",
47                          "HeuristicLab",
48                          MessageBoxButtons.OK,
49                          MessageBoxIcon.Warning);
50          Application.EnableVisualStyles();
51          Application.SetCompatibleTextRenderingDefault(false);
52          Application.Run(new MainForm());
53        } else {
54          PluginManager.Manager.Run(app);
55        }
56      }
57    }
58  }
59}
Note: See TracBrowser for help on using the repository browser.