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 RequestClose; #region 参数和属性 private string _pageIndex = "0"; /// /// 当前页 /// public string PageIndex { get { return _pageIndex; } set { SetProperty(ref _pageIndex, value); } } private string _pageNumber = "0"; /// /// 总页数 /// 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(ParameterNames.ConverterType, out convertType); //switch (convertType) //{ // case "CSV": // ConverterCSVDialogModel ConverterCSVModel; // parameters.TryGetValue(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(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(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(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(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(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(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(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 } }