123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- 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<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()
- {
- 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
- }
- }
|