using ComPDFKit_Conversion.Options; using PDF_Master.Model; using PDF_Master.Model.Dialog.ConverterDialogs; using PDF_Master.Model.EditTools.Watermark; using Prism.Commands; using Prism.Mvvm; using Prism.Regions; using System; using System.Collections.Generic; using System.Linq; using System.Windows.Controls; namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageConverter { public class HomePageConverterExcelViewModel : BindableBase, INavigationAware { #region 参数和属性 public HomePageConverterDialogViewModel homePageConverterDialogViewModel { get; set; } private int _anyContentSelectIndex; public int AnyContentSelectIndex { get { return _anyContentSelectIndex; } set { SetProperty(ref _anyContentSelectIndex, value); AnyContent(_anyContentSelectIndex); } } private int _onlyTableSelectIndex; public int OnlyTableSelectIndex { get { return _onlyTableSelectIndex; } set { SetProperty(ref _onlyTableSelectIndex, value); OnlyTable(_onlyTableSelectIndex); } } #endregion #region 委托声明 public DelegateCommand RadioButtonCommand { get; set; } #endregion public HomePageConverterExcelViewModel() { RadioButtonCommand = new DelegateCommand(radiobutton); } #region 逻辑函数 private void radiobutton(string e) { string radioButton = e; if (radioButton != null) { switch (radioButton) { case "AnyContentRadioBtn": AnyContent(AnyContentSelectIndex); break; case "OnlyTableRadioBtn": OnlyTable(OnlyTableSelectIndex); break; case "OnlyTextRadioBtn": homePageConverterDialogViewModel.ConverterExcelModel.Options.WorksheetOpts = WorksheetOptions.ForTheDocument; homePageConverterDialogViewModel.ConverterExcelModel.Options.ContentOpts = ContentOptions.OnlyText; break; default: break; } } } private void AnyContent(int SelectedIndex) { switch (SelectedIndex) { case 0: homePageConverterDialogViewModel.ConverterExcelModel.Options.WorksheetOpts = WorksheetOptions.ForEachPage; homePageConverterDialogViewModel.ConverterExcelModel.Options.ContentOpts = ContentOptions.AllContent; break; case 1: homePageConverterDialogViewModel.ConverterExcelModel.Options.WorksheetOpts = WorksheetOptions.ForTheDocument; homePageConverterDialogViewModel.ConverterExcelModel.Options.ContentOpts = ContentOptions.AllContent; break; default: break; } } private void OnlyTable(int SelectedIndex) { homePageConverterDialogViewModel.ConverterExcelModel.Options.ContentOpts = ContentOptions.OnlyTable; switch (SelectedIndex) { case 0: homePageConverterDialogViewModel.ConverterExcelModel.Options.WorksheetOpts = WorksheetOptions.ForEachTable; break; case 1: homePageConverterDialogViewModel.ConverterExcelModel.Options.WorksheetOpts = WorksheetOptions.ForEachPage; break; case 2: homePageConverterDialogViewModel.ConverterExcelModel.Options.WorksheetOpts = WorksheetOptions.ForEachPage; break; default: break; } } #endregion #region 构架行为 public void OnNavigatedTo(NavigationContext navigationContext) { var homePageConverterVM = navigationContext.Parameters[ParameterNames.ViewContentViewModel] as HomePageConverterDialogViewModel; if (homePageConverterVM != null) { homePageConverterDialogViewModel = homePageConverterVM; OnlyTableSelectIndex = 0; AnyContentSelectIndex = 0; homePageConverterDialogViewModel.ConverterExcelModel.excelOptions = homePageConverterDialogViewModel.ConverterExcelModel.ExcelOptions(); } } public bool IsNavigationTarget(NavigationContext navigationContext) { return true; } public void OnNavigatedFrom(NavigationContext navigationContext) { } #endregion } }