public bool SaveDocument(Window owner) { if (File == null) return SaveDocumentAs(owner); try { while (Password == null || Password.Length == 0) { var dialog = new ChangePasswordDialog(); if (dialog.ShowDialog(owner, false)) { Password = dialog.Password; } } EncryptionFileIO.SaveFile(File, Content, Hint, Password, Algorithm); fileContent = Content; filePassword = Password; fileHint = Hint; fileAlgorithm = Algorithm; RaisePropertyChanged(nameof(IsChanged)); RaisePropertyChanged(nameof(WindowTitle)); } catch (Exception e) { MessageBox.Show("Error saving file", "Write error", MessageBoxButton.OK, MessageBoxImage.Error); MessageBox.Show(e.ToString(), "Write error", MessageBoxButton.OK, MessageBoxImage.Error); return false; } return true; }
public void ChangePassword(Window owner) { var dialog = new ChangePasswordDialog(); if (dialog.ShowDialog(owner)) { Document.Password = dialog.Password; } }