HomePageBatchProcessingDialogViewModel.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using ComPDFKitViewer.PdfViewer;
  2. using Microsoft.Office.Interop.Word;
  3. using PDF_Office.Model;
  4. using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
  5. using Prism.Commands;
  6. using Prism.Mvvm;
  7. using Prism.Regions;
  8. using Prism.Services.Dialogs;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Windows;
  14. using System.Windows.Controls;
  15. namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
  16. {
  17. public class HomePageBatchProcessingDialogViewModel : BindableBase, IDialogAware, INavigationAware
  18. {
  19. #region 参数和属性
  20. private List<string> fileNames;
  21. public IRegionManager BatchProcessingRegion;
  22. int convertertypeindex = 0;
  23. private string batchProcessingRegionName;
  24. public string BatchProcessingRegionName
  25. {
  26. get
  27. {
  28. return batchProcessingRegionName;
  29. }
  30. set
  31. {
  32. SetProperty(ref batchProcessingRegionName, value);
  33. }
  34. }
  35. private Visibility batchProcessingVisible = Visibility.Collapsed;
  36. public Visibility BatchProcessingVisible
  37. {
  38. get { return batchProcessingVisible; }
  39. set { SetProperty(ref batchProcessingVisible, value); }
  40. }
  41. #endregion
  42. #region 委托声明
  43. public DelegateCommand<string> DelegateChangeBatchProcessingCommand { get; set; }
  44. #endregion
  45. public HomePageBatchProcessingDialogViewModel(IRegionManager regionManager)
  46. {
  47. BatchProcessingRegion = regionManager;
  48. BatchProcessingRegionName = Guid.NewGuid().ToString();
  49. DelegateChangeBatchProcessingCommand= new DelegateCommand<string>(ChangeBatchProcessing);
  50. }
  51. #region 逻辑函数
  52. public void ChangeBatchProcessing(string index) {
  53. NavigationParameters param = new NavigationParameters();
  54. param.Add(ParameterNames.FilePath, HomePageBatchProcessingDialogModel.FilePaths);
  55. BatchProcessingVisible = Visibility.Collapsed;
  56. if (index =="0") {
  57. param.Add("ConverterTypeIndex", convertertypeindex);
  58. }
  59. BatchProcessingRegion.RequestNavigate(BatchProcessingRegionName, HomePageBatchProcessingDialogModel.GetBatchProcessing[int.Parse(index)], param);
  60. BatchProcessingVisible = Visibility.Visible;
  61. }
  62. #endregion
  63. public string Title => "PDF批量工具";
  64. public event Action<IDialogResult> RequestClose;
  65. #region 构架行为
  66. public bool CanCloseDialog()
  67. {
  68. return true;
  69. }
  70. public void OnDialogClosed()
  71. {
  72. }
  73. public void OnDialogOpened(IDialogParameters parameters)
  74. {
  75. string batchprocessingname = "";
  76. string[] filepath = null;
  77. int convertertypeindex=0;
  78. parameters.TryGetValue<string>(ParameterNames.BatchProcessing_Name, out batchprocessingname);
  79. parameters.TryGetValue<string[]>(ParameterNames.FilePath, out filepath);
  80. parameters.TryGetValue<int>("ConverterTypeIndex", out convertertypeindex);
  81. if (batchprocessingname != null || filepath != null) {
  82. fileNames = filepath.ToList();
  83. this.convertertypeindex = convertertypeindex;
  84. ChangeBatchProcessing(batchprocessingname);
  85. }
  86. }
  87. public void OnNavigatedTo(NavigationContext navigationContext)
  88. {
  89. }
  90. public bool IsNavigationTarget(NavigationContext navigationContext)
  91. {
  92. return true;
  93. }
  94. public void OnNavigatedFrom(NavigationContext navigationContext)
  95. {
  96. }
  97. #endregion
  98. }
  99. }