RadioButtonPropertyViewModel.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. using ComPDFKitViewer.AnnotEvent;
  2. using ComPDFKitViewer.PdfViewer;
  3. using PDF_Office.Model;
  4. using Prism.Mvvm;
  5. using Prism.Regions;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Media;
  12. namespace PDF_Office.ViewModels.Form
  13. {
  14. public class RadioButtonPropertyViewModel : FormBaseVM, INavigationAware
  15. {
  16. #region 属性
  17. #region 选项
  18. //单选按钮选项
  19. private string _OptionContent;
  20. public string OptionContent
  21. {
  22. get { return _OptionContent; }
  23. set { SetProperty(ref _OptionContent, value); }
  24. }
  25. private bool _isDefaultChecked = false;
  26. public bool IsDefaultChecked
  27. {
  28. get { return _isDefaultChecked; }
  29. set { SetProperty(ref _isDefaultChecked, value); }
  30. }
  31. #endregion
  32. #endregion
  33. #region Command
  34. #endregion
  35. #region 变量
  36. private CPDFViewer PDFViewer;
  37. private WidgetRadioButtonArgs radioButtonArgs;
  38. #endregion
  39. #region 初始化
  40. public RadioButtonPropertyViewModel()
  41. {
  42. InitVariable();
  43. InitCommand();
  44. }
  45. private void InitVariable()
  46. {
  47. }
  48. private void InitCommand()
  49. {
  50. ChangeValueHandler -= ChangeValue;
  51. ChangeValueHandler += ChangeValue;
  52. }
  53. #endregion
  54. #region 一般处理
  55. #endregion
  56. #region 外观处理
  57. #endregion
  58. #region 选项处理
  59. #endregion
  60. #region Navegation
  61. public bool IsNavigationTarget(NavigationContext navigationContext)
  62. {
  63. return true;
  64. }
  65. public void OnNavigatedFrom(NavigationContext navigationContext)
  66. {
  67. radioButtonArgs = null;
  68. }
  69. public void OnNavigatedTo(NavigationContext navigationContext)
  70. {
  71. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  72. navigationContext.Parameters.TryGetValue<WidgetRadioButtonArgs>("WidgetArgs", out radioButtonArgs);
  73. GetWidgeText();
  74. }
  75. private void GetWidgeText()
  76. {
  77. PDFViewer.SetMouseMode(MouseModes.FormEditTool);
  78. if (radioButtonArgs == null)
  79. {
  80. radioButtonArgs = new WidgetRadioButtonArgs();
  81. radioButtonArgs.FieldName = NameStr;
  82. radioButtonArgs.BgColor = Colors.Transparent;
  83. radioButtonArgs.FontColor = Colors.Black;
  84. radioButtonArgs.LineColor = Colors.Black;
  85. radioButtonArgs.LineWidth = 1;
  86. PDFViewer.SetToolParam(radioButtonArgs);
  87. }
  88. else
  89. {
  90. PDFViewer.SetToolParam(new AnnotHandlerEventArgs());
  91. }
  92. }
  93. //更改基类公共属性后,触发的事件
  94. private void ChangeValue(object sender, FormAttributeType e)
  95. {
  96. switch (e)
  97. {
  98. case FormAttributeType.Name:
  99. break;
  100. case FormAttributeType.ToolTip:
  101. break;
  102. case FormAttributeType.IsSolid:
  103. break;
  104. case FormAttributeType.IsLocked:
  105. break;
  106. case FormAttributeType.HeightSize:
  107. break;
  108. case FormAttributeType.BorderThiness:
  109. break;
  110. case FormAttributeType.BorderColor:
  111. break;
  112. case FormAttributeType.ContentColor:
  113. break;
  114. case FormAttributeType.IsReadOnly:
  115. break;
  116. case FormAttributeType.WidthSize:
  117. break;
  118. case FormAttributeType.IsRequiredField:
  119. break;
  120. }
  121. }
  122. #endregion
  123. }
  124. }