public NewPasswordViewModel(NewPasswordView view, PasswordEntry entry = null) { _ExistingEntry = entry != null; _View = view; _Model = entry ?? new PasswordEntry(); _OKCommand = new DelegateCommand(OnOk, DataCompleted); }
private void ModifyPassword() { if (_SelectedPasswordIndex == -1) { MessageBox.Show(_View, "No selected password", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } PasswordEntry entry = _Passwords[_SelectedPasswordIndex]; NewPasswordView passwordView = new NewPasswordView(entry) { Owner = _View }; try { if (passwordView.ShowDialog() == true) { entry.Save(); MessageBox.Show(_View, "Modified password successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show(_View, "Modification Cancelled", "Cancelled", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } catch { MessageBox.Show(_View, "Problem modifying the password", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public NewPasswordView(PasswordEntry entry = null) { _ViewModel = new NewPasswordViewModel(this, entry); DataContext = _ViewModel; InitializeComponent(); _PasswordBox.Password = _ViewModel.Model.Password; }
public override bool Equals(object obj) { if (obj is PasswordEntry) { PasswordEntry other = (PasswordEntry)obj; return(Name == other.Name); } return(base.Equals(obj)); }
private void ShowSelectedPasswordPermanently() { if (_SelectedPasswordIndex == -1) { MessageBox.Show(_View, "No selected password", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } PasswordEntry entry = _Passwords[_SelectedPasswordIndex]; }
private void CopyPassword() { if (_SelectedPasswordIndex == -1) { MessageBox.Show(_View, "No selected password", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } PasswordEntry entry = _Passwords[_SelectedPasswordIndex]; System.Windows.Clipboard.SetText(entry.Password); }
public static PasswordEntry Load(string filename) { PasswordEntry entry = null; using (StreamReader reader = new StreamReader(File.OpenRead(filename))) { string json = reader.ReadToEnd(); entry = JsonConvert.DeserializeObject <PasswordEntry>(json); } entry.Dirty = false; return(entry); }
private void ShowVerboseInfo() { if (_SelectedPasswordIndex == -1) { MessageBox.Show(_View, "No selected password", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } PasswordEntry entry = _Passwords[_SelectedPasswordIndex]; VerboseView view = new VerboseView(entry); view.ShowDialog(); }
private void DeletePassword() { if (_SelectedPasswordIndex == -1) { MessageBox.Show(_View, "No selected password", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } PasswordEntry entry = _Passwords[_SelectedPasswordIndex]; entry.Delete(); _Passwords.RemoveAt(_SelectedPasswordIndex); }
public void AddEntry(PasswordEntry entry) { int index = _Passwords.IndexOf(entry); if (index != -1) { _Passwords[index] = entry; } else { _Passwords.Add(entry); } }
private void AddPassword(PasswordEntry entry) { var result = _MainViewModel.AddNewPassword(entry); if (result) { entry.Save(); MessageBox.Show(_View, "Added password successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show(_View, "Problem adding password", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private async Task ProcessRemoteFileList() { await ForEachAsync(_Files, async delegate(IpfsFile file) { string filename = Path.Combine(FileSystemConstants.PswmgrDataFolder, Path.ChangeExtension(file.LocalFilename, ".json")); if (File.Exists(filename)) { ResolveConflict(file.LocalFilename, filename); } else { await IpfsApiWrapper.Get(file.RemoteFilename, filename); PasswordEntryManager.Instance.AddEntry(PasswordEntry.Load(filename)); } }); }
public async void LoadPasswords() { _Passwords.Clear(); Directory.CreateDirectory(FileSystemConstants.PswmgrDataFolder); var files = Directory.GetFiles(FileSystemConstants.PswmgrDataFolder, "*.json"); await Task.Run(delegate { Parallel.ForEach(files, delegate(string file) { var val = PasswordEntry.Load(file); ExceptionUtilities.TryCatchIgnore(() => App.Instance.Dispatcher.Invoke(() => _Passwords.Add(val))); }); }); OnFinishedLoading(); }
public VerboseViewModel(VerboseView view, PasswordEntry entry) { _View = view; _Model = entry; }
internal bool AddNewPassword(PasswordEntry newPassword) { _Model.AddEntry(newPassword); return(true); }
internal UnsecurePasswordEntry(PasswordEntry entry) { Username = entry.Username; Password = entry.Password; Website = entry.Website; }