AnnotToolContentViewModel.Properties.cs 6.0 KB

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