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