Exemplo n.º 1
0
        /// <summary>
        ///     Shows a dialog allowing the user to add a new entry to the database.
        /// </summary>
        private void AddNewGame()
        {
            GameDBEntryDialog dlg = new GameDBEntryDialog();

            if ((dlg.ShowDialog() == DialogResult.OK) && (dlg.Game != null))
            {
                if (Program.GameDB.Games.ContainsKey(dlg.Game.Id))
                {
                    MessageBox.Show(GlobalStrings.DBEditDlg_GameIdAlreadyExists, GlobalStrings.Gen_Warning,
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_FailedToAddGame, dlg.Game.Id));
                }
                else
                {
                    Program.GameDB.Games.Add(dlg.Game.Id, dlg.Game);

                    if (ShouldDisplayGame(dlg.Game))
                    {
                        displayedGames.Add(dlg.Game);
                        lstGames.VirtualListSize += 1;
                        displayedGames.Sort(dbEntrySorter);
                        InvalidateAllListViewItems();
                    }

                    AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_AddedGame, dlg.Game.Id));
                    UnsavedChanges = true;
                    UpdateStatusCount();
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 ///     Shows a dialog allowing the user to modify the entry for the first selected game.
 /// </summary>
 private void EditSelectedGame()
 {
     if (lstGames.SelectedIndices.Count > 0)
     {
         GameDBEntry game = displayedGames[lstGames.SelectedIndices[0]];
         if (game != null)
         {
             GameDBEntryDialog dlg = new GameDBEntryDialog(game);
             DialogResult      res = dlg.ShowDialog();
             if (res == DialogResult.OK)
             {
                 lstGames.RedrawItems(lstGames.SelectedIndices[0], lstGames.SelectedIndices[0], true);
                 AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_EditedGame, game.Id));
                 UnsavedChanges = true;
             }
         }
     }
 }