Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/PluginView.cs @ 2860

Last change on this file since 2860 was 2860, checked in by gkronber, 14 years ago
  • replaced column ContactInformation with ContactName and ContactEmail in DB-schema and updated WCF deployment service
  • regenerated proxy classes
  • made PluginDescription from data contract implement IPluginDescription from plugin infrastructure
  • updated GUI on request by swagner (icons)
  • fixed problems in the upload plugins control.

#860 (Deployment server for plugin installation from web locations)

File size: 3.0 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Linq;
7using System.Text;
8using System.Windows.Forms;
9using HeuristicLab.PluginInfrastructure;
10using System.IO;
11
12namespace HeuristicLab.DeploymentService.AdminClient {
13  public partial class PluginView : UserControl {
14    private const string IMAGE_KEY_ASSEMBLY = "Assembly";
15    private const string IMAGE_KEY_FILE = "File";
16    private const string IMAGE_KEY_DOCUMENT = "Document";
17
18    private IPluginDescription plugin;
19
20    public PluginView() {
21      InitializeComponent();
22      PopulateImageList();
23    }
24
25    public PluginView(IPluginDescription plugin) {
26      InitializeComponent();
27      PopulateImageList();
28
29      this.plugin = plugin;
30      UpdateControls();
31    }
32
33    private void PopulateImageList() {
34      imageList.Images.Add(IMAGE_KEY_ASSEMBLY, HeuristicLab.Common.Resources.VS2008ImageLibrary.Assembly);
35      imageList.Images.Add(IMAGE_KEY_FILE, HeuristicLab.Common.Resources.VS2008ImageLibrary.File);
36      imageList.Images.Add(IMAGE_KEY_DOCUMENT, HeuristicLab.Common.Resources.VS2008ImageLibrary.Document);
37    }
38
39    public void UpdateControls() {
40      string appDir = Path.GetDirectoryName(Application.ExecutablePath);
41      nameTextBox.Text = plugin.Name;
42      versionTextBox.Text = plugin.Version.ToString();
43      contactTextBox.Text = CombineStrings(plugin.ContactName, plugin.ContactEmail);
44      foreach (IPluginDescription dependency in plugin.Dependencies) {
45        var depItem = new ListViewItem(new string[] { dependency.Name, dependency.Version.ToString() });
46        depItem.ImageKey = IMAGE_KEY_ASSEMBLY;
47        dependenciesListView.Items.Add(depItem);
48      }
49      foreach (var file in plugin.Files) {
50        string displayedFileName = file.Name.Replace(appDir, string.Empty);
51        displayedFileName = displayedFileName.TrimStart(Path.DirectorySeparatorChar);
52        var fileItem = new ListViewItem(new string[] { displayedFileName, file.Type.ToString() });
53        if (file.Type == PluginFileType.Assembly) {
54          fileItem.ImageKey = IMAGE_KEY_ASSEMBLY;
55        } else if (file.Type == PluginFileType.License) {
56          fileItem.ImageKey = IMAGE_KEY_DOCUMENT;
57        } else fileItem.ImageKey = IMAGE_KEY_FILE;
58        filesListView.Items.Add(fileItem);
59      }
60      licenseButton.Enabled = !string.IsNullOrEmpty(plugin.LicenseText);
61    }
62
63    private string CombineStrings(string a, string b) {
64      if (string.IsNullOrEmpty(a))
65        // a is empty
66        if (!string.IsNullOrEmpty(b)) return CombineStrings(b, string.Empty);
67        else return string.Empty;
68      // a is not empty
69      else if (string.IsNullOrEmpty(b)) return a;
70      // and b are not empty
71      else return a + ", " + b;
72    }
73
74    private void licenseButton_Click(object sender, EventArgs e) {
75      LicenseView view = new LicenseView(plugin.Name, plugin.Version.ToString(), plugin.LicenseText);
76      view.Show();
77    }
78  }
79}
Note: See TracBrowser for help on using the repository browser.