123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- using ComPDFKit.PDFDocument;
- using ComPDFKitViewer.PdfViewer;
- using PDF_Office.CustomControl;
- using PDF_Office.Model;
- using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
- using PDF_Office.Model.PDFTool;
- using PDF_Office.Views.HomePanel.PDFTools;
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Services.Dialogs;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Xml.Linq;
- namespace PDF_Office.ViewModels.HomePanel
- {
- public class HomeGuidContentViewModel : BindableBase
- {
- public IDialogService dialogs;
- public DelegateCommand<ToolItem> QuickToolsCommand { get; set; }
- public HomeGuidContentViewModel(IDialogService dialogService)
- {
- QuickToolsCommand = new DelegateCommand<ToolItem>(QuickTools_Click);
- dialogs = dialogService;
- }
- public void QuickTools_Click(ToolItem toolItem)
- {
- /*
- *设置这个对话框的起始保存路径
- */
- System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
- dlg.Multiselect = false;
- dlg.Filter = "PDF|*.pdf;*.PDF;";
- if (toolItem.Tag == PDFToolType.Compress || toolItem.Tag == PDFToolType.Security)
- {
- dlg.Multiselect = true;
- }
- if (toolItem.Tag == PDFToolType.Merge)
- {
- dlg.Multiselect = true;
- dlg.Filter = "Picture|*.png;*.PNG;*.jpg;*.JPG;*bmp;*jpeg;*gif;*tiff;";
- }
- if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- CPDFViewer viewer = new CPDFViewer();
-
- switch (toolItem.Tag)
- {
- case PDFToolType.Split:
-
- viewer.InitDocument(dlg.FileName);
- DialogParameters splitvalue = new DialogParameters();
- splitvalue.Add(ParameterNames.PDFViewer, viewer);
- splitvalue.Add(ParameterNames.FilePath, dlg.FileName);
- dialogs.ShowDialog(DialogNames.HomePageSplitDialog, splitvalue, e => { });
- break;
- case PDFToolType.Extract:
- viewer.InitDocument(dlg.FileName);
- DialogParameters extractvalue = new DialogParameters();
- extractvalue.Add(ParameterNames.PDFViewer, viewer);
- extractvalue.Add(ParameterNames.FilePath, dlg.FileName);
- dialogs.ShowDialog(DialogNames.HomePageExtractDialog, extractvalue, e => { });
- break;
- case PDFToolType.Insert:
- viewer.InitDocument(dlg.FileName);
- DialogParameters insertvalue = new DialogParameters();
- insertvalue.Add(ParameterNames.PDFViewer, viewer);
- insertvalue.Add(ParameterNames.FilePath, dlg.FileName);
- dialogs.ShowDialog(DialogNames.HomePageInsertDialog, insertvalue, e => { });
- break;
- case PDFToolType.Compress:
- DialogParameters compresspdf = new DialogParameters();
- compresspdf.Add(ParameterNames.BatchProcessing_Name, "1");
- HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
- HomePageBatchProcessingDialogModel.BatchProcessingIndex = 1;
- compresspdf.Add(ParameterNames.FilePath, dlg.FileNames);
- dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, compresspdf, e => { });
- break;
- case PDFToolType.Merge:
- DialogParameters picturetopdf = new DialogParameters();
- picturetopdf.Add(ParameterNames.FilePath, dlg.FileNames);
- dialogs.ShowDialog(DialogNames.HomePagePictureToPDFDialog, picturetopdf, e => { });
- break;
- case PDFToolType.Print:
- DialogParameters printvalue = new DialogParameters();
- printvalue.Add(ParameterNames.FilePath, dlg.FileName);
- dialogs.ShowDialog(DialogNames.HomePagePrinterDialog, printvalue, e => { });
- break;
- case PDFToolType.Security:
- DialogParameters securitypdf = new DialogParameters();
- securitypdf.Add(ParameterNames.BatchProcessing_Name, "2");
- HomePageBatchProcessingDialogModel.FilePaths = dlg.FileNames.ToList();
- HomePageBatchProcessingDialogModel.BatchProcessingIndex = 1;
- securitypdf.Add(ParameterNames.FilePath, dlg.FileNames);
- dialogs.ShowDialog(DialogNames.HomePageBatchProcessingDialog, securitypdf, e => { });
-
- break;
- }
- }
- }
- }
- }
|