123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- 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<string> RadioButtonCommand { get; set; }
- #endregion
- public HomePageConverterExcelViewModel()
- {
- RadioButtonCommand = new DelegateCommand<string>(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
- }
- }
|