ImageTextEditPropertyViewModel.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using ComPDFKitViewer;
  2. using ComPDFKitViewer.PdfViewer;
  3. using PDF_Office.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_Office.ViewModels.PropertyPanel.PDFEdit
  13. {
  14. public class ImageTextEditPropertyViewModel : PDFEditVM, INavigationAware
  15. {
  16. public DelegateCommand<object> ImgAlignCheckedCommand { get; set; }
  17. public ImageTextEditPropertyViewModel()
  18. {
  19. ImgAlignCheckedCommand = new DelegateCommand<object>(ImgAlignChecked);
  20. }
  21. private void ImgAlignChecked(object obj)
  22. {
  23. if (obj != null)
  24. {
  25. switch ((string)obj)
  26. {
  27. case "AlignLeft":
  28. PDFViewer.SetPDFEditAligment(AlignModes.AlignLeft);
  29. break;
  30. case "AlignHorizonCenter":
  31. PDFViewer.SetPDFEditAligment(AlignModes.AlignHorizonCenter);
  32. break;
  33. case "AlignRight":
  34. PDFViewer.SetPDFEditAligment(AlignModes.AlignRight);
  35. break;
  36. case "DistributeHorizontal":
  37. PDFViewer.SetPDFEditAligment(AlignModes.DistributeHorizontal);
  38. break;
  39. case "AlignTop":
  40. PDFViewer.SetPDFEditAligment(AlignModes.AlignTop);
  41. break;
  42. case "AlignVerticalCenter":
  43. PDFViewer.SetPDFEditAligment(AlignModes.AlignVerticalCenter);
  44. break;
  45. case "AlignBottom":
  46. PDFViewer.SetPDFEditAligment(AlignModes.AlignBottom);
  47. break;
  48. case "DistributeVertical":
  49. PDFViewer.SetPDFEditAligment(AlignModes.DistributeVertical);
  50. break;
  51. }
  52. }
  53. }
  54. protected List<ComPDFKitViewer.PDFEditEvent> TextEditEventList;
  55. public void OnNavigatedTo(NavigationContext navigationContext)
  56. {
  57. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  58. navigationContext.Parameters.TryGetValue<List<PDFEditEvent>>(ParameterNames.AnnotEvent, out TextEditEventList);
  59. if (PDFViewer != null)
  60. {
  61. if (TextEditEventList != null && TextEditEventList.Count > 0)
  62. {
  63. TextEditEvent = TextEditEventList[0];
  64. if (TextEditEventList.Count == 2)
  65. {
  66. IsLayoutAlign = true;
  67. IsLayoutAvgAlign = false;
  68. }
  69. else if (TextEditEventList.Count > 2)
  70. {
  71. IsLayoutAlign = true;
  72. IsLayoutAvgAlign = true;
  73. }
  74. else
  75. {
  76. IsLayoutAlign = false;
  77. IsLayoutAvgAlign = false;
  78. }
  79. }
  80. }
  81. }
  82. public bool IsNavigationTarget(NavigationContext navigationContext) { return true; }
  83. public event EventHandler ClearCheckedAglin;
  84. public void OnNavigatedFrom(NavigationContext navigationContext)
  85. {
  86. ClearCheckedAglin?.Invoke(null, null);
  87. }
  88. }
  89. }