示例#1
0
        private void action_Click(object sender, RoutedEventArgs e)
        {
            errorMessage.Text = "";
            int gameId;

            if (actionBtn.Content.Equals("Spectate"))
            {
                DataGridCellInfo cellValue = (selectGameGrid.SelectedCells.ElementAt(1));
                gameId = Int32.Parse(((TexasHoldemGameStrings)cellValue.Item).gameId);
                var game = CommClient.spectateActiveGame(LoginWindow.user.id, gameId);
                if (game != default(TexasHoldemGame))
                {
                    Close();
                    mainMenuWindow.Show();
                    var gw = new GameWindow(game, LoginWindow.user.id, true);
                    game.Subscribe(gw);
                    gw.Show();
                }
                else
                {
                    errorMessage.Text = "Could not spectate chosen game.";
                }
            }
            else
            {
                DataGridCellInfo cellValue = (selectGameGrid.SelectedCells.ElementAt(1));
                gameId = int.Parse(((TexasHoldemGameStrings)cellValue.Item).gameId);
                var game = CommClient.GetGameInstance(gameId, LoginWindow.user.id);

                if (game != default(TexasHoldemGame))
                {
                    Close();
                    mainMenuWindow.Show();
                    var gameWindow = new GameWindow(game, LoginWindow.user.id, false);
                    game.Subscribe(gameWindow);
                    gameWindow.Show();
                }
                else
                {
                    errorMessage.Text = "Could not join chosen game.";
                }
            }
        }
        private void Join_Game_Click(object sender, RoutedEventArgs e)
        {
            errorMessage.Text = "";
            int gameId;
            DataGridCellInfo cellValue = (searchResultGrid.SelectedCells.ElementAt(1));

            gameId = Int32.Parse(((TexasHoldemGameStrings)cellValue.Item).gameId);
            var game = CommClient.GetGameInstance(gameId, LoginWindow.user.id);

            if (game != default(TexasHoldemGame))
            {
                Close();
                mainMenuWindow.Show();
                new GameWindow(game, LoginWindow.user.id, false).Show();
            }
            else
            {
                errorMessage.Text = "Could not join chosen game.";
            }
        }