FormsToolContentViewModel.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using ComPDFKitViewer;
  2. using ComPDFKitViewer.AnnotEvent;
  3. using ComPDFKitViewer.PdfViewer;
  4. using PDF_Office.Model;
  5. using Prism.Commands;
  6. using Prism.Mvvm;
  7. using Prism.Regions;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows;
  14. namespace PDF_Office.ViewModels.Form
  15. {
  16. public class FormsToolContentViewModel : BindableBase, INavigationAware
  17. {
  18. private CPDFViewer PDFViewer;
  19. public ViewContentViewModel viewContentViewModel;
  20. private IRegionManager regions;
  21. /// <summary>
  22. /// 按钮和属性面板键值对
  23. /// </summary>
  24. private Dictionary<string, string> btnToProperty = new Dictionary<string, string>();
  25. private Visibility showPreView;
  26. /// <summary>
  27. /// 显示PreView按钮
  28. /// </summary>
  29. public Visibility ShowPreView
  30. {
  31. get { return showPreView; }
  32. set
  33. {
  34. SetProperty(ref showPreView, value);
  35. }
  36. }
  37. public DelegateCommand<string> CheckedCommand { get; set; }
  38. public FormsToolContentViewModel(IRegionManager regionManager)
  39. {
  40. regions = regionManager;
  41. CheckedCommand = new DelegateCommand<string>(CheckedEvent);
  42. InitBtnToProperty();
  43. }
  44. private void InitBtnToProperty()
  45. {
  46. btnToProperty.Add("Text", "TextFieldProperty");
  47. btnToProperty.Add("CheckBox", "CheckBoxProperty");
  48. btnToProperty.Add("RadioButton", "RadioButtonProperty");
  49. btnToProperty.Add("ListBox", "ListBoxProperty");
  50. btnToProperty.Add("Combox", "ComboxProperty");
  51. btnToProperty.Add("Button", "ButtonProperty");
  52. btnToProperty.Add("Sign", "SignProperty");
  53. }
  54. /// <summary>
  55. /// Form
  56. /// </summary>
  57. /// <param name="type"></param>
  58. private void CheckedEvent(string type)
  59. {
  60. AddToPropertyPanel(type);
  61. }
  62. private void AddToPropertyPanel(string type, WidgetArgs widget = null)
  63. {
  64. if (btnToProperty.ContainsKey(type))
  65. {
  66. NavigationParameters parameters = new NavigationParameters();
  67. parameters.Add(ParameterNames.PDFViewer, PDFViewer);
  68. parameters.Add("WidgetArgs", widget);
  69. regions.RequestNavigate(RegionNames.PropertyRegionName, btnToProperty[type], parameters);
  70. ShowPropertyPanel(true);
  71. }
  72. }
  73. #region 获取Form
  74. private void GetTextField()
  75. {
  76. }
  77. private void GetButton()
  78. {
  79. }
  80. private void GeCheckBox()
  81. {
  82. }
  83. private void GetCombox()
  84. {
  85. }
  86. private void GetListBox()
  87. {
  88. }
  89. private void GetRadioButton()
  90. {
  91. }
  92. private void GetSign()
  93. {
  94. }
  95. #endregion
  96. private void ShowPropertyPanel(bool show = true)
  97. {
  98. viewContentViewModel.IsPropertyOpen = show;
  99. }
  100. #region 表单内部触发的事件(比如选中表单行为等)
  101. private void PDFViewer_WidgetClickHander(object sender, WidgetArgs e)
  102. {
  103. }
  104. #endregion
  105. #region Navegation
  106. public bool IsNavigationTarget(NavigationContext navigationContext)
  107. {
  108. return true;
  109. }
  110. public void OnNavigatedFrom(NavigationContext navigationContext)
  111. {
  112. }
  113. public void OnNavigatedTo(NavigationContext navigationContext)
  114. {
  115. navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel,out viewContentViewModel);
  116. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  117. BindingFormHandler();
  118. }
  119. private void BindingFormHandler()
  120. {
  121. if(PDFViewer != null)
  122. {
  123. PDFViewer.WidgetClickHander -= PDFViewer_WidgetClickHander;
  124. PDFViewer.WidgetClickHander += PDFViewer_WidgetClickHander;
  125. }
  126. }
  127. #endregion
  128. }
  129. }