コード例 #1
0
        private void viewDetailsButton_Click(object sender, EventArgs e)
        {
            if (gamesList.SelectedRows.Count > 0)
            {
                ViewGameDetailsForm vgdf = new ViewGameDetailsForm();

                int gameId = (int)gamesList.SelectedRows[0].Cells[0].Value;

                List <CustomGame> games = DataApiController <List <CustomGame> > .GetData(ChessUtils.IPAddressWithPort + "GetCustomGamesForUser/" + me.Username);

                CustomGame game = games.Single(x => x.GameID == gameId);
                if (game != null)
                {
                    vgdf.SetGameTime(ChessUtils.ConvertSecondsToTimeString(game.GameTimer));
                    vgdf.SetTurnTime(ChessUtils.ConvertSecondsToTimeString(game.MoveTimer));
                    vgdf.SetOpponentName(me.Username);
                    vgdf.SetToMove(game.WhiteMovesFirst ? "White" : "Black");
                    vgdf.SetBoard(game.Pieces);
                    vgdf.Show();
                }
            }
        }
コード例 #2
0
        private void details_Click(object sender, EventArgs e)
        {
            if (lobbyTable.SelectedRows.Count > 0)
            {
                ViewGameDetailsForm vgdf = new ViewGameDetailsForm();

                bool isCustomGame = (bool)lobbyTable.SelectedRows[0].Cells[1].Value;
                if (isCustomGame)
                {
                    string hostUsername = (string)lobbyTable.SelectedRows[0].Cells[2].Value;
                    int    gameId       = (int)lobbyTable.SelectedRows[0].Cells[5].Value;

                    List <CustomGame> games = DataApiController <List <CustomGame> > .GetData(ChessUtils.IPAddressWithPort + "GetCustomGamesForUser/" + hostUsername);

                    CustomGame game = games.Single(x => x.GameID == gameId);
                    if (game != null)
                    {
                        vgdf.SetGameTime(ChessUtils.ConvertSecondsToTimeString(game.GameTimer));
                        vgdf.SetTurnTime(ChessUtils.ConvertSecondsToTimeString(game.MoveTimer));
                        vgdf.SetOpponentName(hostUsername);
                        vgdf.SetToMove(game.WhiteMovesFirst ? "White" : "Black");
                        vgdf.SetBoard(game.Pieces);
                        vgdf.Show();
                    }
                }
                else
                {
                    string gameTime = (string)lobbyTable.SelectedRows[0].Cells[4].Value;
                    string turnTime = (string)lobbyTable.SelectedRows[0].Cells[3].Value;
                    string host     = (string)lobbyTable.SelectedRows[0].Cells[2].Value;
                    vgdf.SetGameTime(gameTime);
                    vgdf.SetTurnTime(turnTime);
                    vgdf.SetOpponentName(host);
                    vgdf.SetToMove("White");
                    vgdf.Show();
                }
            }
        }