public LaunchWindowViewModel() { Accounts = new ObservableCollection<LoginModel>(); Messages = new ObservableCollection<string>(); NewAccount = new LoginModel(); StartQueuedLoginsCommand = new DelegateCommand(StartQueuedLoginsAction); ReloadAccountsListCommand = new DelegateCommand(ReloadAccountsListAction); AddAccountCommand = new DelegateCommand(AddAccountAction); ClearAccountCommand = new DelegateCommand(ClearAccountAction); DeleteAccountCommand = new DelegateCommand(DeleteAccountAction); ReloadAccountsListAction(); }
private void ClearAccountAction() { NewAccount = new LoginModel(); }
private async void AddAccountAction() { string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Launch++"); string js = await Task.Factory.StartNew(() => JsonConvert.SerializeObject(NewAccount)); using (FileStream fs = new FileStream(Path.Combine(path, $"{NewAccount.Username}.json"), FileMode.Create, FileAccess.Write)) using (StreamWriter sw = new StreamWriter(fs)) { await sw.WriteAsync(js); } NewAccount = new LoginModel(); ReloadAccountsListAction(); }