HomeFilesContentViewModel.cs 2.6 KB

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