AnnotCommon.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. using ComPDFKitViewer.AnnotEvent;
  2. using PDF_Office.CustomControl.CompositeControl;
  3. using Prism.Mvvm;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Media;
  10. namespace PDF_Office.Model.AnnotPanel
  11. {
  12. //注释的通用属性
  13. public class AnnotCommon : BindableBase
  14. {
  15. //注释类型
  16. private AnnotArgsType _annotType;
  17. public AnnotArgsType AnnotType
  18. {
  19. get { return _annotType; }
  20. set => SetProperty(ref _annotType, value);
  21. }
  22. //注释类型名称
  23. private string _annotTypeTitle;
  24. public string AnnotTypeTitle
  25. {
  26. get { return _annotTypeTitle; }
  27. set => SetProperty(ref _annotTypeTitle, value);
  28. }
  29. #region 线条
  30. //线条粗细大小
  31. private double _annotThickness = 1;
  32. public double AnnotThickness
  33. {
  34. get { return _annotThickness; }
  35. set => SetProperty(ref _annotThickness, value);
  36. }
  37. //线条样式
  38. private DashStyle dash = new DashStyle();
  39. public DashStyle Dash
  40. {
  41. get { return dash; }
  42. set => SetProperty(ref dash, value);
  43. }
  44. #endregion 线条
  45. #region 填充
  46. //填充颜色透明度
  47. private double fillOpacity = 1;
  48. public double FillOpacity
  49. {
  50. get { return fillOpacity; }
  51. set => SetProperty(ref fillOpacity, value);
  52. }
  53. //当前填充颜色
  54. private Brush _currentFillColor = new SolidColorBrush(Colors.Transparent);
  55. public Brush CurrentFillColor
  56. {
  57. get { return _currentFillColor; }
  58. set => SetProperty(ref _currentFillColor, value);
  59. }
  60. //填充颜色
  61. private Brush fillColor = new SolidColorBrush(Colors.Transparent);
  62. public Brush FillColor
  63. {
  64. get { return fillColor; }
  65. set { SetProperty(ref fillColor, value); CurrentFillColor = fillColor; }
  66. }
  67. //边框颜色集合
  68. private List<ColorItem> _colorItems = new List<ColorItem>();
  69. public List<ColorItem> ColorItems
  70. {
  71. get { return _colorItems; }
  72. set => SetProperty(ref _colorItems, value);
  73. }
  74. //填充颜色集合
  75. private List<ColorItem> _fillColorItems = new List<ColorItem>();
  76. public List<ColorItem> FillColorItems
  77. {
  78. get { return _fillColorItems; }
  79. set => SetProperty(ref _fillColorItems, value);
  80. }
  81. #endregion 填充
  82. #region 边框
  83. //边框颜色透明度
  84. private double _borderOpacity = 1;
  85. public double BorderOpacity
  86. {
  87. get { return _borderOpacity; }
  88. set => SetProperty(ref _borderOpacity, value);
  89. }
  90. private Brush _borderColor = new SolidColorBrush(Colors.Transparent);
  91. public Brush BorderColor
  92. {
  93. get { return _borderColor; }
  94. set { SetProperty(ref _borderColor, value); CurrentBorderColor = _borderColor; }
  95. }
  96. //当前边框颜色
  97. private Brush _currentBorderColor = new SolidColorBrush(Colors.Transparent);
  98. public Brush CurrentBorderColor
  99. {
  100. get { return _currentBorderColor; }
  101. set => SetProperty(ref _currentBorderColor, value);
  102. }
  103. private Brush _fontColor = new SolidColorBrush(Colors.Transparent);
  104. public Brush FontColor
  105. {
  106. get { return _fontColor; }
  107. set { SetProperty(ref _fontColor, value); CurrentFontColor = _fontColor; }
  108. }
  109. //当前边框颜色
  110. private Brush _currentFontColor = new SolidColorBrush(Colors.Transparent);
  111. public Brush CurrentFontColor
  112. {
  113. get { return _currentFontColor; }
  114. set => SetProperty(ref _currentFontColor, value);
  115. }
  116. //外部UI引用,判断是否选中实线、虚线、或都不选中
  117. public string strDashStyle { get; private set; }
  118. //VM赋值
  119. public void SetStrDashStyle(string str)
  120. {
  121. strDashStyle = str;
  122. }
  123. //外部UI引用,其他:例如形状注释类型
  124. public string strOtherTag { get; private set; }
  125. //VM赋值
  126. public void SetOtherTag(string str)
  127. {
  128. strOtherTag = str;
  129. }
  130. #endregion
  131. #region 多选
  132. //多选注释:用处 - 多选注释使得下拉框为空内容,刷新最新的UI布局
  133. private bool _isMultiSelected = false;
  134. public bool IsMultiSelected
  135. {
  136. get { return _isMultiSelected; }
  137. set => SetProperty(ref _isMultiSelected, value);
  138. }
  139. #endregion
  140. /// <summary>
  141. /// VM触发到外部UI事件
  142. /// </summary>
  143. public event EventHandler<object> SelectedAnnotInvokeToUI;
  144. //Todo:由于考虑到有些UI在VM不太方便处理,因此需要触发该函数到外部xaml.cs里更改UI属性。
  145. //更改多个属性:value可为键值对集合
  146. //适应范围:若VM在Loaded进行绑定,需要UI初始化之后,才能起到作用
  147. public void InvokeToUI(object sender, object value)
  148. {
  149. SelectedAnnotInvokeToUI?.Invoke(sender, value);
  150. }
  151. }
  152. //注释的通用颜色集合
  153. public class AnnotColorList
  154. {
  155. //用于高亮注释颜色
  156. public static List<ColorItem> GetHighlightColorList()
  157. {
  158. List<ColorItem> HighlightItems = new List<ColorItem>();
  159. HighlightItems = new List<ColorItem>();
  160. ColorItem colorItem = new ColorItem(Color.FromArgb(0xff, 0xff, 0xC7, 0x00));
  161. HighlightItems.Add(colorItem);
  162. colorItem = new ColorItem(Color.FromArgb(0xff, 0xFC, 0x1F, 0x1F));
  163. HighlightItems.Add(colorItem);
  164. colorItem = new ColorItem(Color.FromArgb(0xff, 0x3E, 0xED, 0x92));
  165. HighlightItems.Add(colorItem);
  166. colorItem = new ColorItem(Color.FromArgb(0xff, 0x47, 0xC8, 0xFF));
  167. HighlightItems.Add(colorItem);
  168. return HighlightItems;
  169. }
  170. //用于边框颜色
  171. public static List<ColorItem> GetBorderColorList()
  172. {
  173. List<ColorItem> BorderItems = new List<ColorItem>();
  174. BorderItems = new List<ColorItem>();
  175. ColorItem colorItem = new ColorItem(Color.FromArgb(0xff, 0xFC, 0x1F, 0x1F));
  176. BorderItems.Add(colorItem);
  177. colorItem = new ColorItem(Color.FromArgb(0xff, 0x29, 0x53, 0x93));
  178. BorderItems.Add(colorItem);
  179. colorItem = new ColorItem(Color.FromArgb(0xff, 0x1E, 0x89, 0x56));
  180. BorderItems.Add(colorItem);
  181. colorItem = new ColorItem(Color.FromArgb(0xff, 0xB8, 0x08, 0xD4));
  182. BorderItems.Add(colorItem);
  183. return BorderItems;
  184. }
  185. //用于填充颜色
  186. public static List<ColorItem> GetFillColorList()
  187. {
  188. List<ColorItem> FillItems = new List<ColorItem>();
  189. FillItems = new List<ColorItem>();
  190. ColorItem colorItem = new ColorItem(Colors.Transparent);
  191. FillItems.Add(colorItem);
  192. colorItem = new ColorItem(Color.FromArgb(0xff, 0xff, 0xff, 0xff));
  193. FillItems.Add(colorItem);
  194. colorItem = new ColorItem(Color.FromArgb(0xff, 0xDF, 0xE1, 0xE4));
  195. FillItems.Add(colorItem);
  196. colorItem = new ColorItem(Color.FromArgb(0xff, 0xFF, 0xF1, 0xC1));
  197. FillItems.Add(colorItem);
  198. return FillItems;
  199. }
  200. //用于注释样式颜色:如便签样式颜色
  201. public static List<ColorItem> GetStyleColorList()
  202. {
  203. List<ColorItem> StyleItems = new List<ColorItem>();
  204. StyleItems = new List<ColorItem>();
  205. ColorItem colorItem = new ColorItem(Color.FromArgb(0xff, 0xff, 0xD5, 0x73));
  206. StyleItems.Add(colorItem);
  207. colorItem = new ColorItem(Color.FromArgb(0xff, 0xF8, 0x59, 0xC8));
  208. StyleItems.Add(colorItem);
  209. colorItem = new ColorItem(Color.FromArgb(0xff, 0x1A, 0xD5, 0x98));
  210. StyleItems.Add(colorItem);
  211. colorItem = new ColorItem(Color.FromArgb(0xff, 0x68, 0xAC, 0xF8));
  212. StyleItems.Add(colorItem);
  213. return StyleItems;
  214. }
  215. }
  216. }