Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Starter/AboutDialog.cs @ 9283

Last change on this file since 9283 was 7259, checked in by swagner, 13 years ago

Updated year of copyrights to 2012 (#1716)

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