FileRestrictedTipViewModel.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using ComPDFKitViewer.PdfViewer;
  2. using PDF_Master.EventAggregators;
  3. using PDF_Master.Helper;
  4. using PDF_Master.Model;
  5. using Prism.Commands;
  6. using Prism.Events;
  7. using Prism.Mvvm;
  8. using Prism.Regions;
  9. using Prism.Services.Dialogs;
  10. using static PDF_Master.Model.Dialog.ToolsDialogs.SaftyDialogs.DeleteSafetySettintgsModel;
  11. namespace PDF_Master.ViewModels.TipContent
  12. {
  13. public class FileRestrictedTipViewModel : BindableBase, INavigationAware
  14. {
  15. #region 文案
  16. private string T_restrictedTitle;
  17. public string T_RestrictedTitle
  18. {
  19. get { return T_restrictedTitle; }
  20. set
  21. {
  22. SetProperty(ref T_restrictedTitle, value);
  23. }
  24. }
  25. private string T_releaseRestrictedContent;
  26. public string T_ReleaseRestrictedContent
  27. {
  28. get { return T_releaseRestrictedContent; }
  29. set
  30. {
  31. SetProperty(ref T_releaseRestrictedContent, value);
  32. }
  33. }
  34. private string T_releaseRestricted;
  35. public string T_ReleaseRestricted
  36. {
  37. get { return T_releaseRestricted; }
  38. set
  39. {
  40. SetProperty(ref T_releaseRestricted, value);
  41. }
  42. }
  43. private void IntString()
  44. {
  45. T_RestrictedTitle = App.MainPageLoader.GetString("TipContent_RestrictedTitle");
  46. T_ReleaseRestrictedContent = App.MainPageLoader.GetString("TipContent_RestrictedContent");
  47. T_ReleaseRestricted = App.MainPageLoader.GetString("TipContent_ReleaseRestricted");
  48. }
  49. #endregion
  50. public string unicode = null;
  51. public IEventAggregator eventAggregator;
  52. public IDialogService DialogService;
  53. private CPDFViewer PDFViewer;
  54. public DelegateCommand CloseTipCommand { get; set; }
  55. public DelegateCommand RestrictCommand { get; set; }
  56. public FileRestrictedTipViewModel(IEventAggregator eventAggregator, IDialogService dialogService)
  57. {
  58. IntString();
  59. this.eventAggregator = eventAggregator;
  60. this.DialogService = dialogService;
  61. unicode = App.mainWindowViewModel.SelectedItem.Unicode;
  62. CloseTipCommand = new DelegateCommand(CloseTip);
  63. RestrictCommand = new DelegateCommand(Restrict);
  64. }
  65. public void CloseTip()
  66. {
  67. this.eventAggregator.GetEvent<ShowTipEvent>().Publish(new ShowTipEventArgs() { enumTipKind = EnumTipKind.StatusNone, Unicode = unicode });
  68. }
  69. public void Restrict()
  70. {
  71. VerifyPasswordResult result = SecurityHelper.VerifyPasswordByPasswordKind(PDFViewer.Document, EnumPasswordKind.StatusPermissionsPassword, DialogService);
  72. if (result.IsDiscryptied)
  73. {
  74. if (result.Password != null)
  75. {
  76. string filePath = PDFViewer.Document.FilePath;
  77. PDFViewer.Document.CheckOwnerPassword(result.Password);
  78. }
  79. ///TODO:
  80. ///此处填入需要执行的代码
  81. this.eventAggregator.GetEvent<ShowTipEvent>().Publish(new ShowTipEventArgs() { enumTipKind = EnumTipKind.StatusNone, Unicode = unicode });
  82. }
  83. }
  84. public bool IsNavigationTarget(NavigationContext navigationContext)
  85. {
  86. return true;
  87. }
  88. public void OnNavigatedFrom(NavigationContext navigationContext)
  89. {
  90. }
  91. public void OnNavigatedTo(NavigationContext navigationContext)
  92. {
  93. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  94. }
  95. }
  96. }