using ComPDFKitViewer.PdfViewer; using PDF_Master.EventAggregators; using PDF_Master.Helper; using PDF_Master.Model; using Prism.Commands; using Prism.Events; using Prism.Mvvm; using Prism.Regions; using Prism.Services.Dialogs; using static PDF_Master.Model.Dialog.ToolsDialogs.SaftyDialogs.DeleteSafetySettintgsModel; namespace PDF_Master.ViewModels.TipContent { public class FileRestrictedTipViewModel : BindableBase, INavigationAware { public string unicode = null; public IEventAggregator eventAggregator; public IDialogService DialogService; private CPDFViewer PDFViewer; public DelegateCommand CloseTipCommand { get; set; } public DelegateCommand RestrictCommand { get; set; } public FileRestrictedTipViewModel(IEventAggregator eventAggregator, IDialogService dialogService) { this.eventAggregator = eventAggregator; this.DialogService = dialogService; unicode = App.mainWindowViewModel.SelectedItem.Unicode; CloseTipCommand = new DelegateCommand(CloseTip); RestrictCommand = new DelegateCommand(Restrict); } public void CloseTip() { this.eventAggregator.GetEvent().Publish(new ShowTipEventArgs() { enumTipKind = EnumTipKind.StatusNone, Unicode = unicode }); } public void Restrict() { VerifyPasswordResult result = SecurityHelper.VerifyPasswordByPasswordKind(PDFViewer.Document, EnumPasswordKind.StatusPermissionsPassword, DialogService); if (result.IsDiscryptied) { if (result.Password != null) { string filePath = PDFViewer.Document.FilePath; PDFViewer.Document.CheckOwnerPassword(result.Password); } ///TODO: ///此处填入需要执行的代码 this.eventAggregator.GetEvent().Publish(new ShowTipEventArgs() { enumTipKind = EnumTipKind.StatusNone, Unicode = unicode }); } } public bool IsNavigationTarget(NavigationContext navigationContext) { return true; } public void OnNavigatedFrom(NavigationContext navigationContext) { } public void OnNavigatedTo(NavigationContext navigationContext) { navigationContext.Parameters.TryGetValue(ParameterNames.PDFViewer, out PDFViewer); } } }