Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        public void ChangePassword(Window owner)
        {
            var dialog = new ChangePasswordDialog();

            if (dialog.ShowDialog(owner))
            {
                Document.Password = dialog.Password;
            }
        }