Free cookie consent management tool by TermsFeed Policy Generator

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

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

fixed #23 by just refreshing the applications-listview in the starter window

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      applicationsListView.Clear();
60
61      pluginManagerListViewItem = new ListViewItem("Plugin Manager", 0);
62      pluginManagerListViewItem.Group = applicationsListView.Groups["Plugin Management"];
63      pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, "-"));
64      pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, "Install, upgrade or delete plugins"));
65      pluginManagerListViewItem.ToolTipText = "Install, upgrade or delete plugins";
66
67      applicationsListView.Items.Add(pluginManagerListViewItem);
68
69      foreach(ApplicationInfo info in PluginManager.Manager.InstalledApplications) {
70        ListViewItem item = new ListViewItem(info.Name, 0);
71        item.Tag = info;
72        item.Group = applicationsListView.Groups["Applications"];
73        item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.Version.ToString()));
74        item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.Description));
75        item.ToolTipText = info.Description;
76        applicationsListView.Items.Add(item);
77      }
78    }
79
80    private void applicationsListView_ItemActivate(object sender, EventArgs e) {
81      if(applicationsListView.SelectedItems.Count > 0) {       
82        ListViewItem selected = applicationsListView.SelectedItems[0];
83        if(selected == pluginManagerListViewItem) {
84          ManagerForm form = new ManagerForm();
85          this.Visible = false;
86          form.ShowDialog();
87          RefreshApplicationsList();
88          this.Visible = true;
89        } else {
90          ApplicationInfo app = (ApplicationInfo)applicationsListView.SelectedItems[0].Tag;
91          SplashScreen splashScreen = new SplashScreen(1000, "Loading " + app.Name);
92          splashScreen.Owner = this;
93          splashScreen.Show();
94          this.Visible = false;
95          PluginManager.Manager.Action += new PluginManagerActionEventHandler(splashScreen.Manager_Action);
96          PluginManager.Manager.Run(app);
97          this.Visible = true;
98        }
99      }
100    }
101
102    private void applicationsListBox_SelectedIndexChanged(object sender, ListViewItemSelectionChangedEventArgs e) {
103      if(e.IsSelected) {
104        startButton.Enabled = true;
105      } else {
106        startButton.Enabled = false;
107      }
108    }
109
110    private void largeIconsButton_Click(object sender, EventArgs e) {
111      applicationsListView.View = View.LargeIcon;
112    }
113
114    private void listButton_Click(object sender, EventArgs e) {
115      applicationsListView.View = View.List;
116    }
117
118    private void detailsButton_Click(object sender, EventArgs e) {
119      applicationsListView.View = View.Details;
120    }
121
122  }
123}
Note: See TracBrowser for help on using the repository browser.