Exemple #1
0
        private async void refreshLists()
        {
            NetworkClient client           = new NetworkClient(_settings);
            var           loggedInUserList = await client.GetListLoggedInUserAsync();

            LoggedInUser selLoggedInUser = loggedInPlayersLb.SelectedItem as LoggedInUser;

            loggedInPlayersLb.Items.Clear();
            foreach (LoggedInUser loggedInUser in loggedInUserList)
            {
                loggedInPlayersLb.Items.Add(loggedInUser);
            }
            if (selLoggedInUser != null && loggedInPlayersLb.Items.Contains(selLoggedInUser))
            {
                loggedInPlayersLb.SelectedItem = selLoggedInUser;
            }
            var availableGameList = await client.GetListAvailableGameAsync();

            AvailableGame selAvailableGame = currentGamesLb.SelectedItem as AvailableGame;

            currentGamesLb.Items.Clear();
            foreach (AvailableGame availableGame in availableGameList)
            {
                currentGamesLb.Items.Add(availableGame);
            }
            if (selAvailableGame != null && currentGamesLb.Items.Contains(selAvailableGame))
            {
                currentGamesLb.SelectedItem = selAvailableGame;
            }
            connectionFailedLbl.Visible = client.ConnectionFailing;
        }
Exemple #2
0
        private void joinGameBtn_Click(object sender, EventArgs e)
        {
            if (_currentLoginSession == null)
            {
                MessageBox.Show(this, "Du måste först logga in!");
                return;
            }
            AvailableGame selGame = currentGamesLb.SelectedItem as AvailableGame;

            if (selGame == null)
            {
                MessageBox.Show(this, "Du måste välja ett spel att gå med i!");
                return;
            }
            string pinCode = "";

            if ((selGame).UsePincode)
            {
                EnterPincodeForm enterPincode   = new EnterPincodeForm();
                DialogResult     settingsResult = enterPincode.ShowDialog(this);
                if (settingsResult != DialogResult.OK)
                {
                    return;
                }
                pinCode = enterPincode.getPincode();
            }
            NetworkClient client = new NetworkClient(_settings);

            if (!client.JoinGame(selGame.Gamename, pinCode, _currentLoginSession.SessionToken))
            {
                MessageBox.Show(this, "Det gick inte att gå med i spelet!");
            }
            else
            {
                refreshLists();
            }
        }