AnnotToolContentViewModel.Properties.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. using ComPDFKitViewer;
  2. using ComPDFKitViewer.AnnotEvent;
  3. using ComPDFKitViewer.PdfViewer;
  4. using PDF_Office.CustomControl;
  5. using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
  6. using Prism.Commands;
  7. using Prism.Events;
  8. using Prism.Regions;
  9. using Prism.Services.Dialogs;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using System.Windows.Media;
  16. namespace PDF_Office.ViewModels.Tools
  17. {
  18. /// <summary>
  19. /// 改变工具栏注释属性值,主要用来传参数:注释属性和同步工具栏对应图标的属性(颜色)
  20. /// </summary>
  21. public class AnnotPropertyPanel
  22. {
  23. public AnnotAttribEvent AnnotEvent { get; set; }
  24. public List<AnnotAttribEvent> AnnotEvents = new List<AnnotAttribEvent>();
  25. public AnnotHandlerEventArgs annot;
  26. public List<AnnotHandlerEventArgs> annotlists;
  27. public event EventHandler<Dictionary<AnnotArgsType, object>> DataChanged;
  28. public event EventHandler<Dictionary<AnnotArgsType, object>> AnnotTypeChanged;
  29. public event EventHandler<object> DefaultStored;
  30. public AnnotPropertyPanel()
  31. { }
  32. //单个属性更改
  33. public void UpdateAnnotAAttrib(AnnotAttrib annotAttrib, object obj)
  34. {
  35. if (annotlists != null && annotlists.Count > 1)
  36. {
  37. foreach (var itemevent in AnnotEvents)
  38. {
  39. itemevent?.UpdateAttrib(annotAttrib, obj);
  40. itemevent?.UpdateAnnot();
  41. }
  42. }
  43. else
  44. {
  45. AnnotEvent?.UpdateAttrib(annotAttrib, obj);
  46. AnnotEvent?.UpdateAnnot();
  47. }
  48. }
  49. //多个属性更改
  50. public void UpdateAnnotAllAttribs(Dictionary<AnnotAttrib, object> AnnotAttribDir)
  51. {
  52. if (annotlists != null && annotlists.Count > 1)
  53. {
  54. foreach (var itemevent in AnnotEvents)
  55. {
  56. foreach (var item in AnnotAttribDir)
  57. {
  58. itemevent?.UpdateAttrib(item.Key, item.Value);
  59. }
  60. itemevent?.UpdateAnnot();
  61. }
  62. }
  63. else
  64. {
  65. foreach (var item in AnnotAttribDir)
  66. {
  67. AnnotEvent?.UpdateAttrib(item.Key, item.Value);
  68. }
  69. AnnotEvent?.UpdateAnnot();
  70. }
  71. }
  72. /// <summary>
  73. /// 更新多个属性,触发到工具栏注释工具,改变工具图标下的颜色值
  74. /// </summary>
  75. public void InvokeToMyTools(object sender, Dictionary<AnnotArgsType, object> keyValues)
  76. {
  77. DataChanged?.Invoke(sender, keyValues);
  78. }
  79. /// <summary>
  80. /// 更新单个属性
  81. /// </summary>
  82. public void InvokeToMyTools(AnnotArgsType argsType, object obj)
  83. {
  84. Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
  85. changeData[argsType] = obj;
  86. DataChanged?.Invoke(null, changeData);
  87. }
  88. //同一属性面板,切换注释工具
  89. public void AnnotTypeChangedInvoke(object sender, Dictionary<AnnotArgsType, object> keyValues)
  90. {
  91. AnnotTypeChanged?.Invoke(sender, keyValues);
  92. }
  93. }
  94. public sealed partial class AnnotToolContentViewModel
  95. {
  96. #region 属性
  97. #region 注释工具
  98. //高亮
  99. private Brush highLightColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  100. public Brush HighLightColor
  101. { get { return highLightColor; } set { SetProperty(ref highLightColor, value); } }
  102. //
  103. private double highLightOpacity = 1;
  104. public double HighLightOpacity
  105. { get { return highLightOpacity; } set { SetProperty(ref highLightOpacity, value); } }
  106. //
  107. private Brush underLine = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  108. public Brush UnderLineColor
  109. { get { return underLine; } set { SetProperty(ref underLine, value); } }
  110. //
  111. private double underLineOpacity = 1;
  112. public double UnderLineOpacity
  113. { get { return underLineOpacity; } set { SetProperty(ref underLineOpacity, value); } }
  114. //
  115. private Brush squigglyColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  116. public Brush SquigglyColor
  117. { get { return squigglyColor; } set { SetProperty(ref squigglyColor, value); } }
  118. //
  119. private double squigglyOpacity = 1;
  120. public double SquigglyOpacity
  121. { get { return squigglyOpacity; } set { SetProperty(ref squigglyOpacity, value); } }
  122. //
  123. private Brush strikeoutColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  124. public Brush StrikeoutColor
  125. { get { return strikeoutColor; } set { SetProperty(ref strikeoutColor, value); } }
  126. //
  127. private double strikeoutOpacity = 1;
  128. public double StrikeoutOpacity
  129. { get { return strikeoutOpacity; } set { SetProperty(ref strikeoutOpacity, value); } }
  130. private bool btnSelecttoolIsChecked = false;
  131. public bool BtnSelecttoolIsChecked
  132. {
  133. get { return btnSelecttoolIsChecked; }
  134. set
  135. {
  136. SetProperty(ref btnSelecttoolIsChecked, value);
  137. }
  138. }
  139. private bool btnLinkIsChecked = false;
  140. public bool BtnLinkIsChecked
  141. {
  142. get { return btnLinkIsChecked; }
  143. set
  144. {
  145. SetProperty(ref btnLinkIsChecked, value);
  146. }
  147. }
  148. private bool btnHandIsChecked = false;
  149. public bool BtnHandIsChecked
  150. {
  151. get { return btnHandIsChecked; }
  152. set
  153. {
  154. SetProperty(ref btnHandIsChecked, value);
  155. }
  156. }
  157. #endregion 注释工具
  158. #endregion 属性
  159. public string PropertyRegionName { get; set; }
  160. private IEventAggregator events;
  161. public IDialogService dialogs;
  162. public IRegionManager region;
  163. private CPDFViewer PDFViewer;
  164. private ViewContentViewModel viewContentViewModel;
  165. private AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
  166. private Dictionary<string, AnnotArgsType> ToolExpandDict = new Dictionary<string, AnnotArgsType>();
  167. private bool isHiddenAnnot = true;
  168. private bool isAddBookMark = true;
  169. private bool isRightMenuAddAnnot = false;
  170. #region 事件
  171. public DelegateCommand<CustomIconToggleBtn> MyToolsCommand { get; set; }
  172. private SnapshotEditMenuViewModel snapshotEditMenuViewModel = new SnapshotEditMenuViewModel();
  173. public SnapshotEditMenuViewModel SnapshotEditMenuViewModel { get => snapshotEditMenuViewModel; set => snapshotEditMenuViewModel = value; }
  174. public DelegateCommand<object> SetAddAnnotationCommand { get; set; }
  175. #endregion 事件
  176. }
  177. public enum AddAnnotType
  178. {
  179. AnnotFreehand,//绘制
  180. AnnotFreeText = 1,//文本
  181. AnnotSticky,//便签
  182. AnnotSquare,//矩形
  183. AnnotCircle,//椭圆形
  184. AnnotArrow,//箭头
  185. AnnotLine,//直线
  186. AnnotLink,//链接
  187. AnnotStamp,//图章
  188. AnnotAutograph //签名
  189. }
  190. }