Changeset 13369


Ignore:
Timestamp:
11/24/15 17:08:43 (3 years ago)
Author:
gkronber
Message:

#2522: improvements to AboutDialog and PluginInformationDialog

Location:
branches/RefactorPluginInfrastructure-2522
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/RefactorPluginInfrastructure-2522/HeuristicLab.Optimizer/3.3/HeuristicLab.Optimizer-3.3.csproj

    r13338 r13369  
    150150    <EmbeddedResource Include="Documents\ALPSGA_TSP.hl" />
    151151    <None Include="Plugin.cs.frame" />
     152    <Compile Include="MenuItems\AboutPluginsMenuItem.cs" />
    152153    <Compile Include="OptimizerSingleDocumentMainForm.cs">
    153154      <SubType>Form</SubType>
  • branches/RefactorPluginInfrastructure-2522/HeuristicLab.Optimizer/3.3/MenuItems/AboutMenuItem.cs

    r13338 r13369  
    2323using System.Windows.Forms;
    2424using HeuristicLab.MainForm;
     25using HeuristicLab.PluginInfrastructure;
    2526using HeuristicLab.PluginInfrastructure.UI;
    2627
     
    4142    public override void Execute() {
    4243      if (aboutDialog == null)
    43         aboutDialog = new AboutDialog();
     44        aboutDialog = new AboutDialog(ApplicationManager.Manager.Plugins, GetType().Assembly); // show information about optimizer
    4445      aboutDialog.ShowDialog((IWin32Window)MainFormManager.MainForm);
    4546    }
  • branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure.UI/AboutDialog.cs

    r13363 r13369  
    3737    /// </summary>
    3838    /// <param name="plugins">Enumerable of plugins that should be listed.</param>
    39     public AboutDialog(IEnumerable<IPluginDescription> plugins) {
     39    public AboutDialog(IEnumerable<IPluginDescription> plugins, Assembly mainAssembly) {
    4040      InitializeComponent();
    41       var entryAssembly = Assembly.GetEntryAssembly();
    42       productTextBox.Text = GetProduct(entryAssembly);
    43       versionTextBox.Text = entryAssembly.GetFileVersion();
    44       copyrightTextBox.Text = GetCopyright(entryAssembly);
     41
     42      productTextBox.Text = mainAssembly.GetProduct();
     43      versionTextBox.Text = mainAssembly.GetFileVersion();
     44      copyrightTextBox.Text = mainAssembly.GetCopyright();
    4545      imageList.Images.Add(Resources.Plugin);
    4646      pictureBox.Image = Resources.HeuristicLabLogo;
     
    5454    /// </summary>
    5555    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();
     56      : this(ApplicationManager.Manager.Plugins, typeof(IPluginDescription).Assembly) {
    7857    }
    7958
    8059    private void okButton_Click(object sender, EventArgs e) {
    8160      Close();
    82     }
    83 
    84     private void pluginListView_ItemActivate(object sender, EventArgs e) {
    8561    }
    8662
  • branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure.UI/PluginInformationDialog.cs

    r13363 r13369  
    2323using System.Collections.Generic;
    2424using System.Drawing;
    25 using System.IO;
    2625using System.Linq;
    27 using System.Reflection;
    28 using System.Text.RegularExpressions;
    2926using System.Windows.Forms;
    3027
     
    3633    public PluginInformationDialog(IEnumerable<IPluginDescription> plugins) {
    3734      InitializeComponent();
    38       var entryAssembly = Assembly.GetEntryAssembly();
    39       productTextBox.Text = GetProduct(entryAssembly);
    40       versionTextBox.Text = entryAssembly.GetFileVersion();
    41       contactTextBox.Text = GetCopyright(entryAssembly);
    4235      imageList.Images.Add(Resources.Plugin);
    4336      textBox.Text = Resources.LicenseText;
    4437      PopulatePluginList(plugins);
     38
     39      // select first plugin to update plugin details
     40      pluginListView.Items[0].Selected = true;
     41      pluginListView.EnsureVisible(0);
     42
    4543      ActiveControl = okButton;
    4644    }
     
    6664      item.SubItems[2].Name = "Description";
    6765      return item;
    68     }
    69 
    70     private string GetCopyright(Assembly asm) {
    71       AssemblyCopyrightAttribute attribute = GetAttribute<AssemblyCopyrightAttribute>(asm);
    72       return attribute.Copyright;
    73     }
    74 
    75     private string GetProduct(Assembly asm) {
    76       AssemblyProductAttribute attribute = GetAttribute<AssemblyProductAttribute>(asm);
    77       return attribute.Product;
    78     }
    79 
    80     private T GetAttribute<T>(Assembly asm) {
    81       return (T)asm.GetCustomAttributes(typeof(T), false).Single();
    8266    }
    8367
  • branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure.UI/StarterForm.cs

    r13360 r13369  
    2424using System.IO;
    2525using System.Linq;
     26using System.Reflection;
    2627using System.Threading;
    2728using System.Threading.Tasks;
     
    130131    private void aboutButton_Click(object sender, EventArgs e) {
    131132      List<IPluginDescription> plugins = new List<IPluginDescription>(pluginManager.Plugins.OfType<IPluginDescription>());
    132       using (var dialog = new AboutDialog(plugins)) {
     133      using (var dialog = new AboutDialog(plugins, Assembly.GetEntryAssembly())) {
    133134        dialog.ShowDialog();
    134135      }
  • branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/AssemblyExtensions.cs

    r13338 r13369  
    5252      return GetCustomAttributeValue<AssemblyFileVersionAttribute>(assembly, "Version");
    5353    }
     54    public static string GetCopyright(this Assembly assembly) {
     55      return GetCustomAttributeValue<AssemblyCopyrightAttribute>(assembly, "Copyright");
     56    }
     57
     58    public static string GetProduct(this Assembly assembly) {
     59      return GetCustomAttributeValue<AssemblyProductAttribute>(assembly, "Product");
     60    }
     61
    5462  }
    5563}
Note: See TracChangeset for help on using the changeset viewer.