123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- 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<string> ImageTypeFamily { set; get; } = new List<string>();
- 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<string> ImageDPIFamily { set; get; } = new List<string>();
- 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
- }
- }
|