|
@@ -201,45 +201,45 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
}
|
|
|
|
|
|
private void OpenSetPasswordDialog()
|
|
|
- {
|
|
|
- if (!viewContentViewModel.SecurityInfo.IsPasswordChanged)
|
|
|
+ {
|
|
|
+ VerifyPasswordResult result = SecurityHelper.VerifyPasswordByPasswordKind(PDFViewer.Document, EnumPasswordKind.StatusPermissionsPassword, dialogs);
|
|
|
+ if (result.IsDiscryptied)
|
|
|
{
|
|
|
- VerifyPasswordResult result = SecurityHelper.VerifyPasswordByPasswordKind(PDFViewer.Document, EnumPasswordKind.StatusPermissionsPassword, dialogs);
|
|
|
- if (result.IsDiscryptied)
|
|
|
- {
|
|
|
-
|
|
|
- if (result.Password != null)
|
|
|
- {
|
|
|
- string filePath = PDFViewer.Document.FilePath;
|
|
|
- PDFViewer.Document.Release();
|
|
|
- PDFViewer.InitDocument(filePath);
|
|
|
- PDFViewer.Load();
|
|
|
- PDFViewer.Document.UnlockWithPassword(result.Password);
|
|
|
- }
|
|
|
|
|
|
+ if (result.Password != null || !viewContentViewModel.SecurityInfo.IsPasswordChanged)
|
|
|
+ {
|
|
|
+ string filePath = PDFViewer.Document.FilePath;
|
|
|
+ PDFViewer.CloseDocument();
|
|
|
+ PDFViewer.InitDocument(filePath);
|
|
|
+ PDFViewer.Load();
|
|
|
+ PDFViewer.Document.UnlockWithPassword(result.Password);
|
|
|
+ }
|
|
|
|
|
|
- DialogParameters value = new DialogParameters();
|
|
|
- value.Add(ParameterNames.PDFViewer, this.PDFViewer);
|
|
|
- value.Add(ParameterNames.ViewContentViewModel, this.viewContentViewModel);
|
|
|
- dialogs.ShowDialog(DialogNames.SetPasswordDialog, value, e =>
|
|
|
+ DialogParameters value = new DialogParameters();
|
|
|
+ value.Add(ParameterNames.PDFViewer, this.PDFViewer);
|
|
|
+ value.Add(ParameterNames.ViewContentViewModel, this.viewContentViewModel);
|
|
|
+ dialogs.ShowDialog(DialogNames.SetPasswordDialog, value, e =>
|
|
|
+ {
|
|
|
+ if (e.Result == ButtonResult.OK)
|
|
|
{
|
|
|
- if (e.Result == ButtonResult.OK)
|
|
|
+ SecurityHelper.IsPasswordChanged = true;
|
|
|
+ if (viewContentViewModel.SecurityInfo.IsPasswordChanged)
|
|
|
{
|
|
|
- SecurityHelper.IsPasswordChanged = true;
|
|
|
- if (viewContentViewModel.SecurityInfo.IsPasswordChanged)
|
|
|
- {
|
|
|
- viewContentViewModel.PDFViewer.UndoManager.CanSave = true;
|
|
|
- }
|
|
|
- this.eventAggregator.GetEvent<ShowTipEvent>().Publish(new ShowTipEventArgs() { enumTipKind = EnumTipKind.StatusSetPasswordSuccessfully, Unicode = unicode });
|
|
|
+ viewContentViewModel.PDFViewer.UndoManager.CanSave = true;
|
|
|
}
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
+ this.eventAggregator.GetEvent<ShowTipEvent>().Publish(new ShowTipEventArgs() { enumTipKind = EnumTipKind.StatusSetPasswordSuccessfully, Unicode = unicode });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void OpenCancelPasswordDialog()
|
|
|
{
|
|
|
- if (!PDFViewer.Document.IsEncrypted)
|
|
|
+ ///无可用安全性设置的原因:
|
|
|
+ ///文件本身无安全性设置,且没有设置过密码
|
|
|
+ ///文件安全性已经被重置
|
|
|
+ ///
|
|
|
+ if ((!PDFViewer.Document.IsEncrypted && !viewContentViewModel.SecurityInfo.IsPasswordChanged) || (viewContentViewModel.SecurityInfo.IsPasswordRemoved))
|
|
|
{
|
|
|
MessageBoxEx.Show("No security settings available ");
|
|
|
}
|
|
@@ -257,7 +257,18 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
}
|
|
|
DialogParameters value = new DialogParameters();
|
|
|
value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
|
|
|
- dialogs.ShowDialog(DialogNames.DeleteSafetySettingsDialog, value, e => { });
|
|
|
+ value.Add(ParameterNames.ViewContentViewModel, this.viewContentViewModel);
|
|
|
+ dialogs.ShowDialog(DialogNames.DeleteSafetySettingsDialog, value, e =>
|
|
|
+ {
|
|
|
+ if (e.Result == ButtonResult.OK)
|
|
|
+ {
|
|
|
+ if (viewContentViewModel.SecurityInfo.IsPasswordRemoved)
|
|
|
+ {
|
|
|
+ viewContentViewModel.PDFViewer.UndoManager.CanSave = true;
|
|
|
+ }
|
|
|
+ this.eventAggregator.GetEvent<ShowTipEvent>().Publish(new ShowTipEventArgs() { enumTipKind = EnumTipKind.StatusRemoveSecuritySuccessfully, Unicode = unicode });
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
}
|