public void updateAccounts() { accountListbox.Items.Clear(); try { List <Account> rawAccountList = new List <Account>(); foreach (List <Account> server in accounts) { foreach (Account account in server) { try { account.addAPIAccount(RiotAPI.GetAccountFromUrl <APIAccount>(account.Server, account.Name)); } catch (Exception) { account.addAPIAccount(new APIAccount()); } try { account.addAPIRank(RiotAPI.GetRankFromUrl <APIRank>(account.Server, account.Id)); } catch (Exception) { account.addAPIRank(new APIRank()); } rawAccountList.Add(account); accountListbox.Items.Add(account.Name); } } AccountSerializer.serializeAllAccounts(rawAccountList); } catch (Exception) { } }
private void AddAccountButton_Click(object sender, EventArgs e) { try { APIAccount account = RiotAPI.GetAccountFromUrl <APIAccount>(serverCombobox.Text, nameTextbox.Text); if (mainForm.accountPuuids.Contains(account.Puuid)) { MessageBox.Show("Account already added"); return; } AccountListHandler.addAccountToServer(new Account(account, null, usernameTextbox.Text, passwordTextbox.Text, serverCombobox.Text), mainForm); mainForm.accountPuuids.Add(account.Puuid); mainForm.updateAccounts(); mainForm.changeServer(serverCombobox.SelectedIndex); this.Dispose(); } catch (Exception) { MessageBox.Show("An error has occured"); } }