public static void addAccount(string player, string username, string password, string server, string name) { Account account = new Account(player, username, password, server, name); if (account.failed) { MessageBox.Show("Something went wrong"); return; } if (AccountListHandler.puuIds.Contains(account.puuId)) { MessageBox.Show("Account already added"); return; } AccountListHandler.puuIds.Add(account.puuId); if (!AccountListHandler.accounts.ContainsKey(player)) // If player not present { AccountListHandler.accounts[player] = new Dictionary <string, List <Account> >(); // Add <player, server dictionary> to dictionary } if (!AccountListHandler.accounts[player].ContainsKey(server)) // If server not present in player { AccountListHandler.accounts[player][server] = new List <Account>(); // Add empty server list<account> to player } AccountListHandler.accounts[player][server].Add(account); // Add account to server AccountListHandler.serializeAllAccounts(); }
public static string deleteAccount(Account account) { if (account != null) { string player = account.player; string server = account.server; AccountListHandler.accounts[player][server].Remove(account); if (AccountListHandler.accounts[player][server].Count == 0) { AccountListHandler.accounts[player].Remove(server); } if (AccountListHandler.accounts[player].Count == 0) { AccountListHandler.accounts.Remove(player); } AccountListHandler.serializeAllAccounts(); return(account.name); } return(null); }
private void btwUpdateAccounts_Click(object sender, RoutedEventArgs e) { AccountListHandler.updateAllAccounts(); }
private void setUp() { AccountListHandler.getAllAccounts(); AccountListHandler.updateAllAccounts(); cmbPlayer.ItemsSource = AccountListHandler.accounts.Keys; }
private void btnAddAccount_Click(object sender, RoutedEventArgs e) { AccountListHandler.addAccount(txtPlayer.Text, txtUsername.Text, txtPassword.Text, txtPassword.Text, txtName.Text); this.Close(); }