ScanPropertyPanelViewModel.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.Text;
  12. using System.Threading.Tasks;
  13. namespace PDF_Office.ViewModels.PropertyPanel.Scan
  14. {
  15. class ScanPropertyPanelViewModel : BindableBase, INavigationAware
  16. {
  17. private int pageCount;
  18. public int PageCount
  19. {
  20. get { return pageCount; }
  21. set
  22. {
  23. SetProperty(ref pageCount, value);
  24. }
  25. }
  26. private string setPageRange;
  27. public string SetPageRange
  28. {
  29. get { return setPageRange; }
  30. set
  31. {
  32. SetProperty(ref setPageRange, value);
  33. }
  34. }
  35. private CPDFViewer PDFViewer;
  36. public IEventAggregator events;
  37. public DelegateCommand OCRCommand { get; set; }
  38. public bool IsNavigationTarget(NavigationContext navigationContext)
  39. {
  40. return true;
  41. }
  42. public void OnNavigatedFrom(NavigationContext navigationContext)
  43. {
  44. return;
  45. }
  46. public void OnNavigatedTo(NavigationContext navigationContext)
  47. {
  48. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  49. if (PDFViewer == null)
  50. {
  51. return;
  52. }
  53. else
  54. {
  55. PageCount = PDFViewer.Document.PageCount;
  56. }
  57. }
  58. public ScanPropertyPanelViewModel(IEventAggregator eventAggregator)
  59. {
  60. events = eventAggregator;
  61. OCRCommand = new DelegateCommand(OCR);
  62. }
  63. private void OCR()
  64. {
  65. events.GetEvent<ScanEvent>().Publish(new ScanEventArgs()
  66. {
  67. Unicode = App.mainWindowViewModel.SelectedItem.Unicode,
  68. PageRange = SetPageRange,
  69. Mode = ScanMode.OCR,
  70. ScanLanguage= ScanLanguageMode.ChineseS
  71. }
  72. );
  73. }
  74. }
  75. }