HomeGuidContentViewModel.cs 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using ComPDFKit.PDFDocument;
  2. using ComPDFKitViewer.PdfViewer;
  3. using PDF_Office.CustomControl;
  4. using PDF_Office.Model;
  5. using PDF_Office.Model.PDFTool;
  6. using PDF_Office.Views.HomePanel.PDFTools;
  7. using Prism.Commands;
  8. using Prism.Mvvm;
  9. using Prism.Services.Dialogs;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using System.Windows.Forms;
  16. using System.Xml.Linq;
  17. namespace PDF_Office.ViewModels.HomePanel
  18. {
  19. public class HomeGuidContentViewModel:BindableBase
  20. {
  21. public IDialogService dialogs;
  22. public DelegateCommand<ToolItem> QuickToolsCommand { get; set; }
  23. public HomeGuidContentViewModel(IDialogService dialogService)
  24. {
  25. QuickToolsCommand = new DelegateCommand<ToolItem>(QuickTools_Click);
  26. dialogs = dialogService;
  27. }
  28. public void QuickTools_Click(ToolItem toolItem)
  29. {
  30. /*
  31. *设置这个对话框的起始保存路径
  32. */
  33. System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
  34. dlg.Multiselect = false;
  35. dlg.Filter = "PDF|*.pdf;*.PDF;";
  36. if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  37. {
  38. CPDFViewer viewer=new CPDFViewer();
  39. viewer.InitDocument(dlg.FileName);
  40. switch (toolItem.Tag)
  41. {
  42. case PDFToolType.Split:
  43. Split_Click();
  44. DialogParameters splitvalue = new DialogParameters();
  45. splitvalue.Add(ParameterNames.PDFViewer, viewer);
  46. splitvalue.Add(ParameterNames.FilePath, dlg.FileName);
  47. dialogs.ShowDialog(DialogNames.HomePageSplitDialog, splitvalue, e => { });
  48. break;
  49. case PDFToolType.Extract:
  50. DialogParameters extractvalue = new DialogParameters();
  51. extractvalue.Add(ParameterNames.PDFViewer, viewer);
  52. extractvalue.Add(ParameterNames.FilePath, dlg.FileName);
  53. dialogs.ShowDialog(DialogNames.HomePageExtractDialog, extractvalue, e => { });
  54. break;
  55. case PDFToolType.Insert:
  56. DialogParameters insertvalue = new DialogParameters();
  57. insertvalue.Add(ParameterNames.PDFViewer, viewer);
  58. insertvalue.Add(ParameterNames.FilePath, dlg.FileName);
  59. dialogs.ShowDialog(DialogNames.HomePageInsertDialog, insertvalue, e => { });
  60. break;
  61. case PDFToolType.Compress:
  62. break;
  63. case PDFToolType.Merge:
  64. break;
  65. case PDFToolType.Print:
  66. DialogParameters printvalue = new DialogParameters();
  67. printvalue.Add(ParameterNames.PDFViewer, viewer); ;
  68. printvalue.Add(ParameterNames.FilePath, dlg.FileName);
  69. dialogs.ShowDialog(DialogNames.HomePagePrinterDialog, printvalue, e => { });
  70. break;
  71. case PDFToolType.Security:
  72. break;
  73. }
  74. }
  75. }
  76. private void Split_Click()
  77. {
  78. }
  79. }
  80. }