|
@@ -1,5 +1,7 @@
|
|
using ComPDFKitViewer.PdfViewer;
|
|
using ComPDFKitViewer.PdfViewer;
|
|
|
|
+using PDF_Office.CustomControl;
|
|
using PDF_Office.EventAggregators;
|
|
using PDF_Office.EventAggregators;
|
|
|
|
+using PDF_Office.Helper;
|
|
using PDF_Office.Model;
|
|
using PDF_Office.Model;
|
|
using Prism.Commands;
|
|
using Prism.Commands;
|
|
using Prism.Events;
|
|
using Prism.Events;
|
|
@@ -10,10 +12,12 @@ using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
|
|
+using System.Windows;
|
|
|
|
+using static PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs.DeleteSafetySettintgsModel;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.Tools
|
|
namespace PDF_Office.ViewModels.Tools
|
|
{
|
|
{
|
|
- public class ToolsBarContentViewModel : BindableBase,INavigationAware
|
|
|
|
|
|
+ public class ToolsBarContentViewModel : BindableBase, INavigationAware
|
|
{
|
|
{
|
|
private CPDFViewer PDFViewer;
|
|
private CPDFViewer PDFViewer;
|
|
|
|
|
|
@@ -23,31 +27,23 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
|
|
|
public IEventAggregator eventAggregator;
|
|
public IEventAggregator eventAggregator;
|
|
|
|
|
|
- public string unicode = null;
|
|
|
|
|
|
+ public string unicode = null;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 是否是第一次加载
|
|
/// 是否是第一次加载
|
|
/// </summary>
|
|
/// </summary>
|
|
private bool isFirstLoad = true;
|
|
private bool isFirstLoad = true;
|
|
-
|
|
|
|
public DelegateCommand CompressCommand { get; set; }
|
|
public DelegateCommand CompressCommand { get; set; }
|
|
-
|
|
|
|
public DelegateCommand MergeCommand { get; set; }
|
|
public DelegateCommand MergeCommand { get; set; }
|
|
-
|
|
|
|
public DelegateCommand SetPasswordCommand { get; set; }
|
|
public DelegateCommand SetPasswordCommand { get; set; }
|
|
-
|
|
|
|
public DelegateCommand CancelPasswordCommand { get; set; }
|
|
public DelegateCommand CancelPasswordCommand { get; set; }
|
|
-
|
|
|
|
public DelegateCommand<object> SetEditToolsCommand { get; set; }
|
|
public DelegateCommand<object> SetEditToolsCommand { get; set; }
|
|
-
|
|
|
|
public DelegateCommand SetWatermarkCommand { get; set; }
|
|
public DelegateCommand SetWatermarkCommand { get; set; }
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
public ToolsBarContentViewModel(IDialogService dialogService, IEventAggregator eventAggregator)
|
|
public ToolsBarContentViewModel(IDialogService dialogService, IEventAggregator eventAggregator)
|
|
{
|
|
{
|
|
- dialogs= dialogService;
|
|
|
|
- this.eventAggregator= eventAggregator;
|
|
|
|
|
|
+ dialogs = dialogService;
|
|
|
|
+ this.eventAggregator = eventAggregator;
|
|
unicode = App.mainWindowViewModel.SelectedItem.Unicode;
|
|
unicode = App.mainWindowViewModel.SelectedItem.Unicode;
|
|
CompressCommand = new DelegateCommand(OpenCompressDialog);
|
|
CompressCommand = new DelegateCommand(OpenCompressDialog);
|
|
MergeCommand = new DelegateCommand(MergeDialog);
|
|
MergeCommand = new DelegateCommand(MergeDialog);
|
|
@@ -61,7 +57,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
var args = e as System.Windows.Controls.Button;
|
|
var args = e as System.Windows.Controls.Button;
|
|
if (args != null)
|
|
if (args != null)
|
|
{
|
|
{
|
|
- this.eventAggregator.GetEvent<EnterSelectedEditToolEvent>().Publish(new StringWithUnicode() { Unicode=unicode,EditToolsContentName=args.Name}) ;
|
|
|
|
|
|
+ this.eventAggregator.GetEvent<EnterSelectedEditToolEvent>().Publish(new StringWithUnicode() { Unicode = unicode, EditToolsContentName = args.Name });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -70,27 +66,40 @@ namespace PDF_Office.ViewModels.Tools
|
|
{
|
|
{
|
|
DialogParameters value = new DialogParameters();
|
|
DialogParameters value = new DialogParameters();
|
|
value.Add(ParameterNames.PDFViewer, PDFViewer);
|
|
value.Add(ParameterNames.PDFViewer, PDFViewer);
|
|
- dialogs.ShowDialog(DialogNames.CompressDialog, value, e => { });
|
|
|
|
|
|
+ dialogs.ShowDialog(DialogNames.CompressDialog, value, e => { });
|
|
}
|
|
}
|
|
private void MergeDialog()
|
|
private void MergeDialog()
|
|
{
|
|
{
|
|
DialogParameters value = new DialogParameters();
|
|
DialogParameters value = new DialogParameters();
|
|
value.Add(ParameterNames.PDFViewer, PDFViewer);
|
|
value.Add(ParameterNames.PDFViewer, PDFViewer);
|
|
- dialogs.ShowDialog(DialogNames.MergeDialog, value, e => { });
|
|
|
|
|
|
+ dialogs.ShowDialog(DialogNames.MergeDialog, value, e => { });
|
|
}
|
|
}
|
|
|
|
|
|
private void OpenSetPasswordDialog()
|
|
private void OpenSetPasswordDialog()
|
|
{
|
|
{
|
|
- DialogParameters value = new DialogParameters();
|
|
|
|
- value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
|
|
|
|
- dialogs.ShowDialog(DialogNames.SetPasswordDialog, value, e => { });
|
|
|
|
|
|
+ if (SecurityHelper.VerifyPassword(PDFViewer.Document, EnumPasswordKind.StatusPermissionsPassword, dialogs))
|
|
|
|
+ {
|
|
|
|
+ DialogParameters value = new DialogParameters();
|
|
|
|
+ value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
|
|
|
|
+ dialogs.ShowDialog(DialogNames.SetPasswordDialog, value, e => { });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private void OpenCancelPasswordDialog()
|
|
private void OpenCancelPasswordDialog()
|
|
{
|
|
{
|
|
- DialogParameters value = new DialogParameters();
|
|
|
|
- value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
|
|
|
|
- dialogs.ShowDialog(DialogNames.DeleteSafetySettingsDialog, value, e => { });
|
|
|
|
|
|
+ if (!PDFViewer.Document.IsEncrypted)
|
|
|
|
+ {
|
|
|
|
+ MessageBoxEx.Show("No security settings available ");
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (SecurityHelper.VerifyPassword(PDFViewer.Document, EnumPasswordKind.StatusPermissionsPassword, dialogs))
|
|
|
|
+ {
|
|
|
|
+ DialogParameters value = new DialogParameters();
|
|
|
|
+ value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
|
|
|
|
+ dialogs.ShowDialog(DialogNames.DeleteSafetySettingsDialog, value, e => { });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
public bool IsNavigationTarget(NavigationContext navigationContext)
|
|
public bool IsNavigationTarget(NavigationContext navigationContext)
|