Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 184 was 19, checked in by gkronber, 17 years ago

fixed #24 by setting the starter to be the owner of the plugin-manager window in ShowDialog().

File size: 4.6 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(this);
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          PluginManager.Manager.Action += new PluginManagerActionEventHandler(splashScreen.Manager_Action);
95          Thread t = new Thread(delegate() {
96            PluginManager.Manager.Run(app);
97          });
98          t.SetApartmentState(ApartmentState.STA);
99          t.Start();
100        }
101      }
102    }
103
104    private void applicationsListBox_SelectedIndexChanged(object sender, ListViewItemSelectionChangedEventArgs e) {
105      if(e.IsSelected) {
106        startButton.Enabled = true;
107      } else {
108        startButton.Enabled = false;
109      }
110    }
111
112    private void largeIconsButton_Click(object sender, EventArgs e) {
113      applicationsListView.View = View.LargeIcon;
114    }
115
116    private void listButton_Click(object sender, EventArgs e) {
117      applicationsListView.View = View.List;
118    }
119
120    private void detailsButton_Click(object sender, EventArgs e) {
121      applicationsListView.View = View.Details;
122    }
123
124  }
125}
Note: See TracBrowser for help on using the repository browser.