123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 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
- {
- #region 文案
- private string T_restrictedTitle;
- public string T_RestrictedTitle
- {
- get { return T_restrictedTitle; }
- set
- {
- SetProperty(ref T_restrictedTitle, value);
- }
- }
- private string T_releaseRestrictedContent;
- public string T_ReleaseRestrictedContent
- {
- get { return T_releaseRestrictedContent; }
- set
- {
- SetProperty(ref T_releaseRestrictedContent, value);
- }
- }
- private string T_releaseRestricted;
- public string T_ReleaseRestricted
- {
- get { return T_releaseRestricted; }
- set
- {
- SetProperty(ref T_releaseRestricted, value);
- }
- }
- private void IntString()
- {
- T_RestrictedTitle = App.MainPageLoader.GetString("TipContent_RestrictedTitle");
- T_ReleaseRestrictedContent = App.MainPageLoader.GetString("TipContent_RestrictedContent");
- T_ReleaseRestricted = App.MainPageLoader.GetString("TipContent_ReleaseRestricted");
- }
- #endregion
- 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)
- {
- IntString();
- 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<ShowTipEvent>().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<ShowTipEvent>().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<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
- }
- }
- }
|