public UsersForm(ApplicationContext appContext) { _applicationContext = appContext; InitializeComponent(); LoadLocalization(); _userManager = File.Exists(_applicationContext.McLauncher + "users.json") ? JsonConvert.DeserializeObject<UserManager>(File.ReadAllText(_applicationContext.McLauncher + "users.json")) : new UserManager(); UpdateUsers(); }
private void UpdateUserList() { NicknameDropDownList.Items.Clear(); try { _userManager = File.Exists(_applicationContext.McLauncher + "users.json") ? JsonConvert.DeserializeObject<UserManager>(File.ReadAllText(_applicationContext.McLauncher + "users.json")) : new UserManager(); } catch (Exception ex) { AppendException("Reading user list: an exception has occurred\n" + ex.Message); _userManager = new UserManager(); SaveUsers(); } NicknameDropDownList.Items.AddRange(_userManager.Accounts.Keys); NicknameDropDownList.SelectedItem = NicknameDropDownList.FindItemExact(_userManager.SelectedUsername, true); }