Exemplo n.º 1
0
        private void OnGameEdit(object sender, EventArgs e)
        {
            var form = new GameForm();

            var game = GetSelectedGame();

            if (game == null)
            {
                return;
            }

            //Game to edit
            form.Game = game;

            while (true)
            {
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                try
                {
                    //UpdateGame(game, form.Game);
                    _games.Update(game.Id, form.Game);
                    break;
                } catch (Exception ex)
                {
                    DisplayError(ex);
                };
            }
            ;

            BindList();
        }
Exemplo n.º 2
0
        private void OnGameAdd(object sender, EventArgs e)
        {
            //Display UI
            var form = new GameForm();

            while (true)
            {
                //Modal
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                //Add
                try
                {
                    //Anything in here that raises an exception will
                    //be sent to the catch block

                    OnSafeAdd(form);
                    break;
                } catch (InvalidOperationException)
                {
                    MessageBox.Show(this, "Choose a better game.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                } catch (Exception ex)
                {
                    //Recover from errors
                    DisplayError(ex);
                };
            }
            ;

            BindList();
        }
Exemplo n.º 3
0
        private void OnGameAdd(object sender, EventArgs e)
        {
            //Display UI
            var form = new GameForm();

            // Modeless Dialoge
            //form.Show();

            while (true)
            {
                // Modal dialog
                if (form.ShowDialog(this) != DialogResult.OK) // "this" represents the current instance
                {
                    return;
                }

                //Add
                try
                {
                    //Anything in here that raises an exception will
                    //be sent to the catch block

                    //_games[GetNextEmptyGame()] = form.Game;
                    // _games.Add(form.Game);
                } catch
                {
                    //Recover from errors
                    MessageBox.Show(this, "Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                };
            }
            ;

            BindList();
        }
Exemplo n.º 4
0
        private void OnGameEdit(object sender, EventArgs e)
        {
            var form = new GameForm();

            var game = GetSelectedGame();

            if (game == null)
            {
                return;
            }

            //Game to edit
            form.Game = game;

            if (form.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            //TODO: Fix to edit, not add
            UpdateGame(game, form.Game);
            BindList();
        }