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 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); }
// ----------------------------------------------------------------------------------------------- public CatalogueIndexOpsForm(CataloguesIndexOperation pOperation, MoviestormPaths pMoviestormPaths, CataloguesIndex pCataloguesIndex, string pSelectedCatalogueName) { _operation = pOperation; _moviestormPaths = pMoviestormPaths; CataloguesIndex = pCataloguesIndex; _selectedCatalogueName = pSelectedCatalogueName; InitializeComponent(); }
private bool CheckNameDuplicate(string pName) { int index = CataloguesIndex.GetIndexByName(pName); if (index < 0) { return(false); } MessageBox.Show("There's already a catalogue with this name", "Name duplicated", MessageBoxButtons.OK); return(true); }
private bool RenameCatalogue() { string newCatalogueName = CheckCatalogueName(tbNewCat.Text); if (newCatalogueName == null) { tbNewCat.Focus(); return(false); } if (CheckNameDuplicate(newCatalogueName)) { tbNewCat.Focus(); return(false); } try { string oldFilename = _selectedCatalogueName + ".scat"; string newFilename = newCatalogueName + ".scat"; File.Move(oldFilename, newFilename); } catch (Exception exception) { MessageBox.Show(exception.Message, "Error renaming file", MessageBoxButtons.OK); tbNewCat.Focus(); return(false); } CataloguesIndex.Rename(_selectedCatalogueName, newCatalogueName); // NewAddonPackageSet = _selectedAddonPackageSet; NewAddonPackageSetName = newCatalogueName; 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; } }