Inheritance: System.Windows.Forms.Form
        /// <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.Database.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.Database.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();
                }
            }
        }
Exemple #2
0
        /// <summary>
        ///     Shows a dialog allowing the user to add a new entry to the database.
        /// </summary>
        private void AddNewGame()
        {
            using (GameDBEntryDialog dlg = new GameDBEntryDialog())
            {
                if (dlg.ShowDialog() != DialogResult.OK || dlg.Game == null)
                {
                    return;
                }

                if (Database.Contains(dlg.Game.Id))
                {
                    MessageBox.Show(GlobalStrings.DBEditDlg_GameIdAlreadyExists, GlobalStrings.Gen_Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    AddStatusMsg(string.Format(CultureInfo.CurrentCulture, GlobalStrings.DBEditDlg_FailedToAddGame, dlg.Game.Id));
                }
                else
                {
                    Database.Add(dlg.Game);

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

                    AddStatusMsg(string.Format(CultureInfo.CurrentCulture, GlobalStrings.DBEditDlg_AddedGame, dlg.Game.Id));
                    UnsavedChanges = true;
                    UpdateStatusCount();
                }
            }
        }
Exemple #3
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)
            {
                return;
            }

            DatabaseEntry game = displayedGames[lstGames.SelectedIndices[0]];

            if (game == null)
            {
                return;
            }

            using (GameDBEntryDialog dialog = new GameDBEntryDialog(game))
            {
                DialogResult result = dialog.ShowDialog();
                if (result != DialogResult.OK)
                {
                    return;
                }

                lstGames.RedrawItems(lstGames.SelectedIndices[0], lstGames.SelectedIndices[0], true);
                AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_EditedGame, game.Id));
                UnsavedChanges = true;
            }
        }
 void AddNewGame()
 {
     GameDBEntryDialog dlg = new GameDBEntryDialog();
     if( dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK && dlg.Game != null ) {
         if( Program.GameDB.Games.ContainsKey( dlg.Game.Id ) ) {
             MessageBox.Show(GlobalStrings.DBEditDlg_GameIdAlreadyExists, GlobalStrings.DBEditDlg_Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_FailedToAddGame, dlg.Game.Id));
         } else {
             Program.GameDB.Games.Add( dlg.Game.Id, dlg.Game );
             AddGameToList( dlg.Game );
             AddStatusMsg( string.Format(GlobalStrings.DBEditDlg_AddedGame, dlg.Game.Id ) );
             UnsavedChanges = true;
             UpdateForSelectChange();
         }
     }
 }
 /// <summary>
 /// Shows a dialog allowing the user to modify the entry for the first selected game.
 /// </summary>
 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 == System.Windows.Forms.DialogResult.OK)
             {
                 lstGames.RedrawItems(lstGames.SelectedIndices[0], lstGames.SelectedIndices[0], true);
                 AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_EditedGame, game.Id));
                 UnsavedChanges = true;
             }
         }
     }
 }
Exemple #6
0
 void EditSelectedGame()
 {
     if (lstGames.SelectedIndices.Count > 0)
     {
         GameDBEntry game = lstGames.SelectedItems[0].Tag as GameDBEntry;
         if (game != null)
         {
             GameDBEntryDialog dlg = new GameDBEntryDialog(game);
             DialogResult      res = dlg.ShowDialog();
             if (res == System.Windows.Forms.DialogResult.OK)
             {
                 UpdateGameAtIndex(lstGames.SelectedIndices[0]);
                 AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_EditedGame, game.Id));
                 UnsavedChanges = true;
             }
         }
     }
 }
Exemple #7
0
        void AddNewGame()
        {
            GameDBEntryDialog dlg = new GameDBEntryDialog();

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK && dlg.Game != null)
            {
                if (Program.GameDB.Games.ContainsKey(dlg.Game.Id))
                {
                    MessageBox.Show(GlobalStrings.DBEditDlg_GameIdAlreadyExists, GlobalStrings.DBEditDlg_Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_FailedToAddGame, dlg.Game.Id));
                }
                else
                {
                    Program.GameDB.Games.Add(dlg.Game.Id, dlg.Game);
                    AddGameToList(dlg.Game);
                    AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_AddedGame, dlg.Game.Id));
                    UnsavedChanges = true;
                    UpdateForSelectChange();
                }
            }
        }
 void EditSelectedGame()
 {
     if( lstGames.SelectedIndices.Count > 0 ) {
         GameDBEntry game = lstGames.SelectedItems[0].Tag as GameDBEntry;
         if( game != null ) {
             GameDBEntryDialog dlg = new GameDBEntryDialog( game );
             DialogResult res = dlg.ShowDialog();
             if( res == System.Windows.Forms.DialogResult.OK ) {
                 UpdateGameAtIndex( lstGames.SelectedIndices[0] );
                 AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_EditedGame, game.Id));
                 UnsavedChanges = true;
             }
         }
     }
 }
 /// <summary>
 /// Shows a dialog allowing the user to modify the entry for the first selected game.
 /// </summary>
 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 == System.Windows.Forms.DialogResult.OK ) {
                 lstGames.RedrawItems( lstGames.SelectedIndices[0], lstGames.SelectedIndices[0], true );
                 AddStatusMsg( string.Format( GlobalStrings.DBEditDlg_EditedGame, game.Id ) );
                 UnsavedChanges = true;
             }
         }
     }
 }
        /// <summary>
        /// Shows a dialog allowing the user to add a new entry to the database.
        /// </summary>
        void AddNewGame() {
            GameDBEntryDialog dlg = new GameDBEntryDialog();
            if( dlg.ShowDialog() == System.Windows.Forms.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();
                }
            }
        }