AnnotToolContentViewModel.Command.cs 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710
  1. using ComPDFKit.Import;
  2. using ComPDFKit.PDFAnnotation;
  3. using ComPDFKit.PDFDocument;
  4. using ComPDFKit.PDFDocument.Action;
  5. using ComPDFKitViewer;
  6. using ComPDFKitViewer.AnnotEvent;
  7. using ComPDFKitViewer.PdfViewer;
  8. using PDF_Master.CustomControl;
  9. using PDF_Master.EventAggregators;
  10. using PDF_Master.Helper;
  11. using PDF_Master.Model.AnnotPanel;
  12. using PDF_Master.Model.FillAndSign;
  13. using PDF_Master.Properties;
  14. using PDF_Master.ViewModels.BOTA;
  15. using PDF_Master.ViewModels.PropertyPanel.AnnotPanel;
  16. using PDF_Master.ViewModels.Tools.AnnotManager;
  17. using PDF_Master.Views.BOTA;
  18. using PDFSettings;
  19. using Prism.Mvvm;
  20. using Prism.Regions;
  21. using System;
  22. using System.Collections.Generic;
  23. using System.Diagnostics;
  24. using System.Linq;
  25. using System.Windows;
  26. using System.Windows.Controls;
  27. using System.Windows.Controls.Primitives;
  28. using System.Windows.Input;
  29. using System.Windows.Markup;
  30. using System.Windows.Media;
  31. namespace PDF_Master.ViewModels.Tools
  32. {
  33. public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
  34. {
  35. #region 事件绑定和解绑
  36. private void BindingEvent()
  37. {
  38. //属性面板与注释工具栏绑定:属性面板的属性变化,会同步注释工具栏的属性值
  39. //比如在属性面板里更改注释颜色,会同时更新工具栏对应的工具颜色
  40. PropertyPanel.DataChanged -= AnnotPropertyPanel_DataChanged;
  41. PropertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
  42. PropertyPanel.AnnotTypeChanged -= AnnotPropertyPanel_AnnotTypeChanged;
  43. PropertyPanel.AnnotTypeChanged += AnnotPropertyPanel_AnnotTypeChanged;
  44. //快捷键
  45. KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
  46. KeyEventsHelper.KeyDown += ShortCut_KeyDown;
  47. }
  48. private void UnBindingEvent()
  49. {
  50. PropertyPanel.DataChanged -= AnnotPropertyPanel_DataChanged;
  51. PropertyPanel.AnnotTypeChanged -= AnnotPropertyPanel_AnnotTypeChanged;
  52. //快捷盘解绑
  53. KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
  54. }
  55. private void BindingPDFViewerHandler()
  56. {
  57. //来自PDFViewer的响应事件
  58. if (PDFViewer != null)
  59. {
  60. PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
  61. PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
  62. PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
  63. PDFViewer.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
  64. PDFViewer.AnnotCommandHandler -= PDFViewer_AnnotCommandHandler;
  65. PDFViewer.AnnotCommandHandler += PDFViewer_AnnotCommandHandler;
  66. PDFViewer.SnapshotCommandHandler -= PDFViewer_SnapshotCommandHandler;
  67. PDFViewer.SnapshotCommandHandler += PDFViewer_SnapshotCommandHandler;
  68. PDFViewer.PDFActionHandler -= PDFViewer_PDFActionHandler;
  69. PDFViewer.PDFActionHandler += PDFViewer_PDFActionHandler;
  70. PDFViewer.AnnotHoverHandler -= PDFViewer_AnnotHoverHandler;
  71. PDFViewer.AnnotHoverHandler += PDFViewer_AnnotHoverHandler;
  72. PDFViewer.PreviewMouseLeftButtonDown -= PDFViewer_PreviewMouseLeftButtonDown;
  73. PDFViewer.PreviewMouseLeftButtonDown += PDFViewer_PreviewMouseLeftButtonDown;
  74. CommandManager.AddPreviewExecutedHandler(PDFViewer, PreviewExcutePDFViewer);
  75. }
  76. }
  77. //判断
  78. private void PreviewExcutePDFViewer(object sender, ExecutedRoutedEventArgs e)
  79. {
  80. if (e.Command == ApplicationCommands.Paste)
  81. {
  82. IsPasteShape = true;
  83. ShapeNames.Clear();
  84. Trace.WriteLine("几次" + 1);
  85. var items = PDFViewer.GetCopyAnnotData();
  86. foreach (var item in items)
  87. {
  88. bool IsShape = false;
  89. if (item is FreehandAnnotArgs)
  90. {
  91. foreach (var point in viewContentViewModel.FillAndSign)
  92. {
  93. if ((item as FreehandAnnotArgs).PageIndex == point.PageIndex && (item as FreehandAnnotArgs).AnnotIndex == point.AnnotIndex)
  94. {
  95. ShapeNames.Add(point.Shape);
  96. Trace.WriteLine("woshi什么" + point.Shape);
  97. IsShape = true;
  98. continue;
  99. }
  100. }
  101. if (!IsShape)
  102. {
  103. ShapeNames.Add("Annot");
  104. Trace.WriteLine("woshi什么" + "Freehand");
  105. }
  106. }
  107. else
  108. {
  109. ShapeNames.Add("Annot");
  110. }
  111. }
  112. }
  113. if (e.Command == ApplicationCommands.Copy)
  114. {
  115. }
  116. }
  117. private void UnBindingPDFViewerHandler()
  118. {
  119. if (PDFViewer != null)
  120. {
  121. PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
  122. PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
  123. PDFViewer.AnnotCommandHandler -= PDFViewer_AnnotCommandHandler;
  124. PDFViewer.SnapshotCommandHandler -= PDFViewer_SnapshotCommandHandler;
  125. PDFViewer.PDFActionHandler -= PDFViewer_PDFActionHandler;
  126. PDFViewer.AnnotHoverHandler -= PDFViewer_AnnotHoverHandler;
  127. PDFViewer.PreviewMouseLeftButtonDown -= PDFViewer_PreviewMouseLeftButtonDown;
  128. }
  129. }
  130. #endregion 事件绑定和解绑
  131. #region 与触发事件调用相关的函数
  132. //鼠标左键双击注释
  133. private void PDFViewer_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  134. {
  135. if (e.ClickCount == 1)
  136. {
  137. //不禁止取消选中注释
  138. PDFViewer.DisableClearSelectAnnot(false);
  139. //PropertyPanel.IsSharpAnnotSelected = true;
  140. //PropertyPanel.IsFreeHandSelected = true;
  141. //PDFViewer.ClearSelectAnnots();
  142. //BOTA所有列表都需要响应 单击阅读页取消多选
  143. if (viewContentViewModel.OpenBOTA == true)
  144. {
  145. this.events.GetEvent<CleanSelectAllEvent>().Publish(new CleanSelectAllArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, IsCleanSelectAll = true });
  146. }
  147. }
  148. if (e.ClickCount == 2)
  149. {
  150. if (CurrentSelectedAnnot != null)
  151. {
  152. var type = CurrentSelectedAnnot.EventType;
  153. if (type != AnnotArgsType.AnnotSticky && type != AnnotArgsType.AnnotFreeText &&
  154. type != AnnotArgsType.AnnotHighlight && type != AnnotArgsType.AnnotUnderline
  155. && type != AnnotArgsType.AnnotStrikeout && type != AnnotArgsType.AnnotLink)
  156. {
  157. int dpi = DpiHelpers.Dpi;
  158. var rect = CurrentSelectedAnnot.ClientRect;
  159. rect = new Rect(
  160. rect.Left * PDFViewer.ZoomFactor,
  161. rect.Top * PDFViewer.ZoomFactor,
  162. rect.Width * PDFViewer.ZoomFactor,
  163. rect.Height * PDFViewer.ZoomFactor);
  164. var ui = PDFViewer.Parent as ContentControl;
  165. if (ui != null)
  166. {
  167. var point = e.GetPosition(ui);
  168. int pageIndex = 0;
  169. Point pagePoint = new Point(0, 0);
  170. PDFViewer.ConvertViewPointToPage(point, out pageIndex, out pagePoint);
  171. if (pagePoint.X >= rect.Left && pagePoint.X <= rect.Right && pagePoint.Y >= rect.Top && pagePoint.Y <= rect.Bottom)
  172. PopAnnotNoteText(CurrentSelectedAnnot);
  173. }
  174. }
  175. if (type == AnnotArgsType.AnnotSticky)
  176. {
  177. (CurrentSelectedAnnot as StickyAnnotArgs).PopupEditWnd();
  178. }
  179. }
  180. }
  181. }
  182. //超链接跳转
  183. private void PDFViewer_PDFActionHandler(object sender, ComPDFKit.PDFDocument.Action.CPDFAction action)
  184. {
  185. if (action == null)
  186. {
  187. return;
  188. }
  189. switch (action.ActionType)
  190. {
  191. case C_ACTION_TYPE.ACTION_TYPE_GOTO:
  192. if (PDFViewer != null)
  193. {
  194. CPDFGoToAction gotoAction = action as CPDFGoToAction;
  195. CPDFDestination dest = gotoAction.GetDestination(PDFViewer.Document);
  196. if (dest != null)
  197. {
  198. PDFViewer.GoToPage(dest.PageIndex, new System.Windows.Point(0, 0));
  199. }
  200. }
  201. break;
  202. case C_ACTION_TYPE.ACTION_TYPE_URI:
  203. {
  204. CPDFUriAction uriAction = action as CPDFUriAction;
  205. string uri = uriAction.GetUri();
  206. try
  207. {
  208. if (!string.IsNullOrEmpty(uri))
  209. {
  210. Process.Start(uri);
  211. }
  212. }
  213. catch (Exception ex)
  214. {
  215. }
  216. }
  217. break;
  218. }
  219. }
  220. private void GetSelectedAnnots(AnnotAttribEvent e)
  221. {
  222. var annot = e.AnnotItemsList[0];
  223. switch (annot.EventType)
  224. {
  225. case AnnotArgsType.AnnotHighlight:
  226. GetHighLight(e.AnnotItemsList);
  227. break;
  228. case AnnotArgsType.AnnotUnderline:
  229. GetUnderLine(e.AnnotItemsList);
  230. break;
  231. case AnnotArgsType.AnnotStrikeout:
  232. GetStrikeout(e.AnnotItemsList);
  233. break;
  234. case AnnotArgsType.AnnotSquiggly:
  235. GetSquiggly(e.AnnotItemsList);
  236. break;
  237. case AnnotArgsType.AnnotFreehand:
  238. GetFreehand(e.AnnotItemsList);
  239. break;
  240. case AnnotArgsType.AnnotFreeText:
  241. GetFreetext(e.AnnotItemsList);
  242. break;
  243. case AnnotArgsType.AnnotSquare:
  244. GetRect(e.AnnotItemsList);
  245. break;
  246. case AnnotArgsType.AnnotCircle:
  247. GetCircle(e.AnnotItemsList);
  248. break;
  249. case AnnotArgsType.AnnotLine:
  250. bool isLine = true;
  251. if (e.Attribs.ContainsKey(AnnotAttrib.LineStart))
  252. {
  253. if ((C_LINE_TYPE)e.Attribs[AnnotAttrib.LineStart] != C_LINE_TYPE.LINETYPE_UNKNOWN && (C_LINE_TYPE)e.Attribs[AnnotAttrib.LineStart] != C_LINE_TYPE.LINETYPE_NONE)
  254. {
  255. isLine = false;
  256. }
  257. }
  258. if (e.Attribs.ContainsKey(AnnotAttrib.LineEnd))
  259. {
  260. if ((C_LINE_TYPE)e.Attribs[AnnotAttrib.LineEnd] != C_LINE_TYPE.LINETYPE_UNKNOWN && (C_LINE_TYPE)e.Attribs[AnnotAttrib.LineEnd] != C_LINE_TYPE.LINETYPE_NONE)
  261. {
  262. isLine = false;
  263. }
  264. }
  265. if (isLine)
  266. GetArrowLine("Line", e.AnnotItemsList);
  267. else
  268. GetArrowLine("Arrow", e.AnnotItemsList);
  269. break;
  270. case AnnotArgsType.AnnotLink:
  271. //viewContentViewModel.IsCreateLink = false;
  272. //e.IsAnnotCreateReset= true;
  273. if (StrAnnotToolChecked == "Link")
  274. {
  275. PropertyPanel.IsAddLink = false;
  276. }
  277. GetLink(e.AnnotItemsList, e);
  278. break;
  279. case AnnotArgsType.AnnotSticky:
  280. GetStickyNote(e.AnnotItemsList);
  281. customStickyPopup.GetCurrentAnnot = e.AnnotItemsList[0] as StickyAnnotArgs;
  282. customStickyPopup.GetPDFViewer = PDFViewer;
  283. if (e.IsAnnotCreateReset)
  284. {
  285. PropertyPanel.annot = e.AnnotItemsList[0];
  286. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  287. PropertyPanel.AnnotEvents = null;
  288. PropertyPanel.AnnotEvent = AnnotEvent;
  289. PropertyPanel.annotlists = e.AnnotItemsList;
  290. }
  291. break;
  292. case AnnotArgsType.AnnotStamp:
  293. if (e.IsAnnotCreateReset == false)
  294. {
  295. GetStamp();
  296. }
  297. break;
  298. }
  299. }
  300. /// <summary>
  301. /// 选中注释 区分签名、图章、手绘
  302. /// </summary>
  303. /// <param name="annotlist"></param>
  304. private void SelectedSignature(List<AnnotHandlerEventArgs> annotlist)
  305. {
  306. if (annotlist == null || annotlist.Count == 0)
  307. return;
  308. var annot = annotlist[0];
  309. if (annot.EventType != AnnotArgsType.AnnotStamp && annot.EventType != AnnotArgsType.AnnotFreehand)
  310. return;
  311. if (annot.PageIndex < 0 || annot.AnnotIndex < 0)
  312. return;
  313. var signAnnot = viewContentViewModel.AnnotSignatures.FirstOrDefault(temp => temp.Item1 == annot.PageIndex && temp.Item2 == annot.AnnotIndex);
  314. if (signAnnot == null)
  315. {
  316. //var key = ToolExpandDict.FirstOrDefault(q => q.Value == annot.EventType);
  317. //if (!string.IsNullOrEmpty(StrAnnotToolChecked))
  318. // StrAnnotToolChecked = key.Key.ToString();
  319. //if (annot.EventType == AnnotArgsType.AnnotStamp)
  320. //{
  321. // StrAnnotToolChecked = "Stamp";
  322. //}
  323. //else
  324. //{
  325. // StrAnnotToolChecked = "";
  326. //}
  327. }
  328. else
  329. {
  330. if (string.IsNullOrEmpty(StrAnnotToolChecked))
  331. {
  332. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  333. //GetSignature();
  334. //StrAnnotToolChecked = "Signature";
  335. }
  336. }
  337. }
  338. private void AddAnnotSignature(AnnotHandlerEventArgs annot)
  339. {
  340. if ((annot.EventType != AnnotArgsType.AnnotStamp && annot.EventType != AnnotArgsType.AnnotFreehand) ||
  341. (annot.PageIndex < 0 || annot.AnnotIndex < 0)) return;
  342. if (StrAnnotToolChecked == "Signature")
  343. {
  344. if (viewContentViewModel.AnnotSignatures == null)
  345. viewContentViewModel.AnnotSignatures = new List<Tuple<int, int>>();
  346. var signAnnot = viewContentViewModel.AnnotSignatures.FirstOrDefault(temp => temp.Item1 == annot.PageIndex && temp.Item2 == annot.AnnotIndex);
  347. if (signAnnot == null)
  348. {
  349. viewContentViewModel.AnnotSignatures.Add(new Tuple<int, int>(annot.PageIndex, annot.AnnotIndex));
  350. }
  351. }
  352. }
  353. #endregion 与触发事件调用相关的函数
  354. #region PDFViewer事件
  355. private AnnotHandlerEventArgs CurrentSelectedAnnot = null;
  356. //选中和非选中注释
  357. private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
  358. {
  359. CurrentSelectedAnnot = null;
  360. if (viewContentViewModel.CurrentBar != "TabItemAnnotation")
  361. {
  362. //viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  363. return;
  364. }
  365. if (e == null)
  366. {
  367. //PDFViewer.DisableClearSelectAnnot(false);
  368. //PropertyPanel.IsSharpAnnotSelected = true;
  369. //PropertyPanel.IsFreeHandSelected = true;
  370. if (string.IsNullOrWhiteSpace(StrAnnotToolChecked))
  371. {
  372. //PDFViewer.ClearSelectAnnots();
  373. PropertyPanel.annot = null;
  374. PropertyPanel.AnnotEvents = null;
  375. PropertyPanel.AnnotEvent = null;
  376. PropertyPanel.annotlists = null;
  377. if (PropertyPanel.IsAddLink == false)
  378. {
  379. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  380. }
  381. //PDFViewer.SetMouseMode(MouseModes.PanTool);
  382. //HandToolIsCheckedEvent(false);
  383. return;
  384. }
  385. else
  386. {
  387. if (StrAnnotToolChecked != "Stamp" && StrAnnotToolChecked != "Freetext")
  388. {
  389. AnnotHandlerEventArgs annotArgs = null;
  390. //此处不能用这个方法更新创建注释的属性 会导致死循环
  391. // FindAnnotTypeKey(StrAnnotToolChecked, ref annotArgs);
  392. return;
  393. }
  394. return;
  395. }
  396. }
  397. if (e != null)
  398. {
  399. if (e.IsMouseRightActive)
  400. {
  401. if (string.IsNullOrEmpty(StrAnnotToolChecked))
  402. {
  403. ShowPropertyPanel(false);
  404. return;
  405. }
  406. }
  407. var annot = e.AnnotItemsList[0];
  408. if (annot != null)
  409. {
  410. if (e.AnnotItemsList.Count == 1)
  411. {
  412. //IsAnnotCreateReset:是否为创建注释的状态
  413. if (e.IsAnnotCreateReset == false)
  414. {
  415. CurrentSelectedAnnot = annot;
  416. //未选注释工具-形状注释,选中形状注释,属性面板不显示(矩形、圆、线、箭头)
  417. if (StrAnnotToolChecked != "Rect"
  418. && (annot.EventType == AnnotArgsType.AnnotSquare ||
  419. annot.EventType == AnnotArgsType.AnnotCircle ||
  420. annot.EventType == AnnotArgsType.AnnotLine))
  421. {
  422. PropertyPanel.IsSharpAnnotSelected = false;
  423. }
  424. else
  425. {
  426. PropertyPanel.IsSharpAnnotSelected = true;
  427. }
  428. if (StrAnnotToolChecked != "Freehand" && annot.EventType == AnnotArgsType.AnnotFreehand)
  429. {
  430. PropertyPanel.IsFreeHandSelected = false;
  431. }
  432. else
  433. {
  434. PropertyPanel.IsFreeHandSelected = true;
  435. }
  436. GetSelectedAnnots(e);
  437. SelectedSignature(e.AnnotItemsList);
  438. if (Settings.Default.AppProperties.InitialVIew.AutoExpandProperty
  439. && annot.EventType != AnnotArgsType.AnnotStamp && StrAnnotToolChecked != "Signature"
  440. && annot.EventType != AnnotArgsType.AnnotLink)
  441. {
  442. var signAnnot = viewContentViewModel.AnnotSignatures.FirstOrDefault(temp => temp.Item1 == annot.PageIndex && temp.Item2 == annot.AnnotIndex);
  443. if (signAnnot == null)
  444. {
  445. ShowPropertyPanel(true);
  446. }
  447. }
  448. if (StrAnnotToolChecked == "Signature")
  449. {
  450. GetSignature();
  451. }
  452. //注释列表同步选中
  453. SelectedBotaAnnotationList(e);
  454. }
  455. else
  456. {
  457. if (!string.IsNullOrEmpty(StrAnnotToolChecked)|| PropertyPanel.IsAddLink==true)
  458. {
  459. GetSelectedAnnots(e);
  460. PDFViewer.SetToolParam(annot);
  461. }
  462. else
  463. {
  464. if (IsNoSelectMenu)
  465. {
  466. return;
  467. }
  468. PropertyPanel.annot = null;
  469. PropertyPanel.AnnotEvents = null;
  470. PropertyPanel.AnnotEvent = null;
  471. PropertyPanel.annotlists = null;
  472. PDFViewer.SetMouseMode(MouseModes.PanTool);
  473. HandToolIsCheckedEvent(false);
  474. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  475. }
  476. //switch (annot.EventType)
  477. //{
  478. // case AnnotArgsType.AnnotFreeText:
  479. // annot = GetFreetext(e.AnnotItemsList);
  480. // PDFViewer.SetToolParam(annot);
  481. // break;
  482. // case AnnotArgsType.AnnotSticky:
  483. // customStickyPopup.GetCurrentAnnot = e.AnnotItemsList[0] as StickyAnnotArgs;
  484. // customStickyPopup.GetPDFViewer = PDFViewer;
  485. // propertyPanel.annot = e.AnnotItemsList[0];
  486. // var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  487. // propertyPanel.AnnotEvents = null;
  488. // propertyPanel.AnnotEvent = AnnotEvent;
  489. // propertyPanel.annotlists = e.AnnotItemsList;
  490. // break;
  491. // case AnnotArgsType.AnnotLink:
  492. // //viewContentViewModel.IsCreateLink = false;
  493. // GetLink(e.AnnotItemsList, e);
  494. // PDFViewer.SetToolParam(annot);
  495. // break;
  496. //}
  497. #region //TODO: 修改注释后,会作用到之后添加的注释中。因此先把此逻辑“创建注释后,会自动回到默认值”注释掉
  498. //注释代码原因:设计已经重新调整逻辑:所有注释创建后,编辑属性,所有属性会作用于下次创建的注释中。
  499. //if (annot.EventType != AnnotArgsType.AnnotStrikeout &&
  500. //annot.EventType != AnnotArgsType.AnnotUnderline &&
  501. //annot.EventType != AnnotArgsType.AnnotHighlight &&
  502. //annot.EventType != AnnotArgsType.AnnotSquiggly &&
  503. //annot.EventType != AnnotArgsType.AnnotLink &&
  504. //annot.EventType != AnnotArgsType.AnnotFreehand &&
  505. //annot.EventType != AnnotArgsType.AnnotSticky &&
  506. //)
  507. //{
  508. // if (ToolExpandDict.ContainsValue(e.AnnotItemsList[0].EventType))
  509. // {
  510. // var strLineAnnotTag = "";
  511. // if (e.AnnotItemsList[0] is LineAnnotArgs)
  512. // {
  513. // var lineAnnot = e.AnnotItemsList[0] as LineAnnotArgs;
  514. // if (lineAnnot.HeadLineType == C_LINE_TYPE.LINETYPE_NONE && lineAnnot.TailLineType == C_LINE_TYPE.LINETYPE_NONE)
  515. // {
  516. // strLineAnnotTag = "Line";
  517. // }
  518. // else
  519. // {
  520. // strLineAnnotTag = "Arrow";
  521. // }
  522. // }
  523. // foreach (var item in ToolExpandDict)
  524. // {
  525. // if (item.Value == e.AnnotItemsList[0].EventType)
  526. // {
  527. // annot = null;//新建注释时,回到默认值
  528. // if (string.IsNullOrEmpty(strLineAnnotTag))
  529. // {
  530. // FindAnnotTypeKey(item.Key, ref annot);
  531. // break;
  532. // }
  533. // else
  534. // {
  535. // if (strLineAnnotTag == item.Key)
  536. // {
  537. // FindAnnotTypeKey(item.Key, ref annot);
  538. // break;
  539. // }
  540. // }
  541. // }
  542. // }
  543. // PDFViewer.SetToolParam(annot);
  544. // }
  545. //}
  546. //设计重新调整,阅读页空白处,右键菜单,添加链接需要显示,其他和pro mac一样的效果,不显示属性栏
  547. //if (isRightMenuAddAnnot && annot.EventType!=AnnotArgsType.AnnotLink)
  548. //{
  549. // ShowPropertyPanel(false);
  550. //}
  551. //else
  552. //{
  553. // ShowPropertyPanel();
  554. //}
  555. #endregion //TODO: 修改注释后,会作用到之后添加的注释中。因此先把此逻辑“创建注释后,会自动回到默认值”注释掉
  556. }
  557. }
  558. else
  559. {
  560. //框选注释
  561. PropertyPanel.annotlists = e.AnnotItemsList;
  562. bool isDifferentAnnotTyle = AnnotTransfer.IsDifferentTypeAnnots(e.AnnotItemsList);
  563. if (isDifferentAnnotTyle)
  564. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  565. else
  566. GetSelectedAnnots(e);
  567. }
  568. }
  569. }
  570. }
  571. /// <summary>
  572. /// 注释列表同步选中
  573. /// </summary>
  574. /// <param name="e"></param>
  575. private void SelectedBotaAnnotationList(AnnotAttribEvent e)
  576. {
  577. var list = e.GetPageAnnotsIndex();
  578. bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  579. //if (viewContentViewModel.OpenBOTA == false || isTabItemAnnotation == false || bOTAContent.TabItemAnnotation.IsSelected == false)
  580. //{
  581. // viewContentViewModel.OpenBOTA = true;
  582. // bOTAContent.TabItemAnnotation.IsSelected = true;
  583. //}
  584. if (viewContentViewModel.OpenBOTA == true && isTabItemAnnotation == true /*&& bOTAContent.TabItemAnnotation.IsSelected == true*/ && list != null && list.Count > 0)
  585. {
  586. if (list.Keys.Count == 0)
  587. {
  588. return;
  589. }
  590. var pageindex = new List<int>(list.Keys);
  591. List<int> annotes = new List<int>();
  592. list.TryGetValue(pageindex[0], out annotes);
  593. int annoteindex = annotes[0];
  594. AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
  595. if (viewModel != null)
  596. {
  597. viewModel.ScrollToAnnot(pageindex[0], annoteindex, annotation.AnnotationList);
  598. }
  599. }
  600. }
  601. //在注释工具的状态下,右键菜单
  602. private void PDFViewer_AnnotCommandHandler(object sender, AnnotCommandArgs e)
  603. {
  604. if (e.AnnotEventArgsList == null || (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool))
  605. return;
  606. if ((UIElement)sender != null)
  607. {
  608. //绑定命令执行前的拦截事件,对于未解密权限的文档进行复制限制
  609. CommandManager.AddPreviewExecutedHandler((UIElement)sender, PreviewExcute);
  610. }
  611. switch (e.CommandType)
  612. {
  613. case CommandType.Context:
  614. if (e.AnnotEventArgsList.Count > 0)
  615. {
  616. if (App.mainWindowViewModel.SelectedItem.IsInReadctonMode && e.AnnotEventArgsList[0].EventType == AnnotArgsType.AnnotRedaction)
  617. {
  618. //绑定标记密文处右键菜单
  619. events.GetEvent<RedactionCommandEvent>().Publish(new RedactionCommandEventArgs() { UniCode = App.mainWindowViewModel.SelectedItem.Unicode, Sender = sender, args = e });
  620. }
  621. else
  622. {
  623. if (e.AnnotEventArgsList.Count == 1)
  624. {
  625. var selectedAnnot = e.AnnotEventArgsList[0];
  626. PopMenuCheckedLineDash(selectedAnnot);
  627. PopMenuCheckedFontFamily(selectedAnnot);
  628. PopMenuCheckedTextAglin(selectedAnnot);
  629. switch (selectedAnnot.EventType)
  630. {
  631. case AnnotArgsType.AnnotHighlight:
  632. case AnnotArgsType.AnnotUnderline:
  633. case AnnotArgsType.AnnotStrikeout:
  634. case AnnotArgsType.AnnotSquiggly:
  635. if (selectedAnnot.EventType == AnnotArgsType.AnnotHighlight)
  636. {
  637. colorContent.ItemSource = AnnotColorList.GetColorList(ColorSelectorType.Highlight);
  638. }
  639. else
  640. {
  641. colorContent.ItemSource = AnnotColorList.GetColorList(ColorSelectorType.Border);
  642. }
  643. e.PopupMenu = HightAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  644. break;
  645. case AnnotArgsType.AnnotFreehand:
  646. e.PopupMenu = FreeHandAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  647. break;
  648. case AnnotArgsType.AnnotFreeText:
  649. e.PopupMenu = FreeTextAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  650. break;
  651. case AnnotArgsType.AnnotSticky:
  652. e.PopupMenu = StrickNoteAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  653. break;
  654. case AnnotArgsType.AnnotSquare:
  655. case AnnotArgsType.AnnotCircle:
  656. ShapeAnnotPopMenu.SetVisual("ShapeDirect", false);
  657. ShapeAnnotPopMenu.SetVisual("ShapeFillColor", true);
  658. e.PopupMenu = ShapeAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  659. break;
  660. case AnnotArgsType.AnnotLine:
  661. ShapeAnnotPopMenu.SetVisual("ShapeFillColor", false);
  662. ShapeAnnotPopMenu.SetVisual("ShapeDirect", true);
  663. e.PopupMenu = ShapeAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  664. break;
  665. case AnnotArgsType.AnnotLink:
  666. e.PopupMenu = LinkAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  667. break;
  668. case AnnotArgsType.AnnotStamp:
  669. e.PopupMenu = StampAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  670. break;
  671. }
  672. }
  673. else
  674. {
  675. bool isHigh = true;//是否为高亮
  676. foreach (var item in e.AnnotEventArgsList)
  677. {
  678. if (AnnotTransfer.IsHightAnnot(item) == false)
  679. {
  680. isHigh = false;
  681. break;
  682. }
  683. }
  684. MultiAnnotPopMenu.SetVisual("MultiCopy", !isHigh);
  685. MultiAnnotPopMenu.SetVisual("MultiCut", !isHigh);
  686. e.PopupMenu = MultiAnnotPopMenu.OpenMenu(e.AnnotEventArgsList, sender);
  687. }
  688. }
  689. if (e.PopupMenu != null)
  690. {
  691. e.Handle = true;
  692. }
  693. }
  694. else
  695. {
  696. if (e.PressOnSelectedText || e.CommandTarget == TargetType.ImageSelection)
  697. {
  698. e.PopupMenu = SelectedTextOrImageContextMenu(sender, e);
  699. if (e.PopupMenu != null)
  700. {
  701. e.Handle = true;
  702. }
  703. }
  704. else
  705. {
  706. e.PopupMenu = ViewerContextMenu(sender);
  707. if (e.PopupMenu != null)
  708. {
  709. e.Handle = true;
  710. }
  711. }
  712. }
  713. break;
  714. }
  715. }
  716. private void PreviewExcute(object sender, ExecutedRoutedEventArgs e)
  717. {
  718. if (e.Command == ApplicationCommands.Copy)
  719. {
  720. VerifyPasswordResult result = SecurityHelper.VerifyPasswordForSelectedPermissions(PDFViewer.Document, Model.Dialog.ToolsDialogs.SaftyDialogs.EnumPermissionsSet.StatusAllowsCopying, dialogs);
  721. if (result.IsDiscryptied)
  722. {
  723. if (result.Password != null)
  724. {
  725. string filePath = PDFViewer.Document.FilePath;
  726. var unlockresult = PDFViewer.Document.CheckOwnerPassword(result.Password);
  727. }
  728. }
  729. else
  730. {
  731. e.Handled = true;
  732. }
  733. }
  734. }
  735. /// <summary>
  736. /// 右键菜单,选中字体样式按钮状态
  737. /// </summary>
  738. /// <param name="annot"></param>
  739. private void PopMenuCheckedFontFamily(AnnotHandlerEventArgs annot)
  740. {
  741. if (annot != null)
  742. {
  743. if (annot.EventType == AnnotArgsType.AnnotFreeText)
  744. {
  745. var freeText = annot as FreeTextAnnotArgs;
  746. string fontFamily = freeText.FontFamily.ToString();
  747. if (fontFamily == "Arial")
  748. {
  749. fontFamily = "Helvetica";
  750. }
  751. if (fontFamily == "Courier New")
  752. {
  753. fontFamily = "Courier";
  754. }
  755. if (fontFamily == "Times New Roman")
  756. {
  757. fontFamily = "Times";
  758. }
  759. FreeTextAnnotPopMenu.SetIsChecked(fontFamily, true);
  760. }
  761. }
  762. }
  763. /// <summary>
  764. /// 右键菜单,选中文本内容对齐按钮状态
  765. /// </summary>
  766. /// <param name="annot"></param>
  767. private void PopMenuCheckedTextAglin(AnnotHandlerEventArgs annot)
  768. {
  769. if (annot != null)
  770. {
  771. if (annot.EventType == AnnotArgsType.AnnotFreeText)
  772. {
  773. var freeText = annot as FreeTextAnnotArgs;
  774. switch (freeText.Align)
  775. {
  776. case TextAlignment.Left:
  777. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinLeft", true);
  778. break;
  779. case TextAlignment.Center:
  780. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinCenter", true);
  781. break;
  782. case TextAlignment.Right:
  783. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinRight", true);
  784. break;
  785. case TextAlignment.Justify:
  786. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinJustify", true);
  787. break;
  788. default:
  789. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinLeft", false);
  790. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinCenter", false);
  791. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinRight", false);
  792. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinJustify", false);
  793. break;
  794. }
  795. }
  796. }
  797. }
  798. //右键菜单,选中虚实线按钮状态
  799. private void PopMenuCheckedLineDash(AnnotHandlerEventArgs annot)
  800. {
  801. if (annot != null)
  802. {
  803. bool isSolidLineDash = true;
  804. if (annot.EventType == AnnotArgsType.AnnotFreehand)
  805. {
  806. var freeHand = annot as FreehandAnnotArgs;
  807. isSolidLineDash = AnnotTransfer.IsSolidStyle(freeHand.LineDash);
  808. FreeHandAnnotPopMenu.SetIsChecked(isSolidLineDash ? "FreeHandSolid" : "FreeHandDash", true);
  809. }
  810. else if (annot.EventType == AnnotArgsType.AnnotSquare)
  811. {
  812. var square = annot as SquareAnnotArgs;
  813. isSolidLineDash = AnnotTransfer.IsSolidStyle(square.LineDash);
  814. ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
  815. }
  816. else if (annot.EventType == AnnotArgsType.AnnotCircle)
  817. {
  818. var circle = annot as CircleAnnotArgs;
  819. isSolidLineDash = AnnotTransfer.IsSolidStyle(circle.LineDash);
  820. ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
  821. }
  822. else if (annot.EventType == AnnotArgsType.AnnotLine)
  823. {
  824. var line = annot as LineAnnotArgs;
  825. isSolidLineDash = AnnotTransfer.IsSolidStyle(line.LineDash);
  826. ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
  827. }
  828. }
  829. }
  830. /// <summary>
  831. /// 内容选择工具
  832. /// </summary>
  833. /// <param name="sender"></param>
  834. /// <param name="e"></param>
  835. private void PDFViewer_SnapshotCommandHandler(object sender, SnapshotCommandArgs e)
  836. {
  837. SnapshotEditToolArgs snapToolArgs=new SnapshotEditToolArgs ();
  838. if (PDFViewer.ToolManager.CurrentAnnotArgs is SnapshotEditToolArgs) {
  839. snapToolArgs = (SnapshotEditToolArgs)PDFViewer.ToolManager.CurrentAnnotArgs;
  840. }
  841. SnapshotEditMenuViewModel.SnapToolArgs = snapToolArgs;
  842. SnapshotEditMenuViewModel.PDFViewer = PDFViewer;
  843. SnapshotEditMenuViewModel.areaCropPageUndoManager = new AreaCropPageUndoManager(PDFViewer);
  844. SnapshotEditMenuViewModel.SnapToolEvent -= SnapshotEditMenuViewModel_SnapToolEvent; ;
  845. SnapshotEditMenuViewModel.SnapToolEvent += SnapshotEditMenuViewModel_SnapToolEvent;
  846. var popMenu = App.Current.FindResource("SnapshotContextMenu") as ContextMenu;
  847. if (e.HitSnapshotTool && e.SnapshotRect.Width > 0 && e.SnapshotRect.Height > 0)
  848. {
  849. e.PopupMenu = popMenu;
  850. e.Handle = true;
  851. if (popMenu != null && popMenu.Items.Count == 5)
  852. {
  853. //复制
  854. MenuItem menuItem = popMenu.Items[0] as MenuItem;
  855. menuItem.CommandTarget = PDFViewer;
  856. menuItem.Command = SnapshotEditMenuViewModel.SnapCopyCommand;
  857. //导出
  858. menuItem = popMenu.Items[1] as MenuItem;
  859. menuItem.CommandTarget = PDFViewer;
  860. if (menuItem.Items.Count == 3)
  861. {
  862. MenuItem menuItem1 = menuItem.Items[0] as MenuItem;
  863. menuItem1.CommandTarget = PDFViewer;
  864. menuItem1.Command = SnapshotEditMenuViewModel.ExportPNGCommand;
  865. menuItem1 = menuItem.Items[1] as MenuItem;
  866. menuItem1.CommandTarget = PDFViewer;
  867. menuItem1.Command = SnapshotEditMenuViewModel.ExportJPGCommand;
  868. menuItem1 = menuItem.Items[2] as MenuItem;
  869. menuItem1.CommandTarget = PDFViewer;
  870. menuItem1.Command = SnapshotEditMenuViewModel.ExportPDFCommand;
  871. }
  872. //裁剪
  873. menuItem = popMenu.Items[2] as MenuItem;
  874. menuItem.CommandTarget = PDFViewer;
  875. menuItem.Command = SnapshotEditMenuViewModel.CroppingCommand;
  876. //缩放至所选区域
  877. menuItem = popMenu.Items[3] as MenuItem;
  878. menuItem.CommandTarget = PDFViewer;
  879. menuItem.Visibility = Visibility.Collapsed;
  880. //menuItem.Command = snapshotEditMenuViewModel.CroppingCommand;
  881. //打印
  882. menuItem = popMenu.Items[4] as MenuItem;
  883. menuItem.CommandTarget = PDFViewer;
  884. menuItem.Command = SnapshotEditMenuViewModel.PrintCommand;
  885. }
  886. }
  887. }
  888. private void SnapshotEditMenuViewModel_SnapToolEvent(object sender, KeyValuePair<string, object> e)
  889. {
  890. switch (e.Key)
  891. {
  892. case "CloseSnap":
  893. {
  894. #region to do
  895. //var item = PDFViewerTab.SelectedItem as TabItem;
  896. //if (item == null)
  897. //{
  898. // ClearSelectedToolPanel();
  899. // return;
  900. //}
  901. //Grid grid = item.Content as Grid;
  902. //if (grid == null || grid.Children.Count == 0)
  903. //{
  904. // ClearSelectedToolPanel();
  905. // return;
  906. //}
  907. //PDFViewerCtrl pdfViewer = grid.Children[0] as PDFViewerCtrl;
  908. //if (pdfViewer == null)
  909. //{
  910. // ClearSelectedToolPanel();
  911. // return;
  912. //}
  913. #endregion to do
  914. switch (PDFViewer.MouseMode)
  915. {
  916. case MouseModes.SelectTextTool:
  917. break;
  918. default:
  919. BtnSelecttoolIsChecked = false;
  920. //BtnHandIsChecked = true;
  921. PDFViewer.EnableZoom(true);
  922. PDFViewer.EnableScroll(true);
  923. PDFViewer.SetMouseMode(MouseModes.PanTool);
  924. break;
  925. }
  926. }
  927. break;
  928. default:
  929. break;
  930. }
  931. }
  932. private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
  933. {
  934. bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  935. AnnotationContentViewModel viewModel = null;
  936. AnnotationContent annotation = null;
  937. if (viewContentViewModel.OpenBOTA == true)
  938. {
  939. viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out annotation);
  940. }
  941. bool isMultiple = false;
  942. Dictionary<int, List<int>> selectAnnotDicts = new Dictionary<int, List<int>>();
  943. if (e != null && e.Count > 0)
  944. {
  945. for (int i = 0; i < e.Count; i++)
  946. {
  947. AnnotEditEvent editEvent = e[i];
  948. bool isVisible = PDFViewer.CheckAnnotVisible(editEvent.PageIndex, editEvent.AnnotIndex);
  949. var annot = editEvent.EditAnnotArgs;
  950. switch (editEvent.EditAction)
  951. {
  952. case ActionType.Add:
  953. #region 区分复制填写签名图形
  954. if (IsPasteShape)
  955. {
  956. if (editEvent.EditAnnotArgs.EventType == AnnotArgsType.AnnotFreehand)
  957. {
  958. if (ShapeNames.Count != 0 && ShapeNames[i] != "Annot")
  959. {
  960. try
  961. {
  962. viewContentViewModel.FillAndSign.Add(new FillAndSignIsShape(editEvent.PageIndex, editEvent.AnnotIndex, ShapeNames[i]));
  963. }
  964. catch { }
  965. }
  966. }
  967. }
  968. #endregion 区分复制填写签名图形
  969. if (viewContentViewModel.CurrentBar != "TabItemAnnotation")
  970. {
  971. //填写与签名在此区域不选中,不添加selectAnnotDicts词典当中
  972. }
  973. else
  974. {
  975. if (PropertyPanel.IsMultiSelected)
  976. {
  977. if (selectAnnotDicts.ContainsKey(editEvent.PageIndex) == false)
  978. {
  979. selectAnnotDicts.Add(editEvent.PageIndex, new List<int>());
  980. selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  981. }
  982. else
  983. {
  984. selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  985. }
  986. isMultiple = true;
  987. }
  988. else
  989. {
  990. if (annot.EventType == AnnotArgsType.AnnotSquare || annot.EventType == AnnotArgsType.AnnotCircle ||
  991. annot.EventType == AnnotArgsType.AnnotLine || annot.EventType == AnnotArgsType.AnnotStamp /*||
  992. annot.EventType == AnnotArgsType.AnnotSticky ||annot.EventType == AnnotArgsType.AnnotFreeText || annot.EventType == AnnotArgsType.AnnotFreehand*/)
  993. {
  994. if (selectAnnotDicts.ContainsKey(editEvent.PageIndex) == false)
  995. {
  996. selectAnnotDicts.Add(editEvent.PageIndex, new List<int>());
  997. selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  998. }
  999. else
  1000. {
  1001. selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1002. }
  1003. isMultiple = true;
  1004. }
  1005. }
  1006. }
  1007. if (viewModel != null)
  1008. {
  1009. int pageindex = editEvent.PageIndex;
  1010. int annotindex = editEvent.AnnotIndex;
  1011. viewModel.UpdateAddedAnnot(pageindex, annotindex);
  1012. }
  1013. //添加书签注释,用于未保存前跟图章手绘注释的区分
  1014. if (StrAnnotToolChecked == "Signature")
  1015. {
  1016. AddAnnotSignature(editEvent.EditAnnotArgs);
  1017. }
  1018. //if (editEvent.EditAnnotArgs.EventType == AnnotArgsType.AnnotFreeText)
  1019. //{
  1020. // (editEvent.EditAnnotArgs as FreeTextAnnotArgs).LineWidth = 0;
  1021. //}
  1022. break;
  1023. case ActionType.Modify:
  1024. if (string.IsNullOrEmpty(StrAnnotToolChecked) == false)
  1025. {
  1026. List<AnnotHandlerEventArgs> selectedArgs = new List<AnnotHandlerEventArgs>() { annot };
  1027. switch (annot.EventType)
  1028. {
  1029. case AnnotArgsType.AnnotFreeText://文本
  1030. GetFreetext(selectedArgs);
  1031. break;
  1032. }
  1033. }
  1034. if (viewModel != null)
  1035. {
  1036. int pageindex = editEvent.PageIndex;
  1037. int annotindex = editEvent.AnnotIndex;
  1038. viewModel.UpdateModifiedAnnot(pageindex, annotindex);
  1039. }
  1040. break;
  1041. case ActionType.Del:
  1042. //isTabItemAnnotation = IsBOTATabItemShow(out bOTAContentViewModel, out bOTAContent, "TabItemAnnotation");
  1043. //if (viewContentViewModel.OpenBOTA == true && bOTAContent.TabItemAnnotation.IsSelected)
  1044. //{
  1045. // AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
  1046. #region//填写与签名 删除缓存信息列表
  1047. //if (Shape != "None")
  1048. //{
  1049. for (int j = 0; j < viewContentViewModel.FillAndSign.Count; j++)
  1050. {
  1051. if (viewContentViewModel.FillAndSign[j].PageIndex == editEvent.PageIndex && viewContentViewModel.FillAndSign[j].AnnotIndex == editEvent.AnnotIndex)
  1052. {
  1053. viewContentViewModel.FillAndSign.Remove(viewContentViewModel.FillAndSign[j]);
  1054. }
  1055. }
  1056. for (int j = 0; j < viewContentViewModel.AnnotSignatures.Count; j++)
  1057. {
  1058. if (viewContentViewModel.AnnotSignatures[j].Item1 == editEvent.PageIndex && viewContentViewModel.AnnotSignatures[j].Item2 == editEvent.AnnotIndex)
  1059. {
  1060. viewContentViewModel.AnnotSignatures.Remove(viewContentViewModel.AnnotSignatures[j]);
  1061. }
  1062. }
  1063. //}
  1064. #endregion PDFViewer事件
  1065. if (viewModel != null)
  1066. {
  1067. int pageindex = editEvent.PageIndex;
  1068. int annotindex = editEvent.AnnotIndex;
  1069. viewModel.DeleteModifiedAnnot(pageindex, annotindex);
  1070. }
  1071. if(string.IsNullOrEmpty(StrAnnotToolChecked))
  1072. {
  1073. ExitAnnotationTool();
  1074. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  1075. }
  1076. else
  1077. {
  1078. switch (StrAnnotToolChecked)
  1079. {
  1080. case "Link":
  1081. PropertyPanel.IsAddLink = true;
  1082. GetLink();
  1083. break;
  1084. }
  1085. }
  1086. break;
  1087. case ActionType.TextEdit:
  1088. break;
  1089. default:
  1090. break;
  1091. }
  1092. }
  1093. IsPasteShape = false;
  1094. if (isMultiple && selectAnnotDicts.Count >= 1)
  1095. {
  1096. //PDFViewer.DisableClearSelectAnnot(false);
  1097. PDFViewer.ClearSelectAnnots();
  1098. if (StrAnnotToolChecked != "Signature")
  1099. {
  1100. //PDFViewer.DisableClearSelectAnnot(true);
  1101. PDFViewer.SelectAnnotation(selectAnnotDicts);
  1102. //禁止取消选中注释
  1103. //PDFViewer.DisableClearSelectAnnot(false);
  1104. }
  1105. }
  1106. //MultipleSelectionAnnot(e);
  1107. //空白处 右键菜单 添加注释 为单次添加,不连续添加
  1108. if (IsNoSelectMenu && PropertyPanel.IsAddLink == false)
  1109. {
  1110. IsNoSelectMenu = false;
  1111. PDFViewer.SetMouseMode(MouseModes.PanTool);
  1112. }
  1113. }
  1114. }
  1115. //复制多个注释,粘贴后,默认注释未选中状态
  1116. private void MultipleSelectionAnnot(List<AnnotEditEvent> e)
  1117. {
  1118. bool isAdd = false;
  1119. Dictionary<int, List<int>> selectAnnotDicts = new Dictionary<int, List<int>>();
  1120. foreach (var item in e)
  1121. {
  1122. if (item.EditAction == ActionType.Add || item.EditAction == ActionType.Modify)
  1123. {
  1124. var annot = item.EditAnnotArgs;
  1125. if (annot.EventType == AnnotArgsType.AnnotSquare || annot.EventType == AnnotArgsType.AnnotCircle ||
  1126. annot.EventType == AnnotArgsType.AnnotLine || annot.EventType == AnnotArgsType.AnnotStamp || annot.EventType == AnnotArgsType.AnnotFreeText || annot.EventType == AnnotArgsType.AnnotFreehand)
  1127. {
  1128. if (selectAnnotDicts.ContainsKey(item.PageIndex) == false)
  1129. {
  1130. selectAnnotDicts.Add(item.PageIndex, new List<int>());
  1131. selectAnnotDicts[item.PageIndex].Add(item.AnnotIndex);
  1132. }
  1133. else
  1134. {
  1135. selectAnnotDicts[item.PageIndex].Add(item.AnnotIndex);
  1136. }
  1137. isAdd = true;
  1138. }
  1139. }
  1140. }
  1141. if (isAdd && selectAnnotDicts.Count >= 1)
  1142. {
  1143. PDFViewer.ClearSelectAnnots();
  1144. if (StrAnnotToolChecked != "Signature")
  1145. {
  1146. PDFViewer.SelectAnnotation(selectAnnotDicts);
  1147. }
  1148. }
  1149. }
  1150. //阅读页悬浮相应
  1151. /// <summary>
  1152. /// 阅读页鼠标悬浮在注释上的虚线
  1153. /// </summary>
  1154. /// <param name="sender"></param>
  1155. /// <param name="e"></param>
  1156. private void PDFViewer_AnnotHoverHandler(object sender, AnnotHoverData e)
  1157. {
  1158. if (e != null && e.DrawContext != null)
  1159. {
  1160. if (StrAnnotToolChecked != "Link")
  1161. {
  1162. if (e.Annot is CPDFLinkAnnotation linkAnnotation)
  1163. {
  1164. return;
  1165. }
  1166. }
  1167. Rect hoverRect = new Rect(
  1168. e.PaintRect.Left - 2,
  1169. e.PaintRect.Top - 2,
  1170. e.PaintRect.Width + 4,
  1171. e.PaintRect.Height + 4);
  1172. if (e.Annot is CPDFTextAnnotation sticky)
  1173. {
  1174. hoverRect = new Rect(
  1175. e.PaintRect.Left - 2,
  1176. e.PaintRect.Top + 2,
  1177. e.PaintRect.Width + 5,
  1178. e.PaintRect.Height + 2);
  1179. }
  1180. Pen hoverPen = new Pen(new SolidColorBrush(Color.FromArgb(0xff, 0x11, 0x8A, 0xff)), 1);
  1181. hoverPen.DashStyle = DashStyles.Dash;
  1182. e.DrawContext?.DrawRectangle(null, hoverPen, hoverRect);
  1183. //便签,显示ToolTip内容
  1184. if (e.Annot != null && e.Annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_TEXT)
  1185. {
  1186. PopAnnotToolTip(e.Annot.GetRect(), hoverRect, e.Annot.GetContent());
  1187. return;
  1188. }
  1189. }
  1190. CloseAnnotToolTip();
  1191. }
  1192. private void PDFViewer_MouseMove(object sender, MouseEventArgs e)
  1193. {
  1194. if (sender != null && PDFViewer.ToolTip != null && PDFViewer.Parent != null)
  1195. {
  1196. //鼠标移到注释之外,关闭ToolTip浮窗
  1197. var newPoint = e.GetPosition(PDFViewer.Parent as ContentControl);
  1198. var isOutw = newPoint.X > (oldRect.X + oldRect.Width + 4);
  1199. var isOuth = newPoint.Y > (oldRect.Y + oldRect.Height + 4);
  1200. if (newPoint.X < oldRect.X || newPoint.Y < oldRect.Y || isOutw || isOuth)
  1201. {
  1202. CloseAnnotToolTip();
  1203. }
  1204. }
  1205. }
  1206. private Rect oldRect = new Rect(0, 0, 0, 0);
  1207. private void PopAnnotToolTip(CRect placementRect, Rect hoverRect, string content)
  1208. {
  1209. //便签,显示ToolTip内容
  1210. if (PDFViewer.ToolTip == null)
  1211. {
  1212. if (string.IsNullOrEmpty(content) == false)
  1213. {
  1214. ToolTip TipChild = new ToolTip();
  1215. TipChild.Style = App.Current.Resources["FlowToolTip"] as Style;
  1216. TipChild.MaxWidth = 246;
  1217. TipChild.Content = content;
  1218. TipChild.Visibility = Visibility.Visible;
  1219. TipChild.IsOpen = true;
  1220. TipChild.Placement = PlacementMode.Right;
  1221. TipChild.PlacementRectangle = new Rect(placementRect.left, placementRect.top, placementRect.right, placementRect.bottom);
  1222. TipChild.PlacementTarget = PDFViewer.Parent as ContentControl;
  1223. TipChild.Placement = PlacementMode.MousePoint;
  1224. PDFViewer.ToolTip = TipChild;
  1225. oldRect = hoverRect;
  1226. PDFViewer.MouseMove -= PDFViewer_MouseMove;
  1227. PDFViewer.MouseMove += PDFViewer_MouseMove;
  1228. }
  1229. }
  1230. }
  1231. //关闭ToolTip
  1232. private void CloseAnnotToolTip()
  1233. {
  1234. if (PDFViewer.ToolTip != null && PDFViewer.ToolTip is ToolTip)
  1235. {
  1236. ToolTip oldTips = (ToolTip)PDFViewer.ToolTip;
  1237. oldTips.IsOpen = false;
  1238. oldTips.Visibility = Visibility.Collapsed;
  1239. PDFViewer.ToolTip = null;
  1240. PDFViewer.MouseMove -= PDFViewer_MouseMove;
  1241. oldRect = new Rect(0, 0, 0, 0);
  1242. }
  1243. }
  1244. #endregion PDFViewer事件
  1245. #region BindingEvent事件
  1246. //同一属性面板,不同的注释类型
  1247. private void AnnotPropertyPanel_AnnotTypeChanged(object sender, Dictionary<AnnotArgsType, object> e)
  1248. {
  1249. if (e != null && sender is SharpsAnnotPropertyViewModel sharpsAnnot)
  1250. {
  1251. AnnotHandlerEventArgs annotArgs = null;
  1252. //PropertyPanel.SaveLastAnnot();
  1253. List<AnnotHandlerEventArgs> annots = new List<AnnotHandlerEventArgs>();
  1254. foreach (AnnotArgsType argsType in e.Keys)
  1255. {
  1256. if (PropertyPanel.annot != null)
  1257. {
  1258. if (PropertyPanel.annot.EventType != argsType)
  1259. {
  1260. PDFViewer.DisableClearSelectAnnot(false);
  1261. PDFViewer.ClearSelectAnnots();
  1262. PDFViewer.SetMouseMode(MouseModes.PanTool);
  1263. CurrentSelectedAnnot = null;
  1264. }
  1265. }
  1266. switch (argsType)
  1267. {
  1268. case AnnotArgsType.AnnotSquare:
  1269. #region TO DO
  1270. //选择一个形状注释A,在选择B(非多选),修改属性成功,以下操作的操作可以解决,
  1271. //可能会出现选择注释A,鼠标直接点击属性面板,注释A取消选中,但还可以对注释A更改属性的BUG
  1272. if (CurrentSelectedAnnot != null)
  1273. {
  1274. if (CurrentSelectedAnnot.EventType == AnnotArgsType.AnnotSquare)
  1275. {
  1276. CurrentSelectedAnnot.PageIndex = -1;
  1277. CurrentSelectedAnnot.AnnotIndex = -1;
  1278. CurrentSelectedAnnot.ClientRect = Rect.Empty;
  1279. annots.Add(CurrentSelectedAnnot);
  1280. }
  1281. }
  1282. if (annots.Count > 0)
  1283. {
  1284. annotArgs = GetRect(annots);
  1285. }
  1286. else
  1287. {
  1288. annotArgs = GetRect();
  1289. }
  1290. #endregion TO DO
  1291. //annotArgs = GetRect();
  1292. break;
  1293. case AnnotArgsType.AnnotCircle:
  1294. #region TO DO
  1295. if (CurrentSelectedAnnot != null)
  1296. {
  1297. if (CurrentSelectedAnnot.EventType == AnnotArgsType.AnnotCircle)
  1298. {
  1299. CurrentSelectedAnnot.PageIndex = -1;
  1300. CurrentSelectedAnnot.AnnotIndex = -1;
  1301. CurrentSelectedAnnot.ClientRect = Rect.Empty;
  1302. annots.Add(CurrentSelectedAnnot);
  1303. }
  1304. }
  1305. if (annots.Count > 0)
  1306. {
  1307. annotArgs = GetCircle(annots);
  1308. }
  1309. else
  1310. {
  1311. annotArgs = GetCircle();
  1312. }
  1313. #endregion TO DO
  1314. //annotArgs = GetCircle();
  1315. break;
  1316. case AnnotArgsType.AnnotLine:
  1317. var LineTag = e[argsType] as string;
  1318. #region TO DO
  1319. if (CurrentSelectedAnnot != null)
  1320. {
  1321. if (CurrentSelectedAnnot.EventType == AnnotArgsType.AnnotLine)
  1322. {
  1323. CurrentSelectedAnnot.PageIndex = -1;
  1324. CurrentSelectedAnnot.AnnotIndex = -1;
  1325. CurrentSelectedAnnot.ClientRect = Rect.Empty;
  1326. if (CurrentSelectedAnnot is LineAnnotArgs lineAnnotArgs)
  1327. {
  1328. if (lineAnnotArgs.HeadLineType >= (C_LINE_TYPE)1 || lineAnnotArgs.TailLineType >= (C_LINE_TYPE)1)
  1329. {
  1330. if (LineTag == "Arrow")
  1331. {
  1332. annots.Add(CurrentSelectedAnnot);
  1333. }
  1334. }
  1335. else
  1336. {
  1337. if (LineTag == "Line")
  1338. {
  1339. annots.Add(CurrentSelectedAnnot);
  1340. }
  1341. }
  1342. }
  1343. }
  1344. }
  1345. if (annots.Count > 0)
  1346. {
  1347. annotArgs = GetArrowLine(LineTag, annots);
  1348. }
  1349. else
  1350. {
  1351. annotArgs = GetArrowLine(LineTag);
  1352. }
  1353. #endregion TO DO
  1354. //annotArgs = GetArrowLine(LineTag);
  1355. break;
  1356. }
  1357. ShowPropertyPanel();
  1358. if (string.IsNullOrEmpty(StrAnnotToolChecked) || StrAnnotToolChecked != "Rect")
  1359. {
  1360. //PDFViewer.SetMouseMode(MouseModes.PanTool);
  1361. return;
  1362. }
  1363. if (annotArgs != null)
  1364. {
  1365. annotArgs.Author = Settings.Default.AppProperties.Description.Author;
  1366. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  1367. PDFViewer.SetToolParam(annotArgs);
  1368. }
  1369. }
  1370. }
  1371. }
  1372. //来自属性面板的事件,更改颜色等属性而触发
  1373. private void AnnotPropertyPanel_DataChanged(object sender, Dictionary<AnnotArgsType, object> e)
  1374. {
  1375. if (e != null)
  1376. {
  1377. foreach (AnnotArgsType argsType in e.Keys)
  1378. {
  1379. var key = ToolExpandDict.FirstOrDefault(q => q.Value == argsType);
  1380. switch (argsType)
  1381. {
  1382. case AnnotArgsType.AnnotHighlight:
  1383. if (e[argsType] is Color)
  1384. {
  1385. HighLightColor = new SolidColorBrush((Color)e[argsType]);
  1386. }
  1387. if (e[argsType] is double)
  1388. {
  1389. HighLightOpacity = (double)e[argsType];
  1390. }
  1391. //创建注释后,修改注释属性,可用于下次创建的注释
  1392. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1393. {
  1394. if (StrAnnotToolChecked == key.Key)
  1395. {
  1396. PDFViewer.SetToolParam(PropertyPanel.annot);
  1397. }
  1398. }
  1399. break;
  1400. case AnnotArgsType.AnnotUnderline:
  1401. if (e[argsType] is Color)
  1402. {
  1403. UnderLineColor = new SolidColorBrush((Color)e[argsType]);
  1404. }
  1405. if (e[argsType] is double)
  1406. {
  1407. underLineOpacity = (double)e[argsType];
  1408. }
  1409. //创建注释后,修改注释属性,可用于下次创建的注释
  1410. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1411. {
  1412. if (StrAnnotToolChecked == key.Key)
  1413. {
  1414. PDFViewer.SetToolParam(PropertyPanel.annot);
  1415. }
  1416. }
  1417. break;
  1418. case AnnotArgsType.AnnotSquiggly:
  1419. if (e[argsType] is Color)
  1420. {
  1421. SquigglyColor = new SolidColorBrush((Color)e[argsType]);
  1422. }
  1423. if (e[argsType] is double)
  1424. {
  1425. SquigglyOpacity = (double)e[argsType];
  1426. }
  1427. //创建注释后,修改注释属性,可用于下次创建的注释
  1428. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1429. {
  1430. if (StrAnnotToolChecked == key.Key)
  1431. {
  1432. PDFViewer.SetToolParam(PropertyPanel.annot);
  1433. }
  1434. }
  1435. break;
  1436. case AnnotArgsType.AnnotStrikeout:
  1437. if (e[argsType] is Color)
  1438. {
  1439. StrikeoutColor = new SolidColorBrush((Color)e[argsType]);
  1440. }
  1441. if (e[argsType] is double)
  1442. {
  1443. StrikeoutOpacity = (double)e[argsType];
  1444. }
  1445. //创建注释后,修改注释属性,可用于下次创建的注释
  1446. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1447. {
  1448. if (StrAnnotToolChecked == key.Key)
  1449. {
  1450. PDFViewer.SetToolParam(PropertyPanel.annot);
  1451. }
  1452. }
  1453. break;
  1454. case AnnotArgsType.AnnotFreehand:
  1455. if (e[argsType] is FreehandAnnotArgs)
  1456. {
  1457. var annot = e[argsType] as FreehandAnnotArgs;
  1458. if (annot != null)
  1459. {
  1460. if (PropertyPanel != null)
  1461. {
  1462. //属性面板,切换橡皮擦后,再回到画笔时,需要恢复最近画笔的属性值
  1463. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  1464. PropertyPanel.AnnotEvent = AnnotEvent;
  1465. var AnnotEvents = new List<AnnotAttribEvent>();
  1466. AnnotEvents.Add(AnnotEvent);
  1467. PropertyPanel.AnnotEvents = AnnotEvents;
  1468. PropertyPanel.annot = annot;
  1469. //手绘注释工具按钮的属性
  1470. // FreehandPath.Opacity = annot.Transparency;
  1471. // FreehandPath.Fill = new SolidColorBrush(annot.InkColor);
  1472. }
  1473. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1474. {
  1475. if (StrAnnotToolChecked == key.Key)
  1476. {
  1477. PDFViewer.SetToolParam(PropertyPanel.annot);
  1478. }
  1479. }
  1480. }
  1481. }
  1482. break;
  1483. case AnnotArgsType.AnnotErase:
  1484. if (e[argsType] is ToggleButton)
  1485. {
  1486. ToggleButton clickBtn = e[argsType] as ToggleButton;
  1487. if (clickBtn.IsChecked == true)
  1488. {
  1489. if (clickBtn.Tag.ToString() != "PenBtn")
  1490. {
  1491. CustomIconToggleBtn btn = new CustomIconToggleBtn();
  1492. btn.Tag = "Freehand";
  1493. btn.IsChecked = true;
  1494. BtnMyTools_Click(btn);
  1495. break;
  1496. }
  1497. else
  1498. {
  1499. CreateEraseArgs();
  1500. }
  1501. }
  1502. }
  1503. break;
  1504. case AnnotArgsType.AnnotSquare:
  1505. case AnnotArgsType.AnnotCircle:
  1506. case AnnotArgsType.AnnotLine:
  1507. case AnnotArgsType.AnnotFreeText:
  1508. //创建注释后,修改注释属性,可用于下次创建的注释
  1509. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1510. {
  1511. if (StrAnnotToolChecked == "Rect" && PropertyPanel.SharpsAnnot == key.Key)
  1512. {
  1513. PDFViewer.SetToolParam(PropertyPanel.annot);
  1514. PropertyPanel.SaveLastAnnot();
  1515. }
  1516. }
  1517. break;
  1518. }
  1519. }
  1520. }
  1521. }
  1522. private void CreateEraseArgs()
  1523. {
  1524. EraseArgs eraseArgs = new EraseArgs();
  1525. eraseArgs.UIBorderColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
  1526. eraseArgs.UIFillColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
  1527. eraseArgs.Thickness = 10;
  1528. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotErase);
  1529. if (annotProperty != null)
  1530. {
  1531. eraseArgs.Thickness = annotProperty.Thickness;
  1532. }
  1533. PDFViewer.ClearSelectAnnots(false);
  1534. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  1535. PDFViewer.SetToolParam(eraseArgs);
  1536. List<AnnotHandlerEventArgs> eraseArgsList = new List<AnnotHandlerEventArgs>();
  1537. if (eraseArgs != null)
  1538. eraseArgsList.Add(eraseArgs);
  1539. AddToPropertyPanel("FreehandAnnotProperty", "Freehand", eraseArgsList);
  1540. }
  1541. #endregion BindingEvent事件
  1542. }
  1543. }