Free cookie consent management tool by TermsFeed Policy Generator

source: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure.UI/AboutDialog.cs @ 13363

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

#2522: improvements to new PluginInformationDialog and removed obsolete classes

File size: 3.8 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
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Reflection;
26using System.Windows.Forms;
27
28namespace HeuristicLab.PluginInfrastructure.UI {
29  /// <summary>
30  /// Shows product, version and copyright information for HeuristicLab and all plugins.
31  /// </summary>
32  public partial class AboutDialog : Form {
33    private List<IPluginDescription> plugins;
34
35    /// <summary>
36    /// Creates a new about dialog listing all plugins in the <paramref name="plugins"/> enumerable.
37    /// </summary>
38    /// <param name="plugins">Enumerable of plugins that should be listed.</param>
39    public AboutDialog(IEnumerable<IPluginDescription> plugins) {
40      InitializeComponent();
41      var entryAssembly = Assembly.GetEntryAssembly();
42      productTextBox.Text = GetProduct(entryAssembly);
43      versionTextBox.Text = entryAssembly.GetFileVersion();
44      copyrightTextBox.Text = GetCopyright(entryAssembly);
45      imageList.Images.Add(Resources.Plugin);
46      pictureBox.Image = Resources.HeuristicLabLogo;
47      licenseTextBox.Text = Resources.LicenseText;
48      this.plugins = plugins.ToList();
49      ActiveControl = okButton;
50    }
51
52    /// <summary>
53    /// Creates a new about dialog with all plugins loaded in the current application.
54    /// </summary>
55    public AboutDialog()
56      : this(ApplicationManager.Manager.Plugins) {
57    }
58
59    private ListViewItem CreateListViewItem(IPluginDescription plugin) {
60      ListViewItem item = new ListViewItem(new string[] { plugin.Name, plugin.Version.ToString(), plugin.Description });
61      item.Tag = plugin;
62      item.ImageIndex = 0;
63      return item;
64    }
65
66    private string GetCopyright(Assembly asm) {
67      AssemblyCopyrightAttribute attribute = GetAttribute<AssemblyCopyrightAttribute>(asm);
68      return attribute.Copyright;
69    }
70
71    private string GetProduct(Assembly asm) {
72      AssemblyProductAttribute attribute = GetAttribute<AssemblyProductAttribute>(asm);
73      return attribute.Product;
74    }
75
76    private T GetAttribute<T>(Assembly asm) {
77      return (T)asm.GetCustomAttributes(typeof(T), false).Single();
78    }
79
80    private void okButton_Click(object sender, EventArgs e) {
81      Close();
82    }
83
84    private void pluginListView_ItemActivate(object sender, EventArgs e) {
85    }
86
87    private void licenseTextBox_LinkClicked(object sender, LinkClickedEventArgs e) {
88      System.Diagnostics.Process.Start(e.LinkText);
89    }
90
91    private void webLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
92      System.Diagnostics.Process.Start(webLinkLabel.Text);
93    }
94
95    private void mailLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
96      System.Diagnostics.Process.Start("mailto:" + mailLinkLabel.Text);
97    }
98
99    private void showPluginsButton_Click(object sender, EventArgs e) {
100      var d = new PluginInformationDialog(plugins);
101      d.ShowDialog(this);
102    }
103  }
104}
Note: See TracBrowser for help on using the repository browser.