123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- 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<string> 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<string> DelegateChangeBatchProcessingCommand { get; set; }
- #endregion
- public HomePageBatchProcessingDialogViewModel(IRegionManager regionManager)
- {
- BatchProcessingRegion = regionManager;
- BatchProcessingRegionName = Guid.NewGuid().ToString();
- DelegateChangeBatchProcessingCommand= new DelegateCommand<string>(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<IDialogResult> 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<DeleteWatermarkEvent>().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<string>(ParameterNames.BatchProcessing_Name, out batchprocessingname);
- parameters.TryGetValue<string[]>(ParameterNames.FilePath, out filepath);
- parameters.TryGetValue<int>("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
- }
- }
|