Пример #1
0
        private void btnJoin_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 1)
            {
                int index = dataGridView1.SelectedRows[0].Index;

                UDPClientServerCommons.Packets.GameInfoPacket gameInfoPacket = gameInfoPackets[index];

                ChooseTeamForm chooseTeam = new ChooseTeamForm(gameInfoPacket);
                if (chooseTeam.ShowDialog(this) == DialogResult.OK)
                {
                    bool result = clientSideNetworking.JoinGame(gameInfoPacket.ServerAddress, chooseTeam.PlayerName, gameInfoPacket.GameId, chooseTeam.TeamId.Value);
                    if (result)
                    {
                        gamePlayForm = new GameplayForm(clientSideNetworking);
                        gamePlayForm.Show();
                    }
                }
            }
        }
Пример #2
0
        private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (gameInfoPackets.Count > 0)
            {
                UDPClientServerCommons.Packets.GameInfoPacket gameInfoPacket = gameInfoPackets[e.RowIndex];

                ChooseTeamForm chooseTeam = new ChooseTeamForm(gameInfoPacket);
                if (chooseTeam.ShowDialog(this) == DialogResult.OK)
                {
                    clientSideNetworking.JoinGame(gameInfoPacket.ServerAddress, chooseTeam.PlayerName, gameInfoPacket.GameId, chooseTeam.TeamId.Value);
                }
            }
        }