123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- using ComPDFKit.PDFDocument;
- using ComPDFKit_Conversion.Converter;
- using ComPDFKit_Conversion.Options;
- using PDF_Master.Helper;
- using PDF_Master.Model;
- using PDF_Master.Model.Dialog.ConverterDialogs;
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Services.Dialogs;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Net.Mime;
- using System.Windows.Media;
- using static Dropbox.Api.Sharing.ListFileMembersIndividualResult;
- using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip;
- namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
- {
- public class ConverterProgressBarDialogViewModel : BindableBase,IDialogAware
- {
- public string Title => "";
- public event Action<IDialogResult> RequestClose;
- #region 参数和属性
- private string _pageIndex = "0";
- /// <value>
- /// 当前页
- /// </value>
- public string PageIndex
- {
- get { return _pageIndex; }
- set
- {
- SetProperty(ref _pageIndex, value);
- }
- }
- private string _pageNumber = "0";
- /// <value>
- /// 总页数
- /// </value>
- public string PageNumber
- {
- get { return _pageNumber; }
- set
- {
- SetProperty(ref _pageNumber, value);
- }
- }
- #endregion
- public DelegateCommand CloseCompressCommand { get; set; }
- public ConverterProgressBarDialogViewModel()
- {
- CloseCompressCommand = new DelegateCommand(Close);
- }
- #region 逻辑函数
- private void SetProgress(int pageIndex)
- {
- PageIndex=pageIndex.ToString();
- }
- public void Close()
- {
- RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
- }
- #endregion
- #region 构架行为
- public bool CanCloseDialog()
- {
- return true;
- }
- public void OnDialogClosed()
- {
- //ConverterHelper.Clear();
- }
- public void OnDialogOpened(IDialogParameters parameters)
- {
- #region 转档
- //bool result=false;
- //string convertType="";
- //OnProgress GetProgress = null;
- //GetProgress += SetProgress;
- //parameters.TryGetValue<string>(ParameterNames.ConverterType, out convertType);
- //switch (convertType)
- //{
- // case "CSV":
- // ConverterCSVDialogModel ConverterCSVModel;
- // parameters.TryGetValue<ConverterCSVDialogModel>(ParameterNames.ConverterTypeModel, out ConverterCSVModel);
- // if (ConverterCSVModel != null)
- // {
- // PageNumber = ConverterCSVModel.PageIndexLists.Count().ToString();
- // for (int i = 0; ConverterCSVModel.PageIndexLists.Count > i; i++)
- // {
- // ConverterCSVModel.PageIndexLists[i] = ConverterCSVModel.PageIndexLists[i] + 1;
- // }
- // result = await ConverterHelper.CSVConvert(ConverterCSVModel.InputPath, ConverterCSVModel.OutputPath, GetProgress, ConverterCSVModel.PageIndexLists, ConverterCSVModel.Pawssword, ConverterCSVModel.csvOptions);
- // }
- // break;
- // case "Excel":
- // ConverterExcelDialogModel ConverterExcelModel;
- // parameters.TryGetValue<ConverterExcelDialogModel>(ParameterNames.ConverterTypeModel, out ConverterExcelModel);
- // if (ConverterExcelModel != null)
- // {
- // PageNumber = ConverterExcelModel.PageIndexLists.Count().ToString();
- // for (int i = 0; ConverterExcelModel.PageIndexLists.Count > i; i++)
- // {
- // ConverterExcelModel.PageIndexLists[i] = ConverterExcelModel.PageIndexLists[i] + 1;
- // }
- // result = await ConverterHelper.ExcelConvert(ConverterExcelModel.InputPath, ConverterExcelModel.OutputPath, GetProgress, ConverterExcelModel.PageIndexLists, ConverterExcelModel.Pawssword, ConverterExcelModel.excelOptions);
- // }
- // break;
- // case "HTML":
- // ConverterHTMLDialogModel ConverterHTMLModel;
- // parameters.TryGetValue<ConverterHTMLDialogModel>(ParameterNames.ConverterTypeModel, out ConverterHTMLModel);
- // if (ConverterHTMLModel != null)
- // {
- // PageNumber = ConverterHTMLModel.PageIndexLists.Count().ToString();
- // for (int i = 0; ConverterHTMLModel.PageIndexLists.Count > i; i++)
- // {
- // ConverterHTMLModel.PageIndexLists[i] = ConverterHTMLModel.PageIndexLists[i] + 1;
- // }
- // result = await ConverterHelper.HTMLConvert(ConverterHTMLModel.InputPath, ConverterHTMLModel.OutputPath, GetProgress, ConverterHTMLModel.PageIndexLists, ConverterHTMLModel.Pawssword, ConverterHTMLModel.htmlOptions);
- // }
- // break;
- // case "Img":
- // ConverterImgDialogModel ConverterImgModel;
- // parameters.TryGetValue<ConverterImgDialogModel>(ParameterNames.ConverterTypeModel, out ConverterImgModel);
- // if (ConverterImgModel != null)
- // {
- // PageNumber = ConverterImgModel.PageIndexLists.Count().ToString();
- // for (int i=0; ConverterImgModel.PageIndexLists.Count>i;i++) {
- // ConverterImgModel.PageIndexLists[i] = ConverterImgModel.PageIndexLists[i] + 1;
- // }
- // result = await ConverterHelper.ImgConvert(ConverterImgModel.InputPath, ConverterImgModel.OutputPath, GetProgress, ConverterImgModel.PageIndexLists, ConverterImgModel.Pawssword, ConverterImgModel.imageType, ConverterImgModel.imgOptions);
- // }
- // break;
- // case "PPT":
- // ConverterPPTDialogModel ConverterPPTModel;
- // parameters.TryGetValue<ConverterPPTDialogModel>(ParameterNames.ConverterTypeModel, out ConverterPPTModel);
- // if (ConverterPPTModel != null)
- // {
- // PageNumber = ConverterPPTModel.PageIndexLists.Count().ToString();
- // for (int i = 0; ConverterPPTModel.PageIndexLists.Count > i; i++)
- // {
- // ConverterPPTModel.PageIndexLists[i] = ConverterPPTModel.PageIndexLists[i] + 1;
- // }
- // result = await ConverterHelper.PPTConvert(ConverterPPTModel.InputPath, ConverterPPTModel.OutputPath, GetProgress, ConverterPPTModel.PageIndexLists, ConverterPPTModel.Pawssword, ConverterPPTModel.pPTOptions);
- // }
- // break;
- // case "RTF":
- // ConverterRTFDialogModel ConverterRTFModel;
- // parameters.TryGetValue<ConverterRTFDialogModel>(ParameterNames.ConverterTypeModel, out ConverterRTFModel);
- // if (ConverterRTFModel != null)
- // {
- // PageNumber = ConverterRTFModel.PageIndexLists.Count().ToString();
- // for (int i = 0; ConverterRTFModel.PageIndexLists.Count > i; i++)
- // {
- // ConverterRTFModel.PageIndexLists[i] = ConverterRTFModel.PageIndexLists[i] + 1;
- // }
- // result = await ConverterHelper.RTFConvert(ConverterRTFModel.InputPath, ConverterRTFModel.OutputPath, GetProgress, ConverterRTFModel.PageIndexLists, ConverterRTFModel.Pawssword, ConverterRTFModel.rTFOptions);
- // }
- // break;
- // case "Text":
- // ConverterTextDialogModel ConverterTextModel;
- // parameters.TryGetValue<ConverterTextDialogModel>(ParameterNames.ConverterTypeModel, out ConverterTextModel);
- // if (ConverterTextModel != null)
- // {
- // PageNumber = ConverterTextModel.PageIndexLists.Count().ToString();
- // for (int i = 0; ConverterTextModel.PageIndexLists.Count > i; i++)
- // {
- // ConverterTextModel.PageIndexLists[i] = ConverterTextModel.PageIndexLists[i] + 1;
- // }
- // result = await ConverterHelper.TxtConvert(ConverterTextModel.InputPath, ConverterTextModel.OutputPath, GetProgress, ConverterTextModel.PageIndexLists, ConverterTextModel.Pawssword, ConverterTextModel.txtOptions);
- // }
- // break;
- // case "Word":
- // ConverterWordDialogModel ConverterWordModel;
- // parameters.TryGetValue<ConverterWordDialogModel>(ParameterNames.ConverterTypeModel, out ConverterWordModel);
- // if (ConverterWordModel != null) {
- // PageNumber = ConverterWordModel.PageIndexLists.Count().ToString();
- // for (int i = 0; ConverterWordModel.PageIndexLists.Count > i; i++)
- // {
- // ConverterWordModel.PageIndexLists[i] = ConverterWordModel.PageIndexLists[i] + 1;
- // }
- // result = await ConverterHelper.WordConvert(ConverterWordModel.InputPath, ConverterWordModel.OutputPath, GetProgress, ConverterWordModel.PageIndexLists, ConverterWordModel.Pawssword, ConverterWordModel.wordOptions);
- // }
- // break;
- // default:
- // break;
- //}
- #endregion
- RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
- }
- #endregion
- }
- }
|