Free cookie consent management tool by TermsFeed Policy Generator

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

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

Added HeuristicLab 3.0 sources from former SVN repository at revision 52

File size: 4.5 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        Trace.Assert(applicationsListView.SelectedItems.Count == 1);
81        ListViewItem selected = applicationsListView.SelectedItems[0];
82        if(selected == pluginManagerListViewItem) {
83          ManagerForm form = new ManagerForm();
84          this.Visible = false;
85          form.ShowDialog();
86          this.Visible = true;
87        } else {
88          ApplicationInfo app = (ApplicationInfo)applicationsListView.SelectedItems[0].Tag;
89          SplashScreen splashScreen = new SplashScreen(1000, "Loading " + app.Name);
90          splashScreen.Owner = this;
91          splashScreen.Show();
92          this.Visible = false;
93          PluginManager.Manager.Action += new PluginManagerActionEventHandler(splashScreen.Manager_Action);
94          PluginManager.Manager.Run(app);
95          this.Visible = true;
96        }
97      }
98    }
99
100    private void applicationsListBox_SelectedIndexChanged(object sender, ListViewItemSelectionChangedEventArgs e) {
101      if(e.IsSelected) {
102        startButton.Enabled = true;
103      } else {
104        startButton.Enabled = false;
105      }
106    }
107
108    private void largeIconsButton_Click(object sender, EventArgs e) {
109      applicationsListView.View = View.LargeIcon;
110    }
111
112    private void listButton_Click(object sender, EventArgs e) {
113      applicationsListView.View = View.List;
114    }
115
116    private void detailsButton_Click(object sender, EventArgs e) {
117      applicationsListView.View = View.Details;
118    }
119
120  }
121}
Note: See TracBrowser for help on using the repository browser.