HomePageConverterExcelViewModel.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using ComPDFKit_Conversion.Options;
  2. using PDF_Office.Model;
  3. using PDF_Office.Model.Dialog.ConverterDialogs;
  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_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageConverter
  11. {
  12. public class HomePageConverterExcelViewModel : BindableBase, INavigationAware
  13. {
  14. #region 参数和属性
  15. public ConverterExcelDialogModel ConverterExcelModel = new ConverterExcelDialogModel();
  16. public HomePageConverterDialogViewModel homePageConverterDialogViewModel { get; set; }
  17. #endregion
  18. #region 委托声明
  19. public DelegateCommand<string> RadioButtonCommand { get; set; }
  20. #endregion
  21. public HomePageConverterExcelViewModel()
  22. {
  23. RadioButtonCommand = new DelegateCommand<string>(radiobutton);
  24. }
  25. #region 逻辑函数
  26. private void radiobutton(string e)
  27. {
  28. string radioButton = e;
  29. if (radioButton != null)
  30. {
  31. switch (radioButton)
  32. {
  33. case "ForEachPageRadioBtn":
  34. homePageConverterDialogViewModel. ConverterExcelModel.excelOption = ConverterExcelModel.ExcelOptions();
  35. break;
  36. case "ForTheDocRadioBtn":
  37. homePageConverterDialogViewModel.ConverterExcelModel.excelOption = ConverterExcelModel.ExcelOptions(WorksheetOptions.ForTheDocument);
  38. break;
  39. case "OnlyTableRadioBtn":
  40. homePageConverterDialogViewModel.ConverterExcelModel.excelOption = ConverterExcelModel.ExcelOptions(WorksheetOptions.ForEachTable, ContentOptions.OnlyTable);
  41. break;
  42. case "OnlyTextRadioBtn":
  43. ConverterExcelModel.excelOption = ConverterExcelModel.ExcelOptions(WorksheetOptions.ForTheDocument, ContentOptions.OnlyText);
  44. break;
  45. default:
  46. break;
  47. }
  48. }
  49. }
  50. #endregion
  51. #region 构架行为
  52. public void OnNavigatedTo(NavigationContext navigationContext)
  53. {
  54. var homePageConverterVM = navigationContext.Parameters[ParameterNames.ViewContentViewModel] as HomePageConverterDialogViewModel;
  55. if (homePageConverterVM != null)
  56. {
  57. homePageConverterDialogViewModel = homePageConverterVM;
  58. homePageConverterDialogViewModel.ConverterExcelModel.excelOption = ConverterExcelModel.ExcelOptions();
  59. }
  60. }
  61. public bool IsNavigationTarget(NavigationContext navigationContext)
  62. {
  63. return true;
  64. }
  65. public void OnNavigatedFrom(NavigationContext navigationContext)
  66. {
  67. }
  68. #endregion
  69. }
  70. }