HomeFilesContentViewModel.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using Microsoft.Office.Interop.Word;
  2. using Microsoft.Win32;
  3. using PDF_Master.Helper;
  4. using PDF_Master.Model;
  5. using Prism.Commands;
  6. using Prism.Mvvm;
  7. using Prism.Regions;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. namespace PDF_Master.ViewModels.HomePanel.PDFTools
  12. {
  13. public class HomeFilesContentViewModel : BindableBase, INavigationAware
  14. {
  15. HomeContentViewModel homeContentViewModel = null;
  16. private int creatGridRowIndex = 0;
  17. public int CreatGridRowIndex
  18. {
  19. get { return creatGridRowIndex; }
  20. set
  21. {
  22. SetProperty(ref creatGridRowIndex, value);
  23. }
  24. }
  25. private int creatGridColumnIndex = 1;
  26. public int CreatGridColumnIndex
  27. {
  28. get { return creatGridColumnIndex; }
  29. set
  30. {
  31. SetProperty(ref creatGridColumnIndex, value);
  32. }
  33. }
  34. public DelegateCommand OpenFileCommand { get; set; }
  35. public DelegateCommand CreateBlackPDFCommand { get; set; }
  36. public DelegateCommand CreateFromOtherFile { get; set; }
  37. public DelegateCommand<string> CreateFromScanner { get; set; }
  38. public HomeFilesContentViewModel()
  39. {
  40. OpenFileCommand = new DelegateCommand(OpenFile);
  41. CreateBlackPDFCommand = new DelegateCommand(CreatBlankPDF);
  42. CreateFromOtherFile = new DelegateCommand(createFromOtherFile);
  43. CreateFromScanner = new DelegateCommand<string>(createFromScanner);
  44. }
  45. /// <summary>
  46. /// 从扫描仪创建
  47. /// </summary>
  48. private async void createFromScanner(string args)
  49. {
  50. if (homeContentViewModel != null)
  51. {
  52. homeContentViewModel.createFromScanner("");
  53. }
  54. }
  55. /// <summary>
  56. /// 打开文件
  57. /// </summary>
  58. public async void OpenFile()
  59. {
  60. if (homeContentViewModel != null)
  61. {
  62. homeContentViewModel.OpenFile();
  63. }
  64. }
  65. /// <summary>
  66. /// 创建空白文档
  67. /// </summary>
  68. public void CreatBlankPDF()
  69. {
  70. if (homeContentViewModel != null)
  71. {
  72. homeContentViewModel.CreatBlankPDF();
  73. }
  74. }
  75. /// <summary>
  76. /// 从其他格式文件创建PDF
  77. /// </summary>
  78. private async void createFromOtherFile()
  79. {
  80. if (homeContentViewModel != null)
  81. {
  82. homeContentViewModel.createFromOtherFile();
  83. }
  84. }
  85. public void OnNavigatedTo(NavigationContext navigationContext)
  86. {
  87. navigationContext.Parameters.TryGetValue<HomeContentViewModel>(ParameterNames.HomeContentViewModel, out homeContentViewModel);
  88. }
  89. public bool IsNavigationTarget(NavigationContext navigationContext)
  90. {
  91. return true;
  92. }
  93. public void OnNavigatedFrom(NavigationContext navigationContext)
  94. {
  95. }
  96. }
  97. }