source: trunk/sources/HeuristicLab/MainForm.cs @ 8

Last change on this file since 8 was 8, checked in by gkronber, 13 years ago

removed silly assertion statements (ticket #12)

File size: 4.4 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.ComponentModel;
25using System.Data;
26using System.Drawing;
27using System.Text;
28using System.Windows.Forms;
29using System.Diagnostics;
30using HeuristicLab.PluginInfrastructure;
31using HeuristicLab.PluginInfrastructure.GUI;
32using System.Threading;
33
34namespace HeuristicLab {
35  public partial class MainForm : Form {
36
37    private ListViewItem pluginManagerListViewItem;
38
39    public MainForm() {
40      SplashScreen splashScreen = new SplashScreen(1000, "Loading HeuristicLab...");
41      splashScreen.Owner = this;
42      splashScreen.Show();
43
44      Application.DoEvents();
45      this.Enabled = false;
46
47      PluginManager.Manager.Action += new PluginManagerActionEventHandler(splashScreen.Manager_Action);
48      PluginManager.Manager.Initialize();
49
50      InitializeComponent();
51
52      RefreshApplicationsList();
53
54      this.Enabled = true;
55      this.Visible = true;
56    }
57
58    private void RefreshApplicationsList() {
59      pluginManagerListViewItem = new ListViewItem("Plugin Manager", 0);
60      pluginManagerListViewItem.Group = applicationsListView.Groups["Plugin Management"];
61      pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, "-"));
62      pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, "Install, upgrade or delete plugins"));
63      pluginManagerListViewItem.ToolTipText = "Install, upgrade or delete plugins";
64
65      applicationsListView.Items.Add(pluginManagerListViewItem);
66
67      foreach(ApplicationInfo info in PluginManager.Manager.InstalledApplications) {
68        ListViewItem item = new ListViewItem(info.Name, 0);
69        item.Tag = info;
70        item.Group = applicationsListView.Groups["Applications"];
71        item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.Version.ToString()));
72        item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.Description));
73        item.ToolTipText = info.Description;
74        applicationsListView.Items.Add(item);
75      }
76    }
77
78    private void applicationsListView_ItemActivate(object sender, EventArgs e) {
79      if(applicationsListView.SelectedItems.Count > 0) {       
80        ListViewItem selected = applicationsListView.SelectedItems[0];
81        if(selected == pluginManagerListViewItem) {
82          ManagerForm form = new ManagerForm();
83          this.Visible = false;
84          form.ShowDialog();
85          this.Visible = true;
86        } else {
87          ApplicationInfo app = (ApplicationInfo)applicationsListView.SelectedItems[0].Tag;
88          SplashScreen splashScreen = new SplashScreen(1000, "Loading " + app.Name);
89          splashScreen.Owner = this;
90          splashScreen.Show();
91          this.Visible = false;
92          PluginManager.Manager.Action += new PluginManagerActionEventHandler(splashScreen.Manager_Action);
93          PluginManager.Manager.Run(app);
94          this.Visible = true;
95        }
96      }
97    }
98
99    private void applicationsListBox_SelectedIndexChanged(object sender, ListViewItemSelectionChangedEventArgs e) {
100      if(e.IsSelected) {
101        startButton.Enabled = true;
102      } else {
103        startButton.Enabled = false;
104      }
105    }
106
107    private void largeIconsButton_Click(object sender, EventArgs e) {
108      applicationsListView.View = View.LargeIcon;
109    }
110
111    private void listButton_Click(object sender, EventArgs e) {
112      applicationsListView.View = View.List;
113    }
114
115    private void detailsButton_Click(object sender, EventArgs e) {
116      applicationsListView.View = View.Details;
117    }
118
119  }
120}
Note: See TracBrowser for help on using the repository browser.