RedactionContentViewModel.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Windows;
  12. namespace PDF_Office.ViewModels.EditTools.Redaction
  13. {
  14. public class RedactionContentViewModel : BindableBase,INavigationAware
  15. {
  16. public IEventAggregator eventAggregator;
  17. public IRegionManager redactionRegion;
  18. private CPDFViewer PDFViewer;
  19. public string RedactionDocumentRegionName { get; set; }
  20. public string RedactionBottomBarRegionName { get; set; }
  21. public string RedactionDocumentName = "RedactionDocumentContent";
  22. public string Unicode = null;
  23. public DelegateCommand CloseEditToolCommand { get; set; }
  24. public RedactionContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
  25. {
  26. this.redactionRegion = regionManager;
  27. this.eventAggregator = eventAggregator;
  28. RedactionDocumentRegionName = Guid.NewGuid().ToString();
  29. Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
  30. CloseEditToolCommand = new DelegateCommand(CloseEditTool);
  31. }
  32. public void CloseEditTool()
  33. {
  34. this.eventAggregator.GetEvent<CloseEditToolEvent>().Publish(new EnumCloseModeUnicode { Unicode = this.Unicode, Status = EnumCloseMode.StatusCancel });
  35. }
  36. public bool IsNavigationTarget(NavigationContext navigationContext)
  37. {
  38. return true;
  39. }
  40. public void OnNavigatedFrom(NavigationContext navigationContext)
  41. {
  42. }
  43. public void OnNavigatedTo(NavigationContext navigationContext)
  44. {
  45. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  46. NavigationParameters param = new NavigationParameters();
  47. param.Add(ParameterNames.PDFViewer, PDFViewer);
  48. redactionRegion.RequestNavigate(RedactionDocumentRegionName, RedactionDocumentName, param);
  49. }
  50. }
  51. }