Exemplo n.º 1
0
        private bool EditCatalogueDescription()
        {
            string newDescription = tbDescription.Text.Trim();

            CatalogueInfo selectedCatalogue = CataloguesIndex.GetByName(_selectedCatalogueName);

            string oldDescription = selectedCatalogue.Description?.Trim() ?? "";

            if (oldDescription == newDescription)
            {
                return(true);
            }

            string errorText;

            AddonPackageSet selectedAddonPackageSet = AddonPackageSet.Load(out errorText, selectedCatalogue.FilePath);

            selectedAddonPackageSet.SetDescription(newDescription);

            if (!selectedAddonPackageSet.Save(out errorText, selectedCatalogue.FilePath))
            {
                MessageBox.Show(errorText, "Error saving updated catalogue", MessageBoxButtons.OK);
                tbDescription.Focus();
                return(false);
            }

            CataloguesIndex.Update(_selectedCatalogueName, newDescription);

            NewAddonPackageSet = selectedAddonPackageSet;
            return(true);
        }
Exemplo n.º 2
0
        // ----------------------------------------------------------------------------------------------------------------------

        private bool NewCatalogue()
        {
            string newCatalogueName = CheckCatalogueName(tbNewCat.Text);

            if (newCatalogueName == null)
            {
                tbNewCat.Focus();
                return(false);
            }

            if (CheckNameDuplicate(newCatalogueName))
            {
                tbNewCat.Focus();
                return(false);
            }

            NewAddonPackageSet = new AddonPackageSet(_moviestormPaths, null, tbDescription.Text.Trim());

            string newCatalogueFilename = newCatalogueName + ".scat";
            string errorText;

            NewAddonPackageSet.Save(out errorText, newCatalogueFilename);

            CataloguesIndex.Update(newCatalogueName, tbDescription.Text, NewAddonPackageSet.Addons?.Count ?? 0, NewAddonPackageSet.LastUpdate, NewAddonPackageSet.CatalogueVersion);
            NewAddonPackageSetName = newCatalogueName;

            return(true);
        }
Exemplo n.º 3
0
        private bool CopyCatalogue()
        {
            string newCatalogueName = CheckCatalogueName(tbNewCat.Text);

            if (newCatalogueName == null)
            {
                tbNewCat.Focus();
                return(false);
            }

            if (CheckNameDuplicate(newCatalogueName))
            {
                tbNewCat.Focus();
                return(false);
            }

            CatalogueInfo selectedCatalogue = CataloguesIndex.GetByName(_selectedCatalogueName);

            string errorText;

            AddonPackageSet newPackageSet = AddonPackageSet.Load(out errorText, selectedCatalogue.FilePath);

            newPackageSet.SetDescription(tbDescription.Text.Trim());

            if (!newPackageSet.Save(out errorText, newCatalogueName + ".scat"))
            {
                MessageBox.Show(errorText, "Error saving copied catalogue", MessageBoxButtons.OK);
                return(false);
            }

            CataloguesIndex.Update(newCatalogueName, tbDescription.Text.Trim(), newPackageSet.Addons?.Count ?? 0, newPackageSet.LastUpdate, newPackageSet.CatalogueVersion);

            NewAddonPackageSet     = newPackageSet;
            NewAddonPackageSetName = newCatalogueName;
            return(true);
        }