using ComPDFKitViewer.PdfViewer; using Microsoft.Office.Interop.Word; using PDF_Master.CustomControl; using PDF_Master.EventAggregators; using PDF_Master.Model; using PDF_Master.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_Master.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() { AlertsMessage alertsMessage = new AlertsMessage(); if (HomePageBatchProcessingDialogModel.closeDialog) { alertsMessage.ShowDialog("批量处理操作被中断,已完成的文件不受影响,是否确定要关闭弹窗", "", "取消", "确定"); if (alertsMessage.result == ContentResult.Ok) { return true; } else { //this.eventAggregator.GetEvent().Publish(new EnumDeleteUnicode //{ // Unicode = Unicode, // Status = EnumDelete.StatusCreate //}); return false; } } 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 } }