private void versionTextBox_TextChanged(object sender, EventArgs e)
        {
            if (productsListView.SelectedItems.Count > 0)
            {
                ListViewItem activeItem = (ListViewItem)productsListView.SelectedItems[0];
                DeploymentService.ProductDescription activeProduct = (DeploymentService.ProductDescription)activeItem.Tag;
                try {
                    var newVersion = new Version(versionTextBox.Text);
                    if (activeProduct.Version != newVersion)
                    {
                        activeProduct.Version       = newVersion;
                        activeItem.SubItems[1].Text = versionTextBox.Text;
                        errorProvider.SetError(versionTextBox, string.Empty);
                        MarkProductDirty(activeProduct);
                    }
                }
                catch (OverflowException) {
                    errorProvider.SetError(versionTextBox, "Invalid value");
                }

                catch (ArgumentException) {
                    errorProvider.SetError(versionTextBox, "Invalid value");
                }
                catch (FormatException) {
                    errorProvider.SetError(versionTextBox, "Invalid value");
                }
            }
        }
        private void productsListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            bool productSelected = productsListView.SelectedItems.Count > 0;

            detailsGroupBox.Enabled = productSelected;
            UpdateProductButtons();
            if (productSelected)
            {
                DeploymentService.ProductDescription activeProduct = (DeploymentService.ProductDescription)((ListViewItem)productsListView.SelectedItems[0]).Tag;
                nameTextBox.Text    = activeProduct.Name;
                versionTextBox.Text = activeProduct.Version.ToString();

                // populate plugins list view
                pluginListView.SuppressItemCheckedEvents = true;
                foreach (var plugin in plugins.OfType <IPluginDescription>())
                {
                    pluginListView.Items.Add(CreateListViewItem(plugin));
                }
                pluginListView.SuppressItemCheckedEvents = false;
                foreach (var plugin in activeProduct.Plugins)
                {
                    pluginListView.CheckItems(FindItemsForPlugin(plugin));
                }
            }
            else
            {
                nameTextBox.Text    = string.Empty;
                versionTextBox.Text = string.Empty;
                pluginListView.Items.Clear();
            }
            Util.ResizeColumns(pluginListView.Columns.OfType <ColumnHeader>());
        }
        private ListViewItem CreateListViewItem(DeploymentService.ProductDescription productDescription)
        {
            ListViewItem item = new ListViewItem(new string[] { productDescription.Name, productDescription.Version.ToString() });

            item.Tag        = productDescription;
            item.ImageIndex = 0;
            return(item);
        }
        private void newProductButton_Click(object sender, EventArgs e)
        {
            var newProduct = new DeploymentService.ProductDescription("New product", new Version("0.0.0.0"));

            products.Add(newProduct);
            UpdateProductsList();
            MarkProductDirty(newProduct);
        }
        private void OnItemChecked(ItemCheckedEventArgs e)
        {
            ListViewItem activeItem = (ListViewItem)productsListView.SelectedItems[0];

            DeploymentService.ProductDescription activeProduct = (DeploymentService.ProductDescription)activeItem.Tag;
            activeProduct.Plugins = (from item in pluginListView.CheckedItems.OfType <ListViewItem>()
                                     select(DeploymentService.PluginDescription) item.Tag).ToArray();
            MarkProductDirty(activeProduct);
        }
 private void nameTextBox_TextChanged(object sender, EventArgs e)
 {
     if (productsListView.SelectedItems.Count > 0)
     {
         ListViewItem activeItem = (ListViewItem)productsListView.SelectedItems[0];
         DeploymentService.ProductDescription activeProduct = (DeploymentService.ProductDescription)activeItem.Tag;
         if (string.IsNullOrEmpty(nameTextBox.Name))
         {
             errorProvider.SetError(nameTextBox, "Invalid value");
         }
         else
         {
             if (activeProduct.Name != nameTextBox.Text)
             {
                 activeProduct.Name          = nameTextBox.Text;
                 activeItem.SubItems[0].Text = activeProduct.Name;
                 errorProvider.SetError(nameTextBox, string.Empty);
                 MarkProductDirty(activeProduct);
             }
         }
     }
 }
Exemplo n.º 7
0
 private void newProductButton_Click(object sender, EventArgs e) {
   var newProduct = new DeploymentService.ProductDescription("New product", new Version("0.0.0.0"));
   products.Add(newProduct);
   UpdateProductsList();
   MarkProductDirty(newProduct);
 }