Free cookie consent management tool by TermsFeed Policy Generator

source: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Advanced/InstallationManagerForm.cs @ 13333

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

#2522: removed classes for plugin uploading and updating

File size: 4.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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
21using System;
22using System.Collections.Generic;
23using System.ComponentModel;
24using System.IO;
25using System.Linq;
26using System.Text;
27using System.Windows.Forms;
28using HeuristicLab.PluginInfrastructure.Manager;
29
30namespace HeuristicLab.PluginInfrastructure.Advanced {
31  internal partial class InstallationManagerForm : Form, IStatusView {
32    private string pluginDir;
33
34    public InstallationManagerForm(PluginManager pluginManager)
35      : base() {
36      InitializeComponent();
37      Text = "HeuristicLab Plugin Manager " + AssemblyHelpers.GetFileVersion(GetType().Assembly);
38
39      pluginManager.PluginLoaded += pluginManager_PluginLoaded;
40      pluginManager.PluginUnloaded += pluginManager_PluginUnloaded;
41      pluginManager.Initializing += pluginManager_Initializing;
42      pluginManager.Initialized += pluginManager_Initialized;
43
44      pluginDir = Application.StartupPath;
45
46      localPluginsView.StatusView = this;
47      localPluginsView.PluginManager = pluginManager;
48      // localPluginsView.InstallationManager = installationManager;
49    }
50
51
52    #region plugin manager event handlers
53    private void pluginManager_Initialized(object sender, PluginInfrastructureEventArgs e) {
54      SetStatusStrip("Initialized PluginInfrastructure");
55    }
56
57    private void pluginManager_Initializing(object sender, PluginInfrastructureEventArgs e) {
58      SetStatusStrip("Initializing PluginInfrastructure");
59    }
60
61    private void pluginManager_PluginUnloaded(object sender, PluginInfrastructureEventArgs e) {
62      SetStatusStrip("Unloaded " + e.Entity);
63    }
64
65    private void pluginManager_PluginLoaded(object sender, PluginInfrastructureEventArgs e) {
66      SetStatusStrip("Loaded " + e.Entity);
67    }
68    #endregion
69
70
71    #region button events
72    private void tabControl_SelectedIndexChanged(object sender, EventArgs e) {
73      toolStripStatusLabel.Text = string.Empty;
74    }
75    #endregion
76
77    #region helper methods
78    private void SetStatusStrip(string msg) {
79      if (InvokeRequired) Invoke((Action<string>)SetStatusStrip, msg);
80      else {
81        toolStripStatusLabel.Text = msg;
82        logTextBox.Text += DateTime.Now + ": " + msg + Environment.NewLine;
83      }
84    }
85
86    #endregion
87
88
89    #region IStatusView Members
90
91    public void ShowProgressIndicator(double percentProgress) {
92      if (percentProgress < 0.0 || percentProgress > 1.0) throw new ArgumentException("percentProgress");
93      toolStripProgressBar.Visible = true;
94      toolStripProgressBar.Style = ProgressBarStyle.Continuous;
95      int range = toolStripProgressBar.Maximum - toolStripProgressBar.Minimum;
96      toolStripProgressBar.Value = (int)(percentProgress * range + toolStripProgressBar.Minimum);
97    }
98
99    public void ShowProgressIndicator() {
100      toolStripProgressBar.Visible = true;
101      toolStripProgressBar.Style = ProgressBarStyle.Marquee;
102    }
103
104    public void HideProgressIndicator() {
105      toolStripProgressBar.Visible = false;
106    }
107
108    public void ShowMessage(string message) {
109      if (string.IsNullOrEmpty(toolStripStatusLabel.Text))
110        toolStripStatusLabel.Text = message;
111      else
112        toolStripStatusLabel.Text += "; " + message;
113    }
114
115    public void RemoveMessage(string message) {
116      if (toolStripStatusLabel.Text.IndexOf("; " + message) > 0) {
117        toolStripStatusLabel.Text = toolStripStatusLabel.Text.Replace("; " + message, "");
118      }
119      toolStripStatusLabel.Text = toolStripStatusLabel.Text.Replace(message, "");
120      toolStripStatusLabel.Text = toolStripStatusLabel.Text.TrimStart(' ', ';');
121    }
122    public void LockUI() {
123      Cursor = Cursors.AppStarting;
124      tabControl.Enabled = false;
125    }
126    public void UnlockUI() {
127      tabControl.Enabled = true;
128      Cursor = Cursors.Default;
129    }
130    public void ShowError(string shortMessage, string description) {
131      logTextBox.Text += DateTime.Now + ": " + shortMessage + Environment.NewLine + description + Environment.NewLine;
132      MessageBox.Show(description, shortMessage);
133    }
134    #endregion
135
136  }
137}
Note: See TracBrowser for help on using the repository browser.