public FormEditSubcategory(Platform platform, PackageSection section, PackageCategory category, PackageSubcategory subcategory)
        {
            InitializeComponent();

            this.platform    = platform;
            this.section     = section;
            this.category    = category;
            this.subcategory = subcategory;

            txtId.Text          = subcategory.ID;
            txtName.Text        = subcategory.Name;
            txtDisplayName.Text = subcategory.DisplayName;
            cbxVisible.Checked  = subcategory.Visible;

            RefreshPlatforms();
            ddlPlatforms.SelectedItem = platform;
            RefreshSections();
            ddlSections.SelectedItem = section;
            RefreshCategories();
            ddlCategories.SelectedItem = category;

            foreach (string k in subcategory.When)
            {
                lvwWhenDependencies.Items.Add(k);
            }
        }
 private void btnSubcategoryOpen_Click(object sender, EventArgs e)
 {
     if (lvwSubcategories.SelectedItems.Count > 0)
     {
         SelectedSubcategory = ((PackageSubcategory)lvwSubcategories.SelectedItems[0].Tag);
         RefreshDisplay();
     }
 }
        public FormEditPackage(Platform platform, PackageSection section, PackageCategory category, PackageSubcategory subcategory)
        {
            InitializeComponent();

            this.platform    = platform;
            this.section     = section;
            this.category    = category;
            this.subcategory = subcategory;

            RefreshPlatforms();
            ddlPlatforms.SelectedItem = platform;
            RefreshSections();
            ddlSections.SelectedItem = section;
            RefreshCategories();
            ddlCategories.SelectedItem = category;
            RefreshSubcategories();
            ddlSubcategories.SelectedItem = subcategory;
        }
        private void btnSubcategorySave_Click(object sender, EventArgs e)
        {
            if (SelectedSubcategory == null)
            {
                SelectedCategory.Subcategories.Add(new PackageSubcategory(txtSubcategoryID.Text, txtSubcategoryName.Text, txtSubcategoryDisplay.Text, cbxSubcategoryVisible.Checked, new List <string>(), 0, new List <Package>()));
            }
            else
            {
                SelectedSubcategory.ID          = txtSubcategoryID.Text;
                SelectedSubcategory.Name        = txtSubcategoryName.Text;
                SelectedSubcategory.DisplayName = txtSubcategoryDisplay.Text;
                SelectedSubcategory.Visible     = cbxSubcategoryVisible.Checked;
            }

            SelectedSubcategory = null;

            RefreshDisplay();
        }
        public FormEditPackage(Platform platform, PackageSection section, PackageCategory category, PackageSubcategory subcategory, Package package)
        {
            InitializeComponent();

            this.platform    = platform;
            this.section     = section;
            this.category    = category;
            this.subcategory = subcategory;
            this.package     = package;

            txtId.Text          = package.ID;
            txtName.Text        = package.Name;
            txtDisplayName.Text = package.DisplayName;
            txtAuthors.Text     = package.Authors;
            txtVersion.Text     = package.Version;
            txtSource.Text      = package.Source;
            txtDlSource.Text    = package.DLSource;
            txtDescription.Text = package.Description;
            cbxVisible.Checked  = package.Visible;
            cbxDefault.Checked  = package.EnabledByDefault;
            nudWhenMode.Value   = package.WhenMode;

            foreach (string k in package.When)
            {
                lvwWhenDependencies.Items.Add(k);
            }
            foreach (string k in package.Dependencies)
            {
                lvwDependencies.Items.Add(k);
            }
            foreach (Artifact k in package.Artifacts)
            {
                artifacts.Add(new Artifact(k.URL, k.Directory, k.FileName, k.DiskLocation));
            }

            RefreshPlatforms();
            ddlPlatforms.SelectedItem = platform;
            RefreshSections();
            ddlSections.SelectedItem = section;
            RefreshCategories();
            ddlCategories.SelectedItem = category;
            RefreshSubcategories();
            ddlSubcategories.SelectedItem = subcategory;
        }
        private void RefreshDisplay()
        {
            lvwPlatforms.Items.Clear();
            foreach (Platform k in manifest.Platforms.Values)
            {
                ListViewItem item = new ListViewItem(k.ID);
                item.Tag = k;
                lvwPlatforms.Items.Add(item);
            }

            if (SelectedPlatform != null)
            {
                txtPlatformID.Text   = SelectedPlatform.ID;
                txtPlatformName.Text = SelectedPlatform.Name;
                txtPlatformMenu.Text = SelectedPlatform.MenuName;
                txtPlatformIcon.Text = SelectedPlatform.HomeIcon;

                lvwSections.Items.Clear();
                foreach (PackageSection k in SelectedPlatform.PackageSections)
                {
                    ListViewItem item = new ListViewItem(k.ID);
                    item.Tag = k;
                    lvwSections.Items.Add(item);
                }

                if (SelectedSection != null)
                {
                    txtSectionName.Text       = SelectedSection.Name;
                    txtSectionDisplay.Text    = SelectedSection.DisplayName;
                    txtSectionID.Text         = SelectedSection.ID;
                    nudDisplayMode.Value      = SelectedSection.ListingMode;
                    cbxSectionVisible.Checked = SelectedSection.Visible;

                    lvwCategories.Items.Clear();
                    foreach (PackageCategory k in SelectedSection.Categories)
                    {
                        ListViewItem item = new ListViewItem(k.ID);
                        item.Tag = k;
                        lvwCategories.Items.Add(item);
                    }

                    if (SelectedCategory != null)
                    {
                        txtCategoryName.Text       = SelectedCategory.Name;
                        txtCategoryDisplay.Text    = SelectedCategory.DisplayName;
                        txtCategoryID.Text         = SelectedCategory.ID;
                        cbxCategoryVisible.Checked = SelectedCategory.Visible;

                        lvwSubcategories.Items.Clear();
                        foreach (PackageSubcategory k in SelectedCategory.Subcategories)
                        {
                            ListViewItem item = new ListViewItem(k.ID);
                            item.Tag = k;
                            lvwSubcategories.Items.Add(item);
                        }

                        if (SelectedSubcategory != null)
                        {
                            txtSubcategoryName.Text       = SelectedSubcategory.Name;
                            txtSubcategoryDisplay.Text    = SelectedSubcategory.DisplayName;
                            txtSubcategoryID.Text         = SelectedSubcategory.ID;
                            cbxSubcategoryVisible.Checked = SelectedSubcategory.Visible;

                            lvwPackages.Items.Clear();
                            foreach (Package k in SelectedSubcategory.Packages)
                            {
                                ListViewItem item = new ListViewItem(k.ID);
                                item.Tag = k;
                                lvwPackages.Items.Add(item);
                            }

                            if (SelectedPackage != null)
                            {
                                txtPackageId.Text         = SelectedPackage.ID;
                                txtPackageName.Text       = SelectedPackage.Name;
                                txtPackageDisplay.Text    = SelectedPackage.DisplayName;
                                cbxPackageVisible.Checked = SelectedPackage.Visible;
                                txtPackageAuthors.Text    = SelectedPackage.Authors;
                                txtDescription.Text       = SelectedPackage.Description;
                                txtPackageDlSource.Text   = SelectedPackage.DLSource;
                                txtPackageSource.Text     = SelectedPackage.Source;
                                txtPackageVersion.Text    = SelectedPackage.Version;
                                cbxPackageDefault.Checked = SelectedPackage.EnabledByDefault;
                                lvwPackageDependencies.Items.Clear();
                                foreach (string k in SelectedPackage.Dependencies)
                                {
                                    lvwPackageDependencies.Items.Add(k);
                                }
                            }
                        }
                        else
                        {
                            SelectedPackage = null;
                        }
                    }
                    else
                    {
                        SelectedPackage     = null;
                        SelectedSubcategory = null;
                    }
                }
                else
                {
                    SelectedPackage     = null;
                    SelectedCategory    = null;
                    SelectedSubcategory = null;
                }
            }
            else
            {
                SelectedPackage     = null;
                SelectedSection     = null;
                SelectedCategory    = null;
                SelectedSubcategory = null;
            }
        }