CheckBoxPropertyViewModel.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. using ComPDFKit.PDFAnnotation;
  2. using ComPDFKit.PDFAnnotation.Form;
  3. using ComPDFKitViewer.AnnotEvent;
  4. using ComPDFKitViewer.PdfViewer;
  5. using PDF_Office.Model;
  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.Media;
  14. namespace PDF_Office.ViewModels.Form
  15. {
  16. public class CheckBoxPropertyViewModel : FormBaseVM, INavigationAware
  17. {
  18. #region 属性
  19. #region 选项
  20. //导出值
  21. private string _exportValue;
  22. public string ExportValue
  23. {
  24. get { return _exportValue; }
  25. set { SetProperty(ref _exportValue, value); }
  26. }
  27. //复选框默认为选中
  28. private bool _isDefaultChecked = false;
  29. public bool IsDefaultChecked
  30. {
  31. get { return _isDefaultChecked; }
  32. set { SetProperty(ref _isDefaultChecked, value); }
  33. }
  34. #endregion
  35. #endregion
  36. #region Command
  37. #endregion
  38. #region 变量
  39. private CPDFViewer PDFViewer;
  40. private WidgetCheckBoxArgs checkBoxArgs;
  41. private bool IsCurrentWidget = false;
  42. #endregion
  43. #region 初始化
  44. public CheckBoxPropertyViewModel()
  45. {
  46. InitVariable();
  47. InitCommand();
  48. }
  49. private void InitVariable()
  50. {
  51. }
  52. private void InitCommand()
  53. {
  54. ChangeValueHandler -= ChangeValue;
  55. ChangeValueHandler += ChangeValue;
  56. }
  57. #endregion
  58. #region 一般处理
  59. #endregion
  60. #region 外观处理
  61. #endregion
  62. #region 选项处理
  63. #endregion
  64. #region Navegation
  65. public bool IsNavigationTarget(NavigationContext navigationContext)
  66. {
  67. return true;
  68. }
  69. public void OnNavigatedFrom(NavigationContext navigationContext)
  70. {
  71. checkBoxArgs = null;
  72. }
  73. public void OnNavigatedTo(NavigationContext navigationContext)
  74. {
  75. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  76. navigationContext.Parameters.TryGetValue<WidgetCheckBoxArgs>("WidgetArgs", out checkBoxArgs);
  77. GetWidgeText();
  78. }
  79. private void GetWidgeText()
  80. {
  81. if (checkBoxArgs == null)
  82. {
  83. PDFViewer.SetMouseMode(MouseModes.FormEditTool);
  84. checkBoxArgs = new WidgetCheckBoxArgs();
  85. WidgetCheckBoxArgs args = new WidgetCheckBoxArgs();
  86. args.FieldName = "CheckBox1";
  87. args.CheckStyle = C_CHECK_STYLE.CK_CHECK;
  88. args.BorderStyle = C_BORDER_STYLE.BS_SOLID;
  89. args.LineColor = Colors.Black;
  90. args.BgColor = Colors.LightGreen;
  91. args.LineWidth = 1;
  92. checkBoxArgs = args;
  93. PDFViewer.SetToolParam(checkBoxArgs);
  94. }
  95. else
  96. {
  97. PDFViewer.SetToolParam(new AnnotHandlerEventArgs());
  98. }
  99. }
  100. //更改基类公共属性后,触发的事件
  101. private void ChangeValue(object sender, FormAttributeType e)
  102. {
  103. switch (e)
  104. {
  105. case FormAttributeType.Name:
  106. break;
  107. case FormAttributeType.ToolTip:
  108. break;
  109. case FormAttributeType.IsSolid:
  110. break;
  111. case FormAttributeType.IsLocked:
  112. break;
  113. case FormAttributeType.HeightSize:
  114. break;
  115. case FormAttributeType.BorderThiness:
  116. break;
  117. case FormAttributeType.BorderColor:
  118. break;
  119. case FormAttributeType.ContentColor:
  120. break;
  121. case FormAttributeType.IsReadOnly:
  122. break;
  123. case FormAttributeType.WidthSize:
  124. break;
  125. case FormAttributeType.IsRequiredField:
  126. break;
  127. }
  128. }
  129. #endregion
  130. }
  131. }