HomePageConverterImgViewModel.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using ComPDFKit_Conversion.Converter;
  2. using PDF_Office.Model;
  3. using Prism.Commands;
  4. using Prism.Mvvm;
  5. using Prism.Regions;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageConverter
  10. {
  11. public class HomePageConverterImgViewModel : BindableBase, INavigationAware
  12. {
  13. #region 参数和属性
  14. public List<string> ImageTypeFamily { set; get; } = new List<string>();
  15. public HomePageConverterDialogViewModel homePageConverterDialogViewModel { get; set; }
  16. private void SetImageTypeOrigin()
  17. {
  18. this.ImageTypeFamily.Add("JPEG");
  19. this.ImageTypeFamily.Add("JPG");
  20. this.ImageTypeFamily.Add("PNG");
  21. this.ImageTypeFamily.Add("GIF");
  22. this.ImageTypeFamily.Add("TIFF");
  23. this.ImageTypeFamily.Add("TGA");
  24. this.ImageTypeFamily.Add("BMP");
  25. this.ImageTypeFamily.Add("JPEG-2000");
  26. }
  27. public List<string> ImageDPIFamily { set; get; } = new List<string>();
  28. private void SetImageDPIOrigin()
  29. {
  30. this.ImageDPIFamily.Add("50 dpi");
  31. this.ImageDPIFamily.Add("72 dpi");
  32. this.ImageDPIFamily.Add("96 dpi");
  33. this.ImageDPIFamily.Add("150 dpi");
  34. this.ImageDPIFamily.Add("300 dpi");
  35. this.ImageDPIFamily.Add("600 dpi");
  36. }
  37. #endregion
  38. public HomePageConverterImgViewModel()
  39. {
  40. SetImageTypeOrigin();
  41. SetImageDPIOrigin();
  42. }
  43. public void UpdateImageType(int index)
  44. {
  45. this.homePageConverterDialogViewModel.ConverterImgModel.Type = ImgType.PNG;
  46. switch (index)
  47. {
  48. //case结果是同样的情况下,case可堆叠在一起,表示处理方式一样
  49. case 0:
  50. this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".jpeg";
  51. break;
  52. case 7:
  53. this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".jp2";
  54. break;
  55. case 3:
  56. this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".gif";
  57. break;
  58. case 4:
  59. this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".tiff";
  60. break;
  61. case 5:
  62. this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".tga";
  63. break;
  64. case 6:
  65. this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".bmp";
  66. break;
  67. case 2:
  68. this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".png";
  69. break;
  70. case 1:
  71. this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".jpg";
  72. this.homePageConverterDialogViewModel.ConverterImgModel.Type = ImgType.JPEG;
  73. break;
  74. default:
  75. break;
  76. }
  77. }
  78. #region 构架行为
  79. public void OnNavigatedTo(NavigationContext navigationContext)
  80. {
  81. var homePageConverterVM = navigationContext.Parameters[ParameterNames.ViewContentViewModel] as HomePageConverterDialogViewModel;
  82. if (homePageConverterVM != null)
  83. {
  84. homePageConverterDialogViewModel = homePageConverterVM;
  85. }
  86. }
  87. public bool IsNavigationTarget(NavigationContext navigationContext)
  88. {
  89. return true;
  90. }
  91. public void OnNavigatedFrom(NavigationContext navigationContext)
  92. {
  93. }
  94. #endregion
  95. }
  96. }