ImageTextEditPropertyViewModel.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using ComPDFKitViewer;
  2. using ComPDFKitViewer.PdfViewer;
  3. using PDF_Master.Model;
  4. using Prism.Commands;
  5. using Prism.Mvvm;
  6. using Prism.Regions;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
  13. {
  14. public class ImageTextEditPropertyViewModel : PDFEditVM, INavigationAware
  15. {
  16. #region 变量
  17. protected List<ComPDFKitViewer.PDFEditEvent> TextEditEventList;
  18. public event EventHandler ClearCheckedAglin;
  19. #endregion
  20. #region Command
  21. public DelegateCommand<object> ImgAlignCheckedCommand { get; set; }
  22. #endregion
  23. public ImageTextEditPropertyViewModel()
  24. {
  25. ImgAlignCheckedCommand = new DelegateCommand<object>(ImgAlignChecked);
  26. }
  27. #region Command实现
  28. private void ImgAlignChecked(object obj)
  29. {
  30. if (obj != null)
  31. {
  32. switch ((string)obj)
  33. {
  34. case "AlignLeft":
  35. PDFViewer.SetPDFEditAligment(AlignModes.AlignLeft);
  36. break;
  37. case "AlignHorizonCenter":
  38. PDFViewer.SetPDFEditAligment(AlignModes.AlignHorizonCenter);
  39. break;
  40. case "AlignRight":
  41. PDFViewer.SetPDFEditAligment(AlignModes.AlignRight);
  42. break;
  43. case "DistributeHorizontal":
  44. PDFViewer.SetPDFEditAligment(AlignModes.DistributeHorizontal);
  45. break;
  46. case "AlignTop":
  47. PDFViewer.SetPDFEditAligment(AlignModes.AlignTop);
  48. break;
  49. case "AlignVerticalCenter":
  50. PDFViewer.SetPDFEditAligment(AlignModes.AlignVerticalCenter);
  51. break;
  52. case "AlignBottom":
  53. PDFViewer.SetPDFEditAligment(AlignModes.AlignBottom);
  54. break;
  55. case "DistributeVertical":
  56. PDFViewer.SetPDFEditAligment(AlignModes.DistributeVertical);
  57. break;
  58. }
  59. }
  60. }
  61. #endregion
  62. public void OnNavigatedTo(NavigationContext navigationContext)
  63. {
  64. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  65. navigationContext.Parameters.TryGetValue<List<PDFEditEvent>>(ParameterNames.AnnotEvent, out TextEditEventList);
  66. if (PDFViewer != null)
  67. {
  68. if (TextEditEventList != null && TextEditEventList.Count > 0)
  69. {
  70. TextEditEvent = TextEditEventList[0];
  71. if (TextEditEventList.Count == 2)
  72. {
  73. IsLayoutAlign = true;
  74. IsLayoutAvgAlign = false;
  75. }
  76. else if (TextEditEventList.Count > 2)
  77. {
  78. IsLayoutAlign = true;
  79. IsLayoutAvgAlign = true;
  80. }
  81. else
  82. {
  83. IsLayoutAlign = false;
  84. IsLayoutAvgAlign = false;
  85. }
  86. }
  87. }
  88. }
  89. public bool IsNavigationTarget(NavigationContext navigationContext) { return true; }
  90. public void OnNavigatedFrom(NavigationContext navigationContext)
  91. {
  92. ClearCheckedAglin?.Invoke(null, null);
  93. }
  94. }
  95. }