Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
xantari committed Mar 28, 2021
1 parent 385f8ce commit abbabec
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 15 deletions.
15 changes: 9 additions & 6 deletions PinCab.Configurator/DatabaseBrowserForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 25 additions & 9 deletions PinCab.Configurator/DatabaseBrowserForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -901,18 +901,38 @@ private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
if (row != null)
{
//Scan the database it's attached to to see how many related entries need to be removed
var numRelatedEntriesToBeRemoved = _dbManager.Databases[row.DatabaseName].Entries
.Count(c => c.RelatedEntries != null && c.RelatedEntries.Any(b => b == row.Id));

//Prompt to user indicating how many other entries will be cleaned up
var deleteFromDatabase = MessageBox.Show($"Are you sure you want to delete: {row.Title}? {numRelatedEntriesToBeRemoved} related entries will also be removed?", "Are you sure?", MessageBoxButtons.YesNo);

if (deleteFromDatabase == DialogResult.No)
return;

//Remove the entry from _dbManager.Databases
foreach (var entry in _dbManager.Databases[row.DatabaseName].Entries.Where(c => c.RelatedEntries != null && c.RelatedEntries.Any(b => b == row.Id)))
{
entry.RelatedEntries.Remove(row.Id);
}
var entryToRemove = _dbManager.Databases[row.DatabaseName].Entries.First(c => c.Id == row.Id);
_dbManager.Databases[row.DatabaseName].Entries.Remove(entryToRemove);
var contentDatabase = _settings.Databases.First(c => c.Name == row.DatabaseName);
var databasePath = _dbManager.GetFilesystemWorkPath(contentDatabase);
_dbManager.Databases[row.DatabaseName].LastUpdateDateUtc = DateTime.UtcNow;
_dbManager.SaveDatabaseCache<PinballDatabase>(_dbManager.Databases[row.DatabaseName], databasePath); //Save the actual database .json file

//Remove the entry from _dbManager.Entries
foreach (var entry in _dbManager.Entries.Where(c => c.RelatedEntries != null && c.RelatedEntries.Any(b => b.Id == row.Id) && c.DatabaseName == row.DatabaseName))
{
entry.RelatedEntries.RemoveWhere(c => c.Id == row.Id);
}
var entryToRemove2 = _dbManager.Entries.First(c => c.Id == row.Id && c.DatabaseName == row.DatabaseName);
_dbManager.Entries.Remove(entryToRemove2);

//Save the actual database .json

//Save the pre-processed database to the file system
//databaseToSave.LastUpdateDateUtc = DateTime.UtcNow;
_dbManager.SaveDatabaseCache<List<DatabaseBrowserEntry>>(_dbManager.Entries, _dbManager.PreprocessedDatabasePath);

RebindGridUsingFilter();
NotifyUserOfSaveWarning();
}
}
Expand Down Expand Up @@ -950,11 +970,7 @@ private void addDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
private void saveDatabasesToolStripMenuItem_Click(object sender, EventArgs e)
{
var entryForm = new SaveDatabaseForm(_settings, _dbManager);
var result = entryForm.ShowDialog(this);
//if (result == DialogResult.OK)
//{

//}
entryForm.ShowDialog(this);
}

private void dataGridViewEntryList_CurrentCellChanged(object sender, EventArgs e)
Expand Down
8 changes: 8 additions & 0 deletions PinCab.Configurator/EditDatabaseEntryForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ private bool ValidateEntry()
}
}

//Ensure the url being added isn't already in the database
if (_manager.Databases[_databaseName] != null && !string.IsNullOrEmpty(txtUrl.Text)) //Not a brand new entry in a new database
{
bool alreadyExists = _manager.Databases[_databaseName].Entries.Any(c => c.Url.ToLower() == txtUrl.Text.Trim().ToLower());
if (alreadyExists)
issues.Add("Url already exists on another entry.");
}

if (issues.Count > 0)
MessageBox.Show(string.Join("\r\n", issues), "Issues List");
return (issues.Count == 0); //True if 0 (no issues), false if >= 1 issues
Expand Down
Binary file added Screenshots/Wiki/DatabaseBrowserAddDatabase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/Wiki/DatabaseBrowserContextMenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/Wiki/DatabaseBrowserEdit1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/Wiki/DatabaseBrowserEdit2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/Wiki/DatabaseBrowserSaveDatabase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit abbabec

Please sign in to comment.