123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using ComPDFKit_Conversion.Converter;
- using PDF_Office.Model;
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Regions;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace PDF_Office.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 UpdateImageType(int index)
- {
- this.homePageConverterDialogViewModel.ConverterImgModel.Type = 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.Type = ImgType.JPEG;
- break;
- default:
- break;
- }
- }
- #region 构架行为
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- var homePageConverterVM = navigationContext.Parameters[ParameterNames.ViewContentViewModel] as HomePageConverterDialogViewModel;
- if (homePageConverterVM != null)
- {
- homePageConverterDialogViewModel = homePageConverterVM;
- }
- }
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
- }
- #endregion
- }
- }
|