AnnotToolContentViewModel.Properties.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. using ComPDFKitViewer;
  2. using ComPDFKitViewer.AnnotEvent;
  3. using ComPDFKitViewer.PdfViewer;
  4. using PDF_Master.CustomControl;
  5. using PDF_Master.Helper;
  6. using PDF_Master.ViewModels.PropertyPanel.AnnotPanel;
  7. using PDF_Master.ViewModels.Tools.AnnotManager;
  8. using PDF_Master.Views.PropertyPanel.AnnotPanel;
  9. using PDFSettings;
  10. using Prism.Commands;
  11. using Prism.Events;
  12. using Prism.Regions;
  13. using Prism.Services.Dialogs;
  14. using System;
  15. using System.Collections.Generic;
  16. using System.Windows.Media;
  17. namespace PDF_Master.ViewModels.Tools
  18. {
  19. public sealed partial class AnnotToolContentViewModel
  20. {
  21. #region 属性
  22. #region 注释工具
  23. //高亮
  24. private Brush highLightColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  25. public Brush HighLightColor
  26. { get { return highLightColor; } set { SetProperty(ref highLightColor, value); } }
  27. //
  28. private double highLightOpacity = 1;
  29. public double HighLightOpacity
  30. { get { return highLightOpacity; } set { SetProperty(ref highLightOpacity, value); } }
  31. //
  32. private Brush underLine = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  33. public Brush UnderLineColor
  34. { get { return underLine; } set { SetProperty(ref underLine, value); } }
  35. //
  36. private double underLineOpacity = 1;
  37. public double UnderLineOpacity
  38. { get { return underLineOpacity; } set { SetProperty(ref underLineOpacity, value); } }
  39. //
  40. private Brush squigglyColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  41. public Brush SquigglyColor
  42. { get { return squigglyColor; } set { SetProperty(ref squigglyColor, value); } }
  43. //
  44. private double squigglyOpacity = 1;
  45. public double SquigglyOpacity
  46. { get { return squigglyOpacity; } set { SetProperty(ref squigglyOpacity, value); } }
  47. //
  48. private Brush strikeoutColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  49. public Brush StrikeoutColor
  50. { get { return strikeoutColor; } set { SetProperty(ref strikeoutColor, value); } }
  51. //
  52. private double strikeoutOpacity = 1;
  53. public double StrikeoutOpacity
  54. { get { return strikeoutOpacity; } set { SetProperty(ref strikeoutOpacity, value); } }
  55. private Brush freeHandColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  56. public Brush FreeHandColor
  57. {
  58. get { return freeHandColor; }
  59. set
  60. {
  61. SetProperty(ref freeHandColor, value);
  62. }
  63. }
  64. private Brush textAnnoteColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  65. public Brush TextAnnoteColor
  66. {
  67. get { return textAnnoteColor; }
  68. set
  69. {
  70. SetProperty(ref textAnnoteColor, value);
  71. }
  72. }
  73. private Brush rectangleBorderColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  74. public Brush RectangleBorderColor
  75. {
  76. get { return rectangleBorderColor; }
  77. set
  78. {
  79. SetProperty(ref rectangleBorderColor, value);
  80. }
  81. }
  82. private Brush rectangleFillColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  83. public Brush RectangleFillColor
  84. {
  85. get { return rectangleFillColor; }
  86. set
  87. {
  88. SetProperty(ref rectangleFillColor, value);
  89. }
  90. }
  91. private Brush circleBorderColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  92. public Brush CircleBorderColor
  93. {
  94. get { return circleBorderColor; }
  95. set
  96. {
  97. SetProperty(ref circleBorderColor, value);
  98. }
  99. }
  100. private Brush circleFillColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  101. public Brush CircleFillColor
  102. {
  103. get { return circleFillColor; }
  104. set
  105. {
  106. SetProperty(ref circleFillColor, value);
  107. }
  108. }
  109. private Brush lineColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  110. public Brush LineColor
  111. {
  112. get { return lineColor; }
  113. set
  114. {
  115. SetProperty(ref lineColor, value);
  116. }
  117. }
  118. private Brush arrowColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  119. public Brush ArrowColor
  120. {
  121. get { return arrowColor; }
  122. set
  123. {
  124. SetProperty(ref arrowColor, value);
  125. }
  126. }
  127. private bool btnSelecttoolIsChecked = false;
  128. public bool BtnSelecttoolIsChecked
  129. {
  130. get { return btnSelecttoolIsChecked; }
  131. set
  132. {
  133. SetProperty(ref btnSelecttoolIsChecked, value);
  134. }
  135. }
  136. private bool btnLinkIsChecked = false;
  137. public bool BtnLinkIsChecked
  138. {
  139. get { return btnLinkIsChecked; }
  140. set
  141. {
  142. SetProperty(ref btnLinkIsChecked, value);
  143. }
  144. }
  145. private bool btnHandIsChecked = false;
  146. public bool BtnHandIsChecked
  147. {
  148. get { return btnHandIsChecked; }
  149. set
  150. {
  151. SetProperty(ref btnHandIsChecked, value);
  152. }
  153. }
  154. private bool btnShowAnnotIsChecked = true;
  155. public bool BtnShowAnnotIsChecked
  156. {
  157. get { return btnShowAnnotIsChecked; }
  158. set
  159. {
  160. SetProperty(ref btnShowAnnotIsChecked, value);
  161. }
  162. }
  163. private string _strAnnotToolChecked = "";
  164. public string StrAnnotToolChecked
  165. {
  166. get { return _strAnnotToolChecked; }
  167. set
  168. {
  169. SetProperty(ref _strAnnotToolChecked, value);
  170. }
  171. }
  172. #endregion 注释工具
  173. #endregion 属性
  174. // 填写与签名图案名字链表
  175. private List<string> ShapeNames = new List<string>();
  176. // 是否处于打印
  177. private bool IsPasteShape = false;
  178. //判断注释是否在拖拉创建中
  179. public bool IsCreateAnnot = false;
  180. //判断是否选中图片
  181. public bool IsSelectImage = false;
  182. public string PropertyRegionName { get; set; }
  183. private IEventAggregator events;
  184. public IDialogService dialogs;
  185. public IRegionManager region;
  186. public OpenFileInfo OpenFileInfo = null;
  187. public CPDFViewer PDFViewer;
  188. public ViewContentViewModel ViewContentViewModel { get; set; }
  189. public AnnotTransfer PropertyPanel = new AnnotTransfer();
  190. private Dictionary<string, AnnotArgsType> ToolExpandDict = new Dictionary<string, AnnotArgsType>();
  191. private Dictionary<string, string> ToolTipDict = new Dictionary<string, string>();
  192. private StickyNotePopup customStickyPopup;
  193. private string Unicode = "";
  194. //private bool isHiddenAnnot = true;
  195. private bool isAddBookMark = true;
  196. /// <summary>
  197. /// 空白处-右键菜单-添加注释
  198. /// </summary>
  199. private bool IsNoSelectMenu = false;
  200. private bool isRightMenuAddAnnot = false;
  201. private PopMenu HightAnnotPopMenu;
  202. private PopMenu FreeHandAnnotPopMenu;
  203. private PopMenu FreeTextAnnotPopMenu;
  204. private PopMenu StrickNoteAnnotPopMenu;
  205. private PopMenu ShapeAnnotPopMenu;
  206. private PopMenu LinkAnnotPopMenu;
  207. private PopMenu StampAnnotPopMenu;
  208. private PopMenu MultiAnnotPopMenu;
  209. #region 事件
  210. public DelegateCommand<CustomIconToggleBtn> ShowOrHiddenAnnotCommand { get; set; }
  211. public DelegateCommand<CustomIconToggleBtn> MyToolsCommand { get; set; }
  212. private SnapshotEditMenuViewModel snapshotEditMenuViewModel = new SnapshotEditMenuViewModel();
  213. public SnapshotEditMenuViewModel SnapshotEditMenuViewModel { get => snapshotEditMenuViewModel; set => snapshotEditMenuViewModel = value; }
  214. public DelegateCommand<object> SetAddAnnotationCommand { get; set; }
  215. public DelegateCommand AddBookMarkCommand { get; set; }
  216. public DelegateCommand HandCommand { get; set; }
  217. #region 注释 - 右键菜单
  218. //公共
  219. public DelegateCommand<object> AnnotDefaultValue_MenuCommand { get; set; }
  220. public DelegateCommand<object> AnnotColorPalette_MenuCommand { get; set; }
  221. public DelegateCommand<object> AnnotAddNoteText_MenuCommand { get; set; }
  222. //高亮、下划线、删除
  223. public DelegateCommand<object> HightAnnotCopyText_MenuCommand { get; set; }
  224. //手绘
  225. public DelegateCommand<object> FreeHandLineStyle_MenuCommand { get; set; }
  226. //文本
  227. public DelegateCommand<object> FreeTextFontFamily_MenuCommand { get; set; }
  228. public DelegateCommand<object> FreeTextAglin_MenuCommand { get; set; }
  229. //便签
  230. public DelegateCommand<object> StrikeNoteEditStrike_MenuCommand { get; set; }
  231. //形状
  232. public DelegateCommand<object> ShapeLineStyle_MenuCommand { get; set; }
  233. public DelegateCommand<object> ShapeLineDirect_MenuCommand { get; set; }
  234. //图章
  235. public DelegateCommand<object> StampExportPicture_MenuCommand { get; set; }
  236. //链接
  237. public DelegateCommand<object> Link_MenuCommand { get; set; }
  238. #endregion 注释 - 右键菜单
  239. private void ViewContentViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  240. {
  241. if (e.PropertyName == "TabSelectedIndex")
  242. {
  243. //收起二级菜单栏时,退出注释工具,并清空属性面板
  244. var viewmodel = sender as ViewContentViewModel;
  245. if (viewmodel != null && viewmodel.ToolRowHeight == 40)
  246. {
  247. ExitAnnotationTool();
  248. //如果选中了内容选择工具时,需要单独取消选中(现有代码逻辑有问题)
  249. if (BtnSelecttoolIsChecked)
  250. {
  251. BtnSelecttoolIsChecked = false;
  252. }
  253. }
  254. }
  255. }
  256. #endregion 事件
  257. /// <summary>
  258. /// 注释列表选中注释
  259. /// </summary>
  260. private AnnotHandlerEventArgs selectedAnnotation = null;
  261. }
  262. public enum AddAnnotType
  263. {
  264. AnnotFreehand,//绘制
  265. AnnotFreeText = 1,//文本
  266. AnnotSticky,//便签
  267. AnnotSquare,//矩形
  268. AnnotCircle,//椭圆形
  269. AnnotArrow,//箭头
  270. AnnotLine,//直线
  271. AnnotLink,//链接
  272. AnnotStamp,//图章
  273. AnnotAutograph //签名
  274. }
  275. }