using ComPDFKit_Conversion.Converter; using ComPDFKit_Conversion.Options; using Microsoft.Office.Interop.Word; using PDF_Master.Model; using Prism.Commands; using Prism.Mvvm; using Prism.Regions; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageConverter { public class HomePageConverterImgViewModel : BindableBase, INavigationAware { #region 参数和属性 public List ImageTypeFamily { set; get; } = new List(); public HomePageConverterDialogViewModel homePageConverterDialogViewModel { get; set; } private void SetImageTypeOrigin() { this.ImageTypeFamily.Add("JPEG"); this.ImageTypeFamily.Add("JPG"); this.ImageTypeFamily.Add("PNG"); this.ImageTypeFamily.Add("GIF"); this.ImageTypeFamily.Add("TIFF"); this.ImageTypeFamily.Add("TGA"); this.ImageTypeFamily.Add("BMP"); this.ImageTypeFamily.Add("JPEG-2000"); } public List ImageDPIFamily { set; get; } = new List(); private void SetImageDPIOrigin() { this.ImageDPIFamily.Add("50 dpi"); this.ImageDPIFamily.Add("72 dpi"); this.ImageDPIFamily.Add("96 dpi"); this.ImageDPIFamily.Add("150 dpi"); this.ImageDPIFamily.Add("300 dpi"); this.ImageDPIFamily.Add("600 dpi"); } #endregion public HomePageConverterImgViewModel() { SetImageTypeOrigin(); SetImageDPIOrigin(); } public void UpdateImageDpi(int index) { switch (index) { case 0: this.homePageConverterDialogViewModel.ConverterImgModel.Options.ImageDpi =50; break; case 1: this.homePageConverterDialogViewModel.ConverterImgModel.Options.ImageDpi = 72; break; case 2: this.homePageConverterDialogViewModel.ConverterImgModel.Options.ImageDpi = 96; break; case 3: this.homePageConverterDialogViewModel.ConverterImgModel.Options.ImageDpi = 150; break; case 4: this.homePageConverterDialogViewModel.ConverterImgModel.Options.ImageDpi = 300; break; case 5: this.homePageConverterDialogViewModel.ConverterImgModel.Options.ImageDpi = 600; break; default: break; } } public void UpdateImageType(int index) { this.homePageConverterDialogViewModel.ConverterImgModel.Options.ImageType = ImgType.PNG; switch (index) { //case结果是同样的情况下,case可堆叠在一起,表示处理方式一样 case 0: this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".jpeg"; break; case 7: this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".jp2"; break; case 3: this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".gif"; break; case 4: this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".tiff"; break; case 5: this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".tga"; break; case 6: this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".bmp"; break; case 2: this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".png"; break; case 1: this.homePageConverterDialogViewModel.ConverterImgModel.imageType = ".jpg"; this.homePageConverterDialogViewModel.ConverterImgModel.Options.ImageType = ImgType.JPEG; break; default: break; } } #region 构架行为 public void OnNavigatedTo(NavigationContext navigationContext) { var homePageConverterVM = navigationContext.Parameters[ParameterNames.ViewContentViewModel] as HomePageConverterDialogViewModel; if (homePageConverterVM != null) { homePageConverterDialogViewModel = homePageConverterVM; UpdateImageDpi(0); UpdateImageType(0); } } public bool IsNavigationTarget(NavigationContext navigationContext) { return true; } public void OnNavigatedFrom(NavigationContext navigationContext) { } #endregion } }