using ComPDFKitViewer.PdfViewer; using Microsoft.Office.Interop.Word; using PDF_Office.Model; using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing; using Prism.Commands; using Prism.Mvvm; using Prism.Regions; using Prism.Services.Dialogs; using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Windows; using System.Windows.Controls; namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing { public class HomePageBatchProcessingDialogViewModel : BindableBase, IDialogAware, INavigationAware { #region 参数和属性 private List fileNames; public IRegionManager BatchProcessingRegion; int convertertypeindex = 0; private string batchProcessingRegionName; public string BatchProcessingRegionName { get { return batchProcessingRegionName; } set { SetProperty(ref batchProcessingRegionName, value); } } private Visibility batchProcessingVisible = Visibility.Collapsed; public Visibility BatchProcessingVisible { get { return batchProcessingVisible; } set { SetProperty(ref batchProcessingVisible, value); } } #endregion #region 委托声明 public DelegateCommand DelegateChangeBatchProcessingCommand { get; set; } #endregion public HomePageBatchProcessingDialogViewModel(IRegionManager regionManager) { BatchProcessingRegion = regionManager; BatchProcessingRegionName = Guid.NewGuid().ToString(); DelegateChangeBatchProcessingCommand= new DelegateCommand(ChangeBatchProcessing); } #region 逻辑函数 public void ChangeBatchProcessing(string index) { NavigationParameters param = new NavigationParameters(); param.Add(ParameterNames.FilePath, HomePageBatchProcessingDialogModel.FilePaths); BatchProcessingVisible = Visibility.Collapsed; if (index =="0") { param.Add("ConverterTypeIndex", convertertypeindex); } BatchProcessingRegion.RequestNavigate(BatchProcessingRegionName, HomePageBatchProcessingDialogModel.GetBatchProcessing[int.Parse(index)], param); BatchProcessingVisible = Visibility.Visible; } #endregion public string Title => "PDF批量工具"; public event Action RequestClose; #region 构架行为 public bool CanCloseDialog() { return true; } public void OnDialogClosed() { } public void OnDialogOpened(IDialogParameters parameters) { string batchprocessingname = ""; string[] filepath = null; int convertertypeindex=0; parameters.TryGetValue(ParameterNames.BatchProcessing_Name, out batchprocessingname); parameters.TryGetValue(ParameterNames.FilePath, out filepath); parameters.TryGetValue("ConverterTypeIndex", out convertertypeindex); if (batchprocessingname != null || filepath != null) { fileNames = filepath.ToList(); this.convertertypeindex = convertertypeindex; ChangeBatchProcessing(batchprocessingname); } } public void OnNavigatedTo(NavigationContext navigationContext) { } public bool IsNavigationTarget(NavigationContext navigationContext) { return true; } public void OnNavigatedFrom(NavigationContext navigationContext) { } #endregion } }