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); }
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); }
private void CatalogueIndexOpsForm_Load(object sender, EventArgs e) { CatalogueInfo currentCatalogue; if (CataloguesIndex == null) { MessageBox.Show("ERROR: No Catalogue Index has been specified", "Error", MessageBoxButtons.OK); DialogResult = DialogResult.Cancel; Close(); return; } if (_operation != CataloguesIndexOperation.NewCatalogue) { if (CataloguesIndex.GetIndexByName(_selectedCatalogueName) < 0) { MessageBox.Show("ERROR: Current Catalogue not found in the index", "Error", MessageBoxButtons.OK); DialogResult = DialogResult.Cancel; Close(); return; } } SetToolTips(); ContextHelp.HelpNamespace = Globals.HelpFilename; ContextHelp.SetHelpNavigator(this, HelpNavigator.TopicId); switch (_operation) { case CataloguesIndexOperation.NewCatalogue: Text = "Create New Catalogue"; lblCurrentCat.Visible = tbCurrentCat.Visible = false; tbNewCat.Focus(); break; case CataloguesIndexOperation.RenameCatalogue: Text = "Rename Selected Catalogue"; tbCurrentCat.Text = _selectedCatalogueName; lblNewCat.Text = "New Name:"; tbDescription.ReadOnly = true; currentCatalogue = CataloguesIndex.GetByName(_selectedCatalogueName); tbDescription.Text = currentCatalogue.Description; tbNewCat.Focus(); break; case CataloguesIndexOperation.EditDescription: Text = "Edit Description of Selected Catalogue"; tbCurrentCat.Text = _selectedCatalogueName; lblNewCat.Visible = tbNewCat.Visible = false; tbDescription.ReadOnly = false; _formToolTip.SetToolTip(tbDescription, "New description of the selected catalogue"); currentCatalogue = CataloguesIndex.GetByName(_selectedCatalogueName); tbDescription.Text = currentCatalogue.Description; tbDescription.Focus(); break; case CataloguesIndexOperation.CopyCatalogue: Text = "Copy Current Catalogue"; tbCurrentCat.Text = _selectedCatalogueName; lblNewCat.Text = "New Catalogue:"; _formToolTip.SetToolTip(tbNewCat, "Name of the new (copy) catalogue"); _formToolTip.SetToolTip(tbDescription, "Description of the new (copy) catalogue"); tbDescription.ReadOnly = false; currentCatalogue = CataloguesIndex.GetByName(_selectedCatalogueName); tbDescription.Text = currentCatalogue.Description; tbNewCat.Focus(); break; } }