Пример #1
0
        private void LaunchButton_Click(object sender, EventArgs e)
        {
            try
            {
                GameType gameType;
                if (TicTacToeRadio.Checked)
                {
                    gameType = GameType.TicTacToe;
                }
                else if (CheckersRadio.Checked)
                {
                    //gameType = GameType.Checkers;
                    throw new GameNotImplementedException();
                }
                else if (ChessRadio.Checked)
                {
                    //gameType = GameType.Chess;
                    throw new GameNotImplementedException();
                }
                else
                {
                    throw new NoGameSelectedException();
                }

                this.Hide();
                //TODO: use factory when implementing other game types
                //var gamePage = gameFactory.create(gameType);
                var gamePage = new TicTacToePage();
                gamePage.ShowDialog();
            }
            catch (GameNotImplementedException)
            {
                MessageBox.Show("This game is not implemented yet!\nPlease select another game to play.");
            }
            catch (NoGameSelectedException)
            {
                MessageBox.Show("No game selected!\nPlease select a game to play.");
            }
            catch (CommunicationException)
            {
                MessageBox.Show("Unable to connect to server!\nPlease try again Later.");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unforseen error!, " + ex.Message);
            }
        }
Пример #2
0
        private void LaunchButton_Click(object sender, EventArgs e)
        {
            try
            {
                GameType gameType;
                if (TicTacToeRadio.Checked)
                {
                    gameType = GameType.TicTacToe;
                }
                else if (CheckersRadio.Checked)
                {
                    //gameType = GameType.Checkers;
                    throw new GameNotImplementedException();
                }
                else if (ChessRadio.Checked)
                {
                    //gameType = GameType.Chess;
                    throw new GameNotImplementedException();
                }
                else
                {
                    throw new NoGameSelectedException();
                }

                this.Hide();
                //TODO: use factory when implementing other game types
                //var gamePage = gameFactory.create(gameType);
                var gamePage = new TicTacToePage();
                gamePage.ShowDialog();

            }
            catch (GameNotImplementedException)
            {
                MessageBox.Show("This game is not implemented yet!\nPlease select another game to play.");
            }
            catch (NoGameSelectedException)
            {
                MessageBox.Show("No game selected!\nPlease select a game to play.");
            }
            catch (CommunicationException)
            {
                MessageBox.Show("Unable to connect to server!\nPlease try again Later.");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unforseen error!, " + ex.Message);
            }
        }