- Timestamp:
- 04/21/10 20:05:33 (14 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure/Advanced/ProductEditor.cs
r3461 r3474 28 28 using System.Text; 29 29 using System.Windows.Forms; 30 using HeuristicLab.MainForm;31 using PluginDeploymentService = HeuristicLab.PluginInfrastructure.Advanced.DeploymentService;32 30 using System.ServiceModel; 33 31 using HeuristicLab.PluginInfrastructure; 34 32 35 namespace HeuristicLab.Plugin Administrator{36 internal partial class ProductEditor : HeuristicLab.MainForm.WindowsForms.View{33 namespace HeuristicLab.PluginInfrastructure.Advanced { 34 internal partial class ProductEditor : UserControl { 37 35 private BackgroundWorker refreshProductsWorker; 38 36 private BackgroundWorker uploadChangedProductsWorker; 39 private List< PluginDeploymentService.ProductDescription> products;40 private List< PluginDeploymentService.PluginDescription> plugins;41 private HashSet< PluginDeploymentService.ProductDescription> dirtyProducts;37 private List<DeploymentService.ProductDescription> products; 38 private List<DeploymentService.PluginDescription> plugins; 39 private HashSet<DeploymentService.ProductDescription> dirtyProducts; 42 40 43 41 public ProductEditor() { 44 42 InitializeComponent(); 45 Caption = "Products"; 46 47 productImageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.Assembly); 48 productImageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.ArrowUp); 49 pluginImageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.Assembly); 50 51 dirtyProducts = new HashSet<PluginDeploymentService.ProductDescription>(); 43 44 productImageList.Images.Add(HeuristicLab.PluginInfrastructure.Resources.Resources.Assembly); 45 productImageList.Images.Add(HeuristicLab.PluginInfrastructure.Resources.Resources.ArrowUp); 46 pluginImageList.Images.Add(HeuristicLab.PluginInfrastructure.Resources.Resources.Assembly); 47 48 dirtyProducts = new HashSet<DeploymentService.ProductDescription>(); 52 49 refreshProductsWorker = new BackgroundWorker(); 53 50 refreshProductsWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(refreshProductsWorker_RunWorkerCompleted); … … 61 58 #region event handlers for upload products background worker 62 59 private void uploadChangedProductsWorker_DoWork(object sender, DoWorkEventArgs e) { 63 var products = (IEnumerable< PluginDeploymentService.ProductDescription>)e.Argument;64 var adminClient = PluginDeploymentService.AdminClientFactory.CreateClient();60 var products = (IEnumerable<DeploymentService.ProductDescription>)e.Argument; 61 var adminClient = DeploymentService.AdminClientFactory.CreateClient(); 65 62 try { 66 63 foreach (var product in products) { … … 81 78 #region event handlers for refresh products background worker 82 79 private void refreshProductsWorker_DoWork(object sender, DoWorkEventArgs e) { 83 var updateClient = PluginDeploymentService.UpdateClientFactory.CreateClient();80 var updateClient = DeploymentService.UpdateClientFactory.CreateClient(); 84 81 try { 85 82 e.Result = new object[] { updateClient.GetProducts(), updateClient.GetPlugins() }; … … 92 89 private void refreshProductsWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { 93 90 if (!e.Cancelled && e.Result != null) { 94 this.products = new List< PluginDeploymentService.ProductDescription>(95 ( PluginDeploymentService.ProductDescription[])((object[])e.Result)[0]);96 this.plugins = new List< PluginDeploymentService.PluginDescription>(97 ( PluginDeploymentService.PluginDescription[])((object[])e.Result)[1]);91 this.products = new List<DeploymentService.ProductDescription>( 92 (DeploymentService.ProductDescription[])((object[])e.Result)[0]); 93 this.plugins = new List<DeploymentService.PluginDescription>( 94 (DeploymentService.PluginDescription[])((object[])e.Result)[1]); 98 95 99 96 UpdateProductsList(); … … 123 120 return; 124 121 } 125 PluginDeploymentService.ProductDescription activeProduct = (PluginDeploymentService.ProductDescription)((ListViewItem)productsListView.SelectedItems[0]).Tag;122 DeploymentService.ProductDescription activeProduct = (DeploymentService.ProductDescription)((ListViewItem)productsListView.SelectedItems[0]).Tag; 126 123 UpdateProductDetails(activeProduct); 127 124 } … … 133 130 } 134 131 135 private void UpdateProductDetails( PluginDeploymentService.ProductDescription activeProduct) {132 private void UpdateProductDetails(DeploymentService.ProductDescription activeProduct) { 136 133 nameTextBox.Text = activeProduct.Name; 137 134 versionTextBox.Text = activeProduct.Version.ToString(); … … 140 137 } 141 138 142 private ListViewItem CreateListViewItem( PluginDeploymentService.ProductDescription productDescription) {139 private ListViewItem CreateListViewItem(DeploymentService.ProductDescription productDescription) { 143 140 ListViewItem item = new ListViewItem(new string[] { productDescription.Name, productDescription.Version.ToString() }); 144 141 item.Tag = productDescription; … … 162 159 #region button event handlers 163 160 private void newProductButton_Click(object sender, EventArgs e) { 164 var newProduct = new PluginDeploymentService.ProductDescription("New product", new Version("0.0.0.0"));161 var newProduct = new DeploymentService.ProductDescription("New product", new Version("0.0.0.0")); 165 162 ListViewItem item = CreateListViewItem(newProduct); 166 163 productsListView.Items.Add(item); … … 183 180 private void nameTextBox_TextChanged(object sender, EventArgs e) { 184 181 ListViewItem activeItem = (ListViewItem)productsListView.SelectedItems[0]; 185 PluginDeploymentService.ProductDescription activeProduct = (PluginDeploymentService.ProductDescription)activeItem.Tag;182 DeploymentService.ProductDescription activeProduct = (DeploymentService.ProductDescription)activeItem.Tag; 186 183 if (string.IsNullOrEmpty(nameTextBox.Name)) { 187 184 errorProvider.SetError(nameTextBox, "Invalid value"); … … 199 196 private void versionTextBox_TextChanged(object sender, EventArgs e) { 200 197 ListViewItem activeItem = (ListViewItem)productsListView.SelectedItems[0]; 201 PluginDeploymentService.ProductDescription activeProduct = (PluginDeploymentService.ProductDescription)activeItem.Tag;198 DeploymentService.ProductDescription activeProduct = (DeploymentService.ProductDescription)activeItem.Tag; 202 199 try { 203 200 var newVersion = new Version(versionTextBox.Text); … … 226 223 private void UpdatePluginsListView() { 227 224 ListViewItem activeItem = (ListViewItem)productsListView.SelectedItems[0]; 228 PluginDeploymentService.ProductDescription activeProduct = (PluginDeploymentService.ProductDescription)activeItem.Tag;225 DeploymentService.ProductDescription activeProduct = (DeploymentService.ProductDescription)activeItem.Tag; 229 226 pluginListView.Plugins = plugins.OfType<IPluginDescription>(); 230 227 foreach (var plugin in activeProduct.Plugins) pluginListView.CheckPlugin(plugin); … … 233 230 private void pluginListView_ItemChecked(object sender, ItemCheckedEventArgs e) { 234 231 ListViewItem activeItem = (ListViewItem)productsListView.SelectedItems[0]; 235 PluginDeploymentService.ProductDescription activeProduct = (PluginDeploymentService.ProductDescription)activeItem.Tag;236 activeProduct.Plugins = pluginListView.CheckedPlugins.Cast< PluginDeploymentService.PluginDescription>().ToArray();232 DeploymentService.ProductDescription activeProduct = (DeploymentService.ProductDescription)activeItem.Tag; 233 activeProduct.Plugins = pluginListView.CheckedPlugins.Cast<DeploymentService.PluginDescription>().ToArray(); 237 234 MarkProductDirty(activeProduct); 238 235 } … … 248 245 private ListViewItem FindItemForProduct(HeuristicLab.PluginInfrastructure.Advanced.DeploymentService.ProductDescription activeProduct) { 249 246 return (from item in productsListView.Items.OfType<ListViewItem>() 250 let product = item.Tag as PluginDeploymentService.ProductDescription247 let product = item.Tag as DeploymentService.ProductDescription 251 248 where product != null 252 249 where product == activeProduct
Note: See TracChangeset
for help on using the changeset viewer.