ListBoxPropertyViewModel.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. using ComPDFKitViewer.AnnotEvent;
  2. using ComPDFKitViewer.PdfViewer;
  3. using PDF_Office.Helper;
  4. using PDF_Office.Model;
  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. using System.Windows.Media;
  13. namespace PDF_Office.ViewModels.Form
  14. {
  15. public class ListBoxPropertyViewModel : FormBaseVM, INavigationAware
  16. {
  17. #region 属性
  18. #region 选项
  19. //排序项目
  20. private bool _isSortProject = false;
  21. public bool IsSortProject
  22. {
  23. get { return _isSortProject; }
  24. set { SetProperty(ref _isSortProject, value); }
  25. }
  26. //多重选择的
  27. private bool _multipleSelection = false;
  28. public bool MultipleSelection
  29. {
  30. get { return _multipleSelection; }
  31. set { SetProperty(ref _multipleSelection, value); }
  32. }
  33. #endregion
  34. #endregion
  35. #region Command
  36. #endregion
  37. #region 变量
  38. private CPDFViewer PDFViewer;
  39. private WidgetListBoxArgs listBoxArgs;
  40. public UpdateAttributeHelper AttribEvent;
  41. #endregion
  42. #region 初始化
  43. public ListBoxPropertyViewModel()
  44. {
  45. InitVariable();
  46. InitCommand();
  47. }
  48. private void InitVariable()
  49. {
  50. ResetColorOne = new ResetColor()
  51. {
  52. BorderColor = new SolidColorBrush(Colors.Transparent),
  53. FontColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
  54. FillColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00))
  55. };
  56. ResetColorTwo = new ResetColor()
  57. {
  58. BorderColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
  59. FontColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
  60. FillColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00))
  61. };
  62. ResetColorThree = new ResetColor()
  63. {
  64. BorderColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
  65. FontColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
  66. FillColor = new SolidColorBrush(Color.FromArgb(0xFF, 0xBD, 0xDF, 0xFD))
  67. };
  68. ResetColorForth = new ResetColor()
  69. {
  70. BorderColor = new SolidColorBrush(Color.FromArgb(0xFF, 0xff, 0x00, 0x00)),
  71. FontColor = new SolidColorBrush(Color.FromArgb(0xFF, 0xff, 0x00, 0x00)),
  72. FillColor = new SolidColorBrush(Colors.Transparent)
  73. };
  74. }
  75. private void InitCommand()
  76. {
  77. ChangeValueHandler -= ChangeValue;
  78. ChangeValueHandler += ChangeValue;
  79. }
  80. #endregion
  81. #region 一般处理
  82. #endregion
  83. #region 外观处理
  84. #endregion
  85. #region 选项处理
  86. #endregion
  87. #region Navegation
  88. public bool IsNavigationTarget(NavigationContext navigationContext)
  89. {
  90. return true;
  91. }
  92. public void OnNavigatedFrom(NavigationContext navigationContext)
  93. {
  94. listBoxArgs = null;
  95. }
  96. public void OnNavigatedTo(NavigationContext navigationContext)
  97. {
  98. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  99. navigationContext.Parameters.TryGetValue<WidgetListBoxArgs>("WidgetArgs", out listBoxArgs);
  100. navigationContext.Parameters.TryGetValue<UpdateAttributeHelper>(ParameterNames.AnnotEvent, out AttribEvent);
  101. GetWidgeText();
  102. }
  103. private void GetWidgeText()
  104. {
  105. if (listBoxArgs == null)
  106. {
  107. PDFViewer.SetMouseMode(MouseModes.FormEditTool);
  108. listBoxArgs = new WidgetListBoxArgs();
  109. listBoxArgs.BgColor = Colors.White;
  110. listBoxArgs.FontFamily = "Courier New";
  111. listBoxArgs.FontSize = 12;
  112. listBoxArgs.FontColor = Colors.Black;
  113. listBoxArgs.LineColor = Colors.Black;
  114. listBoxArgs.LineWidth = 1;
  115. listBoxArgs.FieldName = "ListBox1";
  116. PDFViewer.SetToolParam(listBoxArgs);
  117. }
  118. else
  119. {
  120. PDFViewer.SetToolParam(new AnnotHandlerEventArgs());
  121. }
  122. }
  123. //更改基类公共属性后,触发的事件
  124. private void ChangeValue(object sender, FormAttributeType e)
  125. {
  126. switch (e)
  127. {
  128. case FormAttributeType.Name:
  129. break;
  130. case FormAttributeType.ToolTip:
  131. break;
  132. case FormAttributeType.IsSolid:
  133. break;
  134. case FormAttributeType.IsLocked:
  135. break;
  136. case FormAttributeType.HeightSize:
  137. break;
  138. case FormAttributeType.BorderThiness:
  139. break;
  140. case FormAttributeType.BorderColor:
  141. break;
  142. case FormAttributeType.ContentColor:
  143. break;
  144. case FormAttributeType.IsReadOnly:
  145. break;
  146. case FormAttributeType.WidthSize:
  147. break;
  148. case FormAttributeType.IsRequiredField:
  149. break;
  150. }
  151. }
  152. #endregion
  153. }
  154. }