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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Linq;
|
---|
25 | using System.Reflection;
|
---|
26 | using System.Windows.Forms;
|
---|
27 |
|
---|
28 | namespace 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 | /// <summary>
|
---|
34 | /// Creates a new about dialog with all plugins loaded in the current application.
|
---|
35 | /// </summary>
|
---|
36 | public AboutDialog() {
|
---|
37 | InitializeComponent();
|
---|
38 | var curAssembly = this.GetType().Assembly;
|
---|
39 | productTextBox.Text = GetProduct(curAssembly);
|
---|
40 | versionTextBox.Text = GetVersion();
|
---|
41 | copyrightTextBox.Text = GetCopyright(curAssembly);
|
---|
42 | imageList.Images.Add(Resources.Plugin);
|
---|
43 | pictureBox.Image = Resources.HeuristicLabLogo;
|
---|
44 | licenseTextBox.Text = Resources.LicenseText;
|
---|
45 | UpdatePluginList(ApplicationManager.Manager.Plugins);
|
---|
46 | ActiveControl = okButton;
|
---|
47 | }
|
---|
48 |
|
---|
49 | /// <summary>
|
---|
50 | /// Creates a new about dialog listing all plugins in the <paramref name="plugins"/> enumerable.
|
---|
51 | /// </summary>
|
---|
52 | /// <param name="plugins">Enumerable of plugins that should be listed.</param>
|
---|
53 | public AboutDialog(IEnumerable<IPluginDescription> plugins)
|
---|
54 | : this() {
|
---|
55 | UpdatePluginList(plugins);
|
---|
56 | }
|
---|
57 |
|
---|
58 | private void UpdatePluginList(IEnumerable<IPluginDescription> plugins) {
|
---|
59 | pluginListView.Items.Clear();
|
---|
60 | foreach (var plugin in plugins) {
|
---|
61 | ListViewItem pluginItem = CreateListViewItem(plugin);
|
---|
62 | pluginListView.Items.Add(pluginItem);
|
---|
63 | }
|
---|
64 | Util.ResizeColumns(pluginListView.Columns.OfType<ColumnHeader>());
|
---|
65 | }
|
---|
66 |
|
---|
67 | private ListViewItem CreateListViewItem(IPluginDescription plugin) {
|
---|
68 | ListViewItem item = new ListViewItem(new string[] { plugin.Name, plugin.Version.ToString(), plugin.Description });
|
---|
69 | item.Tag = plugin;
|
---|
70 | item.ImageIndex = 0;
|
---|
71 | return item;
|
---|
72 | }
|
---|
73 |
|
---|
74 | private string GetCopyright(Assembly asm) {
|
---|
75 | AssemblyCopyrightAttribute attribute = GetAttribute<AssemblyCopyrightAttribute>(asm);
|
---|
76 | return attribute.Copyright;
|
---|
77 | }
|
---|
78 |
|
---|
79 | private string GetVersion() {
|
---|
80 | return AssemblyExtensions.GetFileVersion(GetType().Assembly);
|
---|
81 | }
|
---|
82 |
|
---|
83 | private string GetProduct(Assembly asm) {
|
---|
84 | AssemblyProductAttribute attribute = GetAttribute<AssemblyProductAttribute>(asm);
|
---|
85 | return attribute.Product;
|
---|
86 | }
|
---|
87 |
|
---|
88 | private T GetAttribute<T>(Assembly asm) {
|
---|
89 | return (T)asm.GetCustomAttributes(typeof(T), false).Single();
|
---|
90 | }
|
---|
91 |
|
---|
92 | private void okButton_Click(object sender, EventArgs e) {
|
---|
93 | Close();
|
---|
94 | }
|
---|
95 |
|
---|
96 | private void pluginListView_ItemActivate(object sender, EventArgs e) {
|
---|
97 | if (pluginListView.SelectedItems.Count > 0) {
|
---|
98 | PluginView view = new PluginView((IPluginDescription)pluginListView.SelectedItems[0].Tag);
|
---|
99 | view.Show(this);
|
---|
100 | }
|
---|
101 | }
|
---|
102 |
|
---|
103 | private void licenseTextBox_LinkClicked(object sender, LinkClickedEventArgs e) {
|
---|
104 | System.Diagnostics.Process.Start(e.LinkText);
|
---|
105 | }
|
---|
106 |
|
---|
107 | private void webLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
|
---|
108 | System.Diagnostics.Process.Start(webLinkLabel.Text);
|
---|
109 | }
|
---|
110 |
|
---|
111 | private void mailLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
|
---|
112 | System.Diagnostics.Process.Start("mailto:" + mailLinkLabel.Text);
|
---|
113 | }
|
---|
114 | }
|
---|
115 | }
|
---|