AnnotToolContentViewModel.Properties.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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. //是否为多选
  73. public bool IsMultiSelected { get { return (annotlists != null && annotlists.Count > 1); } }
  74. /// <summary>
  75. /// 更新多个属性,触发到工具栏注释工具,改变工具图标下的颜色值
  76. /// </summary>
  77. public void InvokeToMyTools(object sender, Dictionary<AnnotArgsType, object> keyValues)
  78. {
  79. DataChanged?.Invoke(sender, keyValues);
  80. }
  81. /// <summary>
  82. /// 更新单个属性
  83. /// </summary>
  84. public void InvokeToMyTools(AnnotArgsType argsType, object obj)
  85. {
  86. Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
  87. changeData[argsType] = obj;
  88. DataChanged?.Invoke(null, changeData);
  89. }
  90. //同一属性面板,切换注释工具
  91. public void AnnotTypeChangedInvoke(object sender, Dictionary<AnnotArgsType, object> keyValues)
  92. {
  93. AnnotTypeChanged?.Invoke(sender, keyValues);
  94. }
  95. }
  96. public sealed partial class AnnotToolContentViewModel
  97. {
  98. #region 属性
  99. #region 注释工具
  100. //高亮
  101. private Brush highLightColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  102. public Brush HighLightColor
  103. { get { return highLightColor; } set { SetProperty(ref highLightColor, value); } }
  104. //
  105. private double highLightOpacity = 1;
  106. public double HighLightOpacity
  107. { get { return highLightOpacity; } set { SetProperty(ref highLightOpacity, value); } }
  108. //
  109. private Brush underLine = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  110. public Brush UnderLineColor
  111. { get { return underLine; } set { SetProperty(ref underLine, value); } }
  112. //
  113. private double underLineOpacity = 1;
  114. public double UnderLineOpacity
  115. { get { return underLineOpacity; } set { SetProperty(ref underLineOpacity, value); } }
  116. //
  117. private Brush squigglyColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  118. public Brush SquigglyColor
  119. { get { return squigglyColor; } set { SetProperty(ref squigglyColor, value); } }
  120. //
  121. private double squigglyOpacity = 1;
  122. public double SquigglyOpacity
  123. { get { return squigglyOpacity; } set { SetProperty(ref squigglyOpacity, value); } }
  124. //
  125. private Brush strikeoutColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  126. public Brush StrikeoutColor
  127. { get { return strikeoutColor; } set { SetProperty(ref strikeoutColor, value); } }
  128. //
  129. private double strikeoutOpacity = 1;
  130. public double StrikeoutOpacity
  131. { get { return strikeoutOpacity; } set { SetProperty(ref strikeoutOpacity, value); } }
  132. private bool btnSelecttoolIsChecked = false;
  133. public bool BtnSelecttoolIsChecked
  134. {
  135. get { return btnSelecttoolIsChecked; }
  136. set
  137. {
  138. SetProperty(ref btnSelecttoolIsChecked, value);
  139. }
  140. }
  141. private bool btnLinkIsChecked = false;
  142. public bool BtnLinkIsChecked
  143. {
  144. get { return btnLinkIsChecked; }
  145. set
  146. {
  147. SetProperty(ref btnLinkIsChecked, value);
  148. }
  149. }
  150. private bool btnHandIsChecked = false;
  151. public bool BtnHandIsChecked
  152. {
  153. get { return btnHandIsChecked; }
  154. set
  155. {
  156. SetProperty(ref btnHandIsChecked, value);
  157. }
  158. }
  159. #endregion 注释工具
  160. #endregion 属性
  161. public string PropertyRegionName { get; set; }
  162. private IEventAggregator events;
  163. public IDialogService dialogs;
  164. public IRegionManager region;
  165. private CPDFViewer PDFViewer;
  166. private ViewContentViewModel viewContentViewModel;
  167. private AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
  168. private Dictionary<string, AnnotArgsType> ToolExpandDict = new Dictionary<string, AnnotArgsType>();
  169. private bool isHiddenAnnot = true;
  170. private bool isAddBookMark = true;
  171. private bool isRightMenuAddAnnot = false;
  172. #region 事件
  173. public DelegateCommand<CustomIconToggleBtn> MyToolsCommand { get; set; }
  174. private SnapshotEditMenuViewModel snapshotEditMenuViewModel = new SnapshotEditMenuViewModel();
  175. public SnapshotEditMenuViewModel SnapshotEditMenuViewModel { get => snapshotEditMenuViewModel; set => snapshotEditMenuViewModel = value; }
  176. public DelegateCommand<object> SetAddAnnotationCommand { get; set; }
  177. #endregion 事件
  178. }
  179. public enum AddAnnotType
  180. {
  181. AnnotFreehand,//绘制
  182. AnnotFreeText = 1,//文本
  183. AnnotSticky,//便签
  184. AnnotSquare,//矩形
  185. AnnotCircle,//椭圆形
  186. AnnotArrow,//箭头
  187. AnnotLine,//直线
  188. AnnotLink,//链接
  189. AnnotStamp,//图章
  190. AnnotAutograph //签名
  191. }
  192. }