|
@@ -41,6 +41,7 @@ using PDF_Master.Model.FillAndSign;
|
|
|
using PDF_Master.Views.PropertyPanel.ViewModular;
|
|
|
using PDF_Master.Views.PropertyPanel;
|
|
|
using System.Windows.Threading;
|
|
|
+using Dropbox.Api.Files;
|
|
|
|
|
|
namespace PDF_Master.ViewModels
|
|
|
{
|
|
@@ -271,6 +272,8 @@ namespace PDF_Master.ViewModels
|
|
|
/// <summary>
|
|
|
/// 顶部提示栏的显示状态
|
|
|
/// </summary>
|
|
|
+ public bool IsFileLocked = false;
|
|
|
+
|
|
|
public Visibility TipVisible
|
|
|
{
|
|
|
get { return tipVisible; }
|
|
@@ -1164,7 +1167,11 @@ namespace PDF_Master.ViewModels
|
|
|
/// </summary>
|
|
|
private void decrypt()
|
|
|
{
|
|
|
- if (!PDFViewer.Document.IsEncrypted)
|
|
|
+ ///无可用安全性设置的原因:
|
|
|
+ ///文件本身无安全性设置,且没有设置过密码
|
|
|
+ ///文件安全性已经被重置
|
|
|
+ ///
|
|
|
+ if ((!PDFViewer.Document.IsEncrypted && !SecurityInfo.IsPasswordChanged) || (SecurityInfo.IsPasswordRemoved))
|
|
|
{
|
|
|
MessageBoxEx.Show("No security settings available ");
|
|
|
}
|
|
@@ -1175,14 +1182,24 @@ namespace PDF_Master.ViewModels
|
|
|
{
|
|
|
if (result.Password != null)
|
|
|
{
|
|
|
- string filePath = PDFViewer.Document.FilePath;
|
|
|
- PDFViewer.Document.Release();
|
|
|
- PDFViewer.InitDocument(filePath);
|
|
|
- PDFViewer.Document.UnlockWithPassword(result.Password);
|
|
|
+ PDFViewer.Document.CheckOwnerPassword(result.Password);
|
|
|
}
|
|
|
+ ShowLeftTip(false);
|
|
|
DialogParameters value = new DialogParameters();
|
|
|
value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
|
|
|
- dialogs.ShowDialog(DialogNames.DeleteSafetySettingsDialog, value, e => { });
|
|
|
+ value.Add(ParameterNames.ViewContentViewModel, this);
|
|
|
+ dialogs.ShowDialog(DialogNames.DeleteSafetySettingsDialog, value, e =>
|
|
|
+ {
|
|
|
+ if (e.Result == ButtonResult.OK)
|
|
|
+ {
|
|
|
+ if (SecurityInfo.IsPasswordRemoved)
|
|
|
+ {
|
|
|
+ PDFViewer.UndoManager.CanSave = true;
|
|
|
+ }
|
|
|
+ ShowLeftTip(false);
|
|
|
+ region.RequestNavigate(TipContentRegionName, "RemoveSecuritySuccessTip");
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1199,10 +1216,10 @@ namespace PDF_Master.ViewModels
|
|
|
{
|
|
|
if (result.Password != null)
|
|
|
{
|
|
|
- string filePath = PDFViewer.Document.FilePath;
|
|
|
- PDFViewer.Document.Release();
|
|
|
- PDFViewer.InitDocument(filePath);
|
|
|
- PDFViewer.Document.UnlockWithPassword(result.Password);
|
|
|
+ if (PDFViewer.Document.UnlockWithPassword(result.Password))
|
|
|
+ {
|
|
|
+ PDFViewer.Document.CheckOwnerPassword(result.Password);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2017,18 +2034,22 @@ namespace PDF_Master.ViewModels
|
|
|
CanSave = PDFViewer.UndoManager.CanSave;
|
|
|
CanUndo = PDFViewer.UndoManager.CanUndo;
|
|
|
CanRedo = PDFViewer.UndoManager.CanRedo;
|
|
|
- // if (passwordInfo != null && (!string.IsNullOrEmpty(passwordInfo.OpenPassword) || !string.IsNullOrEmpty(passwordInfo.PermissionsPassword)))
|
|
|
- if (passwordInfo != null && (!string.IsNullOrEmpty(passwordInfo.OpenPassword)))
|
|
|
+ if (passwordInfo != null && (!string.IsNullOrEmpty(passwordInfo.OpenPassword) || !string.IsNullOrEmpty(passwordInfo.PermissionsPassword)))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(passwordInfo.OpenPassword))
|
|
|
{
|
|
|
PDFViewer.Document.UnlockWithPassword(passwordInfo.OpenPassword);
|
|
|
}
|
|
|
- SecurityHelper.CheckHaveAllPermissions(PDFViewer.Document);
|
|
|
- //if (!string.IsNullOrEmpty(passwordInfo.PermissionsPassword))
|
|
|
- //{
|
|
|
- // PDFViewer.Document.UnlockWithPassword(passwordInfo.PermissionsPassword);
|
|
|
- //}
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(passwordInfo.PermissionsPassword)&&passwordInfo.PermissionsPassword != passwordInfo.OpenPassword)
|
|
|
+ {
|
|
|
+ IsFileLocked = true;
|
|
|
+ NavigationParameters param = new NavigationParameters();
|
|
|
+ param.Add(ParameterNames.PDFViewer, PDFViewer);
|
|
|
+ param.Add(ParameterNames.ViewContentViewModel, this);
|
|
|
+ ShowLeftTip(true);
|
|
|
+ region.RequestNavigate(LeftTipContentRegionName, "FileRestrictedTip", param);
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -2142,7 +2163,6 @@ namespace PDF_Master.ViewModels
|
|
|
/// </summary>
|
|
|
public bool saveFile()
|
|
|
{
|
|
|
- bool isFileLocked = false;
|
|
|
try
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(PDFViewer.Document.FilePath) || mainViewModel.NewFile)
|
|
@@ -2225,7 +2245,7 @@ namespace PDF_Master.ViewModels
|
|
|
if (!string.IsNullOrEmpty(permissionsPassword) && openPassword != permissionsPassword)
|
|
|
{
|
|
|
//PDFViewer.Document.CheckOwnerPassword(permissionsPassword);
|
|
|
- isFileLocked = true;
|
|
|
+ IsFileLocked = true;
|
|
|
NavigationParameters param = new NavigationParameters();
|
|
|
param.Add(ParameterNames.PDFViewer, PDFViewer);
|
|
|
param.Add(ParameterNames.ViewContentViewModel, this);
|
|
@@ -2346,7 +2366,7 @@ namespace PDF_Master.ViewModels
|
|
|
catch { return false; }
|
|
|
finally
|
|
|
{
|
|
|
- if (!isFileLocked)
|
|
|
+ if (!IsFileLocked)
|
|
|
{
|
|
|
ShowLeftTip(false);
|
|
|
}
|