HomePageConverterExcelViewModel.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. homePageConverterDialogViewModel.ConverterExcelModel.excelOption = ConverterExcelModel.ExcelOptions();
  25. }
  26. #region 逻辑函数
  27. private void radiobutton(string e)
  28. {
  29. string radioButton = e;
  30. if (radioButton != null)
  31. {
  32. switch (radioButton)
  33. {
  34. case "ForEachPageRadioBtn":
  35. homePageConverterDialogViewModel. ConverterExcelModel.excelOption = ConverterExcelModel.ExcelOptions();
  36. break;
  37. case "ForTheDocRadioBtn":
  38. homePageConverterDialogViewModel.ConverterExcelModel.excelOption = ConverterExcelModel.ExcelOptions(WorksheetOptions.ForTheDocument);
  39. break;
  40. case "OnlyTableRadioBtn":
  41. homePageConverterDialogViewModel.ConverterExcelModel.excelOption = ConverterExcelModel.ExcelOptions(WorksheetOptions.ForEachTable, ContentOptions.OnlyTable);
  42. break;
  43. case "OnlyTextRadioBtn":
  44. ConverterExcelModel.excelOption = ConverterExcelModel.ExcelOptions(WorksheetOptions.ForTheDocument, ContentOptions.OnlyText);
  45. break;
  46. default:
  47. break;
  48. }
  49. }
  50. }
  51. #endregion
  52. #region 构架行为
  53. public void OnNavigatedTo(NavigationContext navigationContext)
  54. {
  55. var homePageConverterVM = navigationContext.Parameters[ParameterNames.ViewContentViewModel] as HomePageConverterDialogViewModel;
  56. if (homePageConverterVM != null)
  57. {
  58. homePageConverterDialogViewModel = homePageConverterVM;
  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. }