ToolsBarContentViewModel.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using ComPDFKitViewer.PdfViewer;
  2. using PDF_Office.EventAggregators;
  3. using PDF_Office.Model;
  4. using Prism.Commands;
  5. using Prism.Events;
  6. using Prism.Mvvm;
  7. using Prism.Regions;
  8. using Prism.Services.Dialogs;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Security.Cryptography.X509Certificates;
  13. namespace PDF_Office.ViewModels.Tools
  14. {
  15. public class ToolsBarContentViewModel : BindableBase,INavigationAware
  16. {
  17. private CPDFViewer PDFViewer;
  18. private ViewContentViewModel viewContentViewModel;
  19. public IDialogService dialogs;
  20. public IEventAggregator eventAggregator;
  21. /// <summary>
  22. /// 是否是第一次加载
  23. /// </summary>
  24. private bool isFirstLoad = true;
  25. public DelegateCommand CompressCommand { get; set; }
  26. public DelegateCommand SetPasswordCommand { get; set; }
  27. public DelegateCommand CancelPasswordCommand { get; set; }
  28. public DelegateCommand<object> SetEditToolsCommand { get; set; }
  29. public DelegateCommand SetWatermarkCommand { get; set; }
  30. public DelegateCommand<object> SetEditToolsCommand { get; set; }
  31. public ToolsBarContentViewModel(IDialogService dialogService, IEventAggregator eventAggregator)
  32. {
  33. dialogs= dialogService;
  34. this.eventAggregator= eventAggregator;
  35. CompressCommand = new DelegateCommand(OpenCompressDialog);
  36. SetPasswordCommand = new DelegateCommand(OpenSetPasswordDialog);
  37. CancelPasswordCommand = new DelegateCommand(OpenCancelPasswordDialog);
  38. SetEditToolsCommand = new DelegateCommand<object>(SetEditTools);
  39. }
  40. private void SetEditTools(object e)
  41. {
  42. var args = e as System.Windows.Controls.Button;
  43. if (args != null)
  44. {
  45. <<<<<<< Updated upstream
  46. this.eventAggregator.GetEvent<EditToolsEvent>().Publish(args.Name);
  47. =======
  48. this.eventAggregator.GetEvent<EnterSelectedEditToolEvent>().Publish(args.Name);
  49. >>>>>>> Stashed changes
  50. }
  51. }
  52. private void OpenCompressDialog()
  53. {
  54. DialogParameters value = new DialogParameters();
  55. value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
  56. dialogs.ShowDialog(DialogNames.CompressDialog, value, e => { });
  57. }
  58. private void OpenSetPasswordDialog()
  59. {
  60. DialogParameters value = new DialogParameters();
  61. value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
  62. dialogs.ShowDialog(DialogNames.SetPasswordDialog, value, e => { });
  63. }
  64. private void OpenCancelPasswordDialog()
  65. {
  66. DialogParameters value = new DialogParameters();
  67. value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
  68. dialogs.ShowDialog(DialogNames.DeleteSafetySettingsDialog, value, e => { });
  69. }
  70. public bool IsNavigationTarget(NavigationContext navigationContext)
  71. {
  72. return true;
  73. }
  74. public void OnNavigatedFrom(NavigationContext navigationContext)
  75. {
  76. }
  77. public void OnNavigatedTo(NavigationContext navigationContext)
  78. {
  79. navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
  80. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  81. if (PDFViewer != null)
  82. {
  83. isFirstLoad = false;
  84. }
  85. }
  86. }
  87. }