Changeset 13369 for branches/RefactorPluginInfrastructure-2522
- Timestamp:
- 11/24/15 17:08:43 (9 years ago)
- 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 150 150 <EmbeddedResource Include="Documents\ALPSGA_TSP.hl" /> 151 151 <None Include="Plugin.cs.frame" /> 152 <Compile Include="MenuItems\AboutPluginsMenuItem.cs" /> 152 153 <Compile Include="OptimizerSingleDocumentMainForm.cs"> 153 154 <SubType>Form</SubType> -
branches/RefactorPluginInfrastructure-2522/HeuristicLab.Optimizer/3.3/MenuItems/AboutMenuItem.cs
r13338 r13369 23 23 using System.Windows.Forms; 24 24 using HeuristicLab.MainForm; 25 using HeuristicLab.PluginInfrastructure; 25 26 using HeuristicLab.PluginInfrastructure.UI; 26 27 … … 41 42 public override void Execute() { 42 43 if (aboutDialog == null) 43 aboutDialog = new AboutDialog( );44 aboutDialog = new AboutDialog(ApplicationManager.Manager.Plugins, GetType().Assembly); // show information about optimizer 44 45 aboutDialog.ShowDialog((IWin32Window)MainFormManager.MainForm); 45 46 } -
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure.UI/AboutDialog.cs
r13363 r13369 37 37 /// </summary> 38 38 /// <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) { 40 40 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(); 45 45 imageList.Images.Add(Resources.Plugin); 46 46 pictureBox.Image = Resources.HeuristicLabLogo; … … 54 54 /// </summary> 55 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(); 56 : this(ApplicationManager.Manager.Plugins, typeof(IPluginDescription).Assembly) { 78 57 } 79 58 80 59 private void okButton_Click(object sender, EventArgs e) { 81 60 Close(); 82 }83 84 private void pluginListView_ItemActivate(object sender, EventArgs e) {85 61 } 86 62 -
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure.UI/PluginInformationDialog.cs
r13363 r13369 23 23 using System.Collections.Generic; 24 24 using System.Drawing; 25 using System.IO;26 25 using System.Linq; 27 using System.Reflection;28 using System.Text.RegularExpressions;29 26 using System.Windows.Forms; 30 27 … … 36 33 public PluginInformationDialog(IEnumerable<IPluginDescription> plugins) { 37 34 InitializeComponent(); 38 var entryAssembly = Assembly.GetEntryAssembly();39 productTextBox.Text = GetProduct(entryAssembly);40 versionTextBox.Text = entryAssembly.GetFileVersion();41 contactTextBox.Text = GetCopyright(entryAssembly);42 35 imageList.Images.Add(Resources.Plugin); 43 36 textBox.Text = Resources.LicenseText; 44 37 PopulatePluginList(plugins); 38 39 // select first plugin to update plugin details 40 pluginListView.Items[0].Selected = true; 41 pluginListView.EnsureVisible(0); 42 45 43 ActiveControl = okButton; 46 44 } … … 66 64 item.SubItems[2].Name = "Description"; 67 65 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();82 66 } 83 67 -
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure.UI/StarterForm.cs
r13360 r13369 24 24 using System.IO; 25 25 using System.Linq; 26 using System.Reflection; 26 27 using System.Threading; 27 28 using System.Threading.Tasks; … … 130 131 private void aboutButton_Click(object sender, EventArgs e) { 131 132 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())) { 133 134 dialog.ShowDialog(); 134 135 } -
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/AssemblyExtensions.cs
r13338 r13369 52 52 return GetCustomAttributeValue<AssemblyFileVersionAttribute>(assembly, "Version"); 53 53 } 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 54 62 } 55 63 }
Note: See TracChangeset
for help on using the changeset viewer.