HomeGuidContentViewModel.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. PageTurningPreview.document = viewer.Document;
  48. dialogs.ShowDialog(DialogNames.HomePageSplitDialog, splitvalue, e => { });
  49. break;
  50. case PDFToolType.Extract:
  51. DialogParameters extractvalue = new DialogParameters();
  52. extractvalue.Add(ParameterNames.PDFViewer, viewer);
  53. extractvalue.Add(ParameterNames.FilePath, dlg.FileName);
  54. PageTurningPreview.document = viewer.Document;
  55. dialogs.ShowDialog(DialogNames.HomePageExtractDialog, extractvalue, e => { });
  56. break;
  57. case PDFToolType.Insert:
  58. DialogParameters insertvalue = new DialogParameters();
  59. insertvalue.Add(ParameterNames.PDFViewer, viewer);
  60. insertvalue.Add(ParameterNames.FilePath, dlg.FileName);
  61. PageTurningPreview.document = viewer.Document;
  62. dialogs.ShowDialog(DialogNames.HomePageInsertDialog, insertvalue, e => { });
  63. break;
  64. case PDFToolType.Compress:
  65. break;
  66. case PDFToolType.Merge:
  67. break;
  68. <<<<<<< Updated upstream
  69. case PDFToolType.Print:
  70. DialogParameters printvalue = new DialogParameters();
  71. printvalue.Add(ParameterNames.PDFViewer, viewer); ;
  72. printvalue.Add(ParameterNames.FilePath, dlg.FileName);
  73. dialogs.ShowDialog(DialogNames.HomePagePrinterDialog, printvalue, e => { });
  74. break;
  75. case PDFToolType.Security:
  76. break;
  77. }
  78. =======
  79. case PDFToolType.Print:
  80. DialogParameters printvalue = new DialogParameters();
  81. dialogs.ShowDialog(DialogNames.HomePagePrinterDialog, printvalue, e => { });
  82. break;
  83. >>>>>>> Stashed changes
  84. }
  85. }
  86. private void Split_Click()
  87. {
  88. }
  89. }
  90. }