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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Windows.Forms;
|
---|
25 | using System.Xml;
|
---|
26 | using System.Threading;
|
---|
27 | using System.Text;
|
---|
28 | using HeuristicLab.PluginInfrastructure;
|
---|
29 |
|
---|
30 | namespace HeuristicLab {
|
---|
31 | static class Program {
|
---|
32 | [STAThread]
|
---|
33 | static void Main(string[] args) {
|
---|
34 | try {
|
---|
35 | if (args.Length == 0) { // normal mode
|
---|
36 | Application.EnableVisualStyles();
|
---|
37 | Application.SetCompatibleTextRenderingDefault(false);
|
---|
38 | Application.Run(new MainForm());
|
---|
39 | } else if (args.Length == 1) { // start specific application
|
---|
40 | //PluginManager.Manager.Initialize();
|
---|
41 |
|
---|
42 | //ApplicationInfo app = null;
|
---|
43 | //foreach (ApplicationInfo info in PluginManager.Manager.InstalledApplications) {
|
---|
44 | // if (info.Name == args[0])
|
---|
45 | // app = info;
|
---|
46 | //}
|
---|
47 | //if (app == null) { // application not found
|
---|
48 | // MessageBox.Show("Cannot start application.\nApplication " + args[0] + " is not installed.\n\nStarting HeuristicLab in normal mode ...",
|
---|
49 | // "HeuristicLab",
|
---|
50 | // MessageBoxButtons.OK,
|
---|
51 | // MessageBoxIcon.Warning);
|
---|
52 | // Application.EnableVisualStyles();
|
---|
53 | // Application.SetCompatibleTextRenderingDefault(false);
|
---|
54 | // Application.Run(new MainForm());
|
---|
55 | //} else {
|
---|
56 | // PluginManager.Manager.Run(app);
|
---|
57 | //}
|
---|
58 | }
|
---|
59 | }
|
---|
60 | catch (Exception ex) {
|
---|
61 | ShowErrorMessageBox(ex);
|
---|
62 | }
|
---|
63 | }
|
---|
64 |
|
---|
65 | private static void ShowErrorMessageBox(Exception ex) {
|
---|
66 | MessageBox.Show(null,
|
---|
67 | BuildErrorMessage(ex),
|
---|
68 | "Error - " + ex.GetType().Name,
|
---|
69 | MessageBoxButtons.OK,
|
---|
70 | MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
|
---|
71 | }
|
---|
72 |
|
---|
73 | private static string BuildErrorMessage(Exception ex) {
|
---|
74 | StringBuilder sb = new StringBuilder();
|
---|
75 | sb.Append("Sorry, but something went wrong!\n\n" + ex.Message + "\n\n" + ex.StackTrace);
|
---|
76 |
|
---|
77 | while (ex.InnerException != null) {
|
---|
78 | ex = ex.InnerException;
|
---|
79 | sb.Append("\n\n-----\n\n" + ex.Message + "\n\n" + ex.StackTrace);
|
---|
80 | }
|
---|
81 | return sb.ToString();
|
---|
82 | }
|
---|
83 | }
|
---|
84 | }
|
---|