Changeset 2860 for branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/PluginView.cs
- Timestamp:
- 02/24/10 14:34:07 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/PluginView.cs
r2816 r2860 8 8 using System.Windows.Forms; 9 9 using HeuristicLab.PluginInfrastructure; 10 using System.IO; 10 11 11 12 namespace HeuristicLab.DeploymentService.AdminClient { 12 13 public partial class PluginView : UserControl { 14 private const string IMAGE_KEY_ASSEMBLY = "Assembly"; 15 private const string IMAGE_KEY_FILE = "File"; 16 private const string IMAGE_KEY_DOCUMENT = "Document"; 17 18 private IPluginDescription plugin; 19 13 20 public PluginView() { 14 21 InitializeComponent(); 22 PopulateImageList(); 23 } 24 25 public PluginView(IPluginDescription plugin) { 26 InitializeComponent(); 27 PopulateImageList(); 28 29 this.plugin = plugin; 30 UpdateControls(); 31 } 32 33 private void PopulateImageList() { 34 imageList.Images.Add(IMAGE_KEY_ASSEMBLY, HeuristicLab.Common.Resources.VS2008ImageLibrary.Assembly); 35 imageList.Images.Add(IMAGE_KEY_FILE, HeuristicLab.Common.Resources.VS2008ImageLibrary.File); 36 imageList.Images.Add(IMAGE_KEY_DOCUMENT, HeuristicLab.Common.Resources.VS2008ImageLibrary.Document); 37 } 38 39 public void UpdateControls() { 40 string appDir = Path.GetDirectoryName(Application.ExecutablePath); 41 nameTextBox.Text = plugin.Name; 42 versionTextBox.Text = plugin.Version.ToString(); 43 contactTextBox.Text = CombineStrings(plugin.ContactName, plugin.ContactEmail); 44 foreach (IPluginDescription dependency in plugin.Dependencies) { 45 var depItem = new ListViewItem(new string[] { dependency.Name, dependency.Version.ToString() }); 46 depItem.ImageKey = IMAGE_KEY_ASSEMBLY; 47 dependenciesListView.Items.Add(depItem); 48 } 49 foreach (var file in plugin.Files) { 50 string displayedFileName = file.Name.Replace(appDir, string.Empty); 51 displayedFileName = displayedFileName.TrimStart(Path.DirectorySeparatorChar); 52 var fileItem = new ListViewItem(new string[] { displayedFileName, file.Type.ToString() }); 53 if (file.Type == PluginFileType.Assembly) { 54 fileItem.ImageKey = IMAGE_KEY_ASSEMBLY; 55 } else if (file.Type == PluginFileType.License) { 56 fileItem.ImageKey = IMAGE_KEY_DOCUMENT; 57 } else fileItem.ImageKey = IMAGE_KEY_FILE; 58 filesListView.Items.Add(fileItem); 59 } 60 licenseButton.Enabled = !string.IsNullOrEmpty(plugin.LicenseText); 61 } 62 63 private string CombineStrings(string a, string b) { 64 if (string.IsNullOrEmpty(a)) 65 // a is empty 66 if (!string.IsNullOrEmpty(b)) return CombineStrings(b, string.Empty); 67 else return string.Empty; 68 // a is not empty 69 else if (string.IsNullOrEmpty(b)) return a; 70 // and b are not empty 71 else return a + ", " + b; 72 } 73 74 private void licenseButton_Click(object sender, EventArgs e) { 75 LicenseView view = new LicenseView(plugin.Name, plugin.Version.ToString(), plugin.LicenseText); 76 view.Show(); 15 77 } 16 78 }
Note: See TracChangeset
for help on using the changeset viewer.