AnnotToolContentViewModel.Command.cs 80 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739
  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 == "Rect" && PropertyPanel.IsSelectedTextAddShape == false)
  388. {
  389. AnnotHandlerEventArgs annotArgs = null;
  390. //此处不能用这个方法更新创建注释的属性 会导致死循环
  391. //选择文字 点击矩形 会导致死循环
  392. // FindAnnotTypeKey(StrAnnotToolChecked, ref annotArgs);
  393. PropertyPanel.annot = null;
  394. PropertyPanel.AnnotEvents = null;
  395. PropertyPanel.AnnotEvent = null;
  396. PropertyPanel.annotlists = null;
  397. switch (PropertyPanel.SharpsAnnot)
  398. {
  399. case "Rect":
  400. annotArgs = GetRect();
  401. break;
  402. case "Circle":
  403. annotArgs = GetCircle();
  404. break;
  405. case "Arrow":
  406. annotArgs = GetArrowLine("Arrow");
  407. break;
  408. case "Line":
  409. annotArgs = GetArrowLine("Line");
  410. break;
  411. }
  412. return;
  413. }
  414. }
  415. }
  416. if (e != null)
  417. {
  418. if (e.IsMouseRightActive)
  419. {
  420. if (string.IsNullOrEmpty(StrAnnotToolChecked))
  421. {
  422. ShowPropertyPanel(false);
  423. return;
  424. }
  425. }
  426. var annot = e.AnnotItemsList[0];
  427. if (annot != null)
  428. {
  429. if (e.AnnotItemsList.Count == 1)
  430. {
  431. //IsAnnotCreateReset:是否为创建注释的状态
  432. if (e.IsAnnotCreateReset == false)
  433. {
  434. CurrentSelectedAnnot = annot;
  435. //未选注释工具-形状注释,选中形状注释,属性面板不显示(矩形、圆、线、箭头)
  436. if (StrAnnotToolChecked != "Rect"
  437. && (annot.EventType == AnnotArgsType.AnnotSquare ||
  438. annot.EventType == AnnotArgsType.AnnotCircle ||
  439. annot.EventType == AnnotArgsType.AnnotLine))
  440. {
  441. PropertyPanel.IsSharpAnnotSelected = false;
  442. }
  443. else
  444. {
  445. PropertyPanel.IsSharpAnnotSelected = true;
  446. }
  447. if (StrAnnotToolChecked != "Freehand" && annot.EventType == AnnotArgsType.AnnotFreehand)
  448. {
  449. PropertyPanel.IsFreeHandSelected = false;
  450. }
  451. else
  452. {
  453. PropertyPanel.IsFreeHandSelected = true;
  454. }
  455. GetSelectedAnnots(e);
  456. SelectedSignature(e.AnnotItemsList);
  457. if (Settings.Default.AppProperties.InitialVIew.AutoExpandProperty
  458. && annot.EventType != AnnotArgsType.AnnotStamp && StrAnnotToolChecked != "Signature"
  459. && annot.EventType != AnnotArgsType.AnnotLink)
  460. {
  461. var signAnnot = viewContentViewModel.AnnotSignatures.FirstOrDefault(temp => temp.Item1 == annot.PageIndex && temp.Item2 == annot.AnnotIndex);
  462. if (signAnnot == null)
  463. {
  464. ShowPropertyPanel(true);
  465. }
  466. }
  467. if (StrAnnotToolChecked == "Signature")
  468. {
  469. GetSignature();
  470. }
  471. //注释列表同步选中
  472. SelectedBotaAnnotationList(e);
  473. }
  474. else
  475. {
  476. if (!string.IsNullOrEmpty(StrAnnotToolChecked) || PropertyPanel.IsAddLink == true)
  477. {
  478. GetSelectedAnnots(e);
  479. PDFViewer.SetToolParam(annot);
  480. }
  481. else
  482. {
  483. if (IsNoSelectMenu)
  484. {
  485. return;
  486. }
  487. PropertyPanel.annot = null;
  488. PropertyPanel.AnnotEvents = null;
  489. PropertyPanel.AnnotEvent = null;
  490. PropertyPanel.annotlists = null;
  491. PDFViewer.SetMouseMode(MouseModes.PanTool);
  492. HandToolIsCheckedEvent(false);
  493. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  494. }
  495. //switch (annot.EventType)
  496. //{
  497. // case AnnotArgsType.AnnotFreeText:
  498. // annot = GetFreetext(e.AnnotItemsList);
  499. // PDFViewer.SetToolParam(annot);
  500. // break;
  501. // case AnnotArgsType.AnnotSticky:
  502. // customStickyPopup.GetCurrentAnnot = e.AnnotItemsList[0] as StickyAnnotArgs;
  503. // customStickyPopup.GetPDFViewer = PDFViewer;
  504. // propertyPanel.annot = e.AnnotItemsList[0];
  505. // var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  506. // propertyPanel.AnnotEvents = null;
  507. // propertyPanel.AnnotEvent = AnnotEvent;
  508. // propertyPanel.annotlists = e.AnnotItemsList;
  509. // break;
  510. // case AnnotArgsType.AnnotLink:
  511. // //viewContentViewModel.IsCreateLink = false;
  512. // GetLink(e.AnnotItemsList, e);
  513. // PDFViewer.SetToolParam(annot);
  514. // break;
  515. //}
  516. #region //TODO: 修改注释后,会作用到之后添加的注释中。因此先把此逻辑“创建注释后,会自动回到默认值”注释掉
  517. //注释代码原因:设计已经重新调整逻辑:所有注释创建后,编辑属性,所有属性会作用于下次创建的注释中。
  518. //if (annot.EventType != AnnotArgsType.AnnotStrikeout &&
  519. //annot.EventType != AnnotArgsType.AnnotUnderline &&
  520. //annot.EventType != AnnotArgsType.AnnotHighlight &&
  521. //annot.EventType != AnnotArgsType.AnnotSquiggly &&
  522. //annot.EventType != AnnotArgsType.AnnotLink &&
  523. //annot.EventType != AnnotArgsType.AnnotFreehand &&
  524. //annot.EventType != AnnotArgsType.AnnotSticky &&
  525. //)
  526. //{
  527. // if (ToolExpandDict.ContainsValue(e.AnnotItemsList[0].EventType))
  528. // {
  529. // var strLineAnnotTag = "";
  530. // if (e.AnnotItemsList[0] is LineAnnotArgs)
  531. // {
  532. // var lineAnnot = e.AnnotItemsList[0] as LineAnnotArgs;
  533. // if (lineAnnot.HeadLineType == C_LINE_TYPE.LINETYPE_NONE && lineAnnot.TailLineType == C_LINE_TYPE.LINETYPE_NONE)
  534. // {
  535. // strLineAnnotTag = "Line";
  536. // }
  537. // else
  538. // {
  539. // strLineAnnotTag = "Arrow";
  540. // }
  541. // }
  542. // foreach (var item in ToolExpandDict)
  543. // {
  544. // if (item.Value == e.AnnotItemsList[0].EventType)
  545. // {
  546. // annot = null;//新建注释时,回到默认值
  547. // if (string.IsNullOrEmpty(strLineAnnotTag))
  548. // {
  549. // FindAnnotTypeKey(item.Key, ref annot);
  550. // break;
  551. // }
  552. // else
  553. // {
  554. // if (strLineAnnotTag == item.Key)
  555. // {
  556. // FindAnnotTypeKey(item.Key, ref annot);
  557. // break;
  558. // }
  559. // }
  560. // }
  561. // }
  562. // PDFViewer.SetToolParam(annot);
  563. // }
  564. //}
  565. //设计重新调整,阅读页空白处,右键菜单,添加链接需要显示,其他和pro mac一样的效果,不显示属性栏
  566. //if (isRightMenuAddAnnot && annot.EventType!=AnnotArgsType.AnnotLink)
  567. //{
  568. // ShowPropertyPanel(false);
  569. //}
  570. //else
  571. //{
  572. // ShowPropertyPanel();
  573. //}
  574. #endregion //TODO: 修改注释后,会作用到之后添加的注释中。因此先把此逻辑“创建注释后,会自动回到默认值”注释掉
  575. }
  576. }
  577. else
  578. {
  579. //框选注释
  580. PropertyPanel.annotlists = e.AnnotItemsList;
  581. bool isDifferentAnnotTyle = AnnotTransfer.IsDifferentTypeAnnots(e.AnnotItemsList);
  582. if (isDifferentAnnotTyle)
  583. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  584. else
  585. GetSelectedAnnots(e);
  586. }
  587. }
  588. }
  589. }
  590. /// <summary>
  591. /// 注释列表同步选中
  592. /// </summary>
  593. /// <param name="e"></param>
  594. private void SelectedBotaAnnotationList(AnnotAttribEvent e)
  595. {
  596. var list = e.GetPageAnnotsIndex();
  597. bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  598. //if (viewContentViewModel.OpenBOTA == false || isTabItemAnnotation == false || bOTAContent.TabItemAnnotation.IsSelected == false)
  599. //{
  600. // viewContentViewModel.OpenBOTA = true;
  601. // bOTAContent.TabItemAnnotation.IsSelected = true;
  602. //}
  603. if (viewContentViewModel.OpenBOTA == true && isTabItemAnnotation == true /*&& bOTAContent.TabItemAnnotation.IsSelected == true*/ && list != null && list.Count > 0)
  604. {
  605. if (list.Keys.Count == 0)
  606. {
  607. return;
  608. }
  609. var pageindex = new List<int>(list.Keys);
  610. List<int> annotes = new List<int>();
  611. list.TryGetValue(pageindex[0], out annotes);
  612. int annoteindex = annotes[0];
  613. AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
  614. if (viewModel != null)
  615. {
  616. viewModel.ScrollToAnnot(pageindex[0], annoteindex, annotation.AnnotationList);
  617. }
  618. }
  619. }
  620. //在注释工具的状态下,右键菜单
  621. private void PDFViewer_AnnotCommandHandler(object sender, AnnotCommandArgs e)
  622. {
  623. if (e.AnnotEventArgsList == null || (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool))
  624. return;
  625. if ((UIElement)sender != null)
  626. {
  627. //绑定命令执行前的拦截事件,对于未解密权限的文档进行复制限制
  628. CommandManager.AddPreviewExecutedHandler((UIElement)sender, PreviewExcute);
  629. }
  630. switch (e.CommandType)
  631. {
  632. case CommandType.Context:
  633. if (e.AnnotEventArgsList.Count > 0)
  634. {
  635. if (App.mainWindowViewModel.SelectedItem.IsInReadctonMode && e.AnnotEventArgsList[0].EventType == AnnotArgsType.AnnotRedaction)
  636. {
  637. //绑定标记密文处右键菜单
  638. events.GetEvent<RedactionCommandEvent>().Publish(new RedactionCommandEventArgs() { UniCode = App.mainWindowViewModel.SelectedItem.Unicode, Sender = sender, args = e });
  639. }
  640. else
  641. {
  642. if (e.AnnotEventArgsList.Count == 1)
  643. {
  644. var selectedAnnot = e.AnnotEventArgsList[0];
  645. PopMenuCheckedLineDash(selectedAnnot);
  646. PopMenuCheckedFontFamily(selectedAnnot);
  647. PopMenuCheckedTextAglin(selectedAnnot);
  648. switch (selectedAnnot.EventType)
  649. {
  650. case AnnotArgsType.AnnotHighlight:
  651. case AnnotArgsType.AnnotUnderline:
  652. case AnnotArgsType.AnnotStrikeout:
  653. case AnnotArgsType.AnnotSquiggly:
  654. if (selectedAnnot.EventType == AnnotArgsType.AnnotHighlight)
  655. {
  656. colorContent.ItemSource = AnnotColorList.GetColorList(ColorSelectorType.Highlight);
  657. }
  658. else
  659. {
  660. colorContent.ItemSource = AnnotColorList.GetColorList(ColorSelectorType.Border);
  661. }
  662. e.PopupMenu = HightAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  663. break;
  664. case AnnotArgsType.AnnotFreehand:
  665. e.PopupMenu = FreeHandAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  666. break;
  667. case AnnotArgsType.AnnotFreeText:
  668. e.PopupMenu = FreeTextAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  669. break;
  670. case AnnotArgsType.AnnotSticky:
  671. e.PopupMenu = StrickNoteAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  672. break;
  673. case AnnotArgsType.AnnotSquare:
  674. case AnnotArgsType.AnnotCircle:
  675. ShapeAnnotPopMenu.SetVisual("ShapeDirect", false);
  676. ShapeAnnotPopMenu.SetVisual("ShapeFillColor", true);
  677. e.PopupMenu = ShapeAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  678. break;
  679. case AnnotArgsType.AnnotLine:
  680. ShapeAnnotPopMenu.SetVisual("ShapeFillColor", false);
  681. ShapeAnnotPopMenu.SetVisual("ShapeDirect", true);
  682. e.PopupMenu = ShapeAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  683. break;
  684. case AnnotArgsType.AnnotLink:
  685. e.PopupMenu = LinkAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  686. break;
  687. case AnnotArgsType.AnnotStamp:
  688. e.PopupMenu = StampAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  689. break;
  690. }
  691. }
  692. else
  693. {
  694. bool isHigh = true;//是否为高亮
  695. foreach (var item in e.AnnotEventArgsList)
  696. {
  697. if (AnnotTransfer.IsHightAnnot(item) == false)
  698. {
  699. isHigh = false;
  700. break;
  701. }
  702. }
  703. MultiAnnotPopMenu.SetVisual("MultiCopy", !isHigh);
  704. MultiAnnotPopMenu.SetVisual("MultiCut", !isHigh);
  705. e.PopupMenu = MultiAnnotPopMenu.OpenMenu(e.AnnotEventArgsList, sender);
  706. }
  707. }
  708. if (e.PopupMenu != null)
  709. {
  710. e.Handle = true;
  711. }
  712. }
  713. else
  714. {
  715. if (e.PressOnSelectedText || e.CommandTarget == TargetType.ImageSelection)
  716. {
  717. e.PopupMenu = SelectedTextOrImageContextMenu(sender, e);
  718. if (e.PopupMenu != null)
  719. {
  720. e.Handle = true;
  721. }
  722. }
  723. else
  724. {
  725. e.PopupMenu = ViewerContextMenu(sender);
  726. if (e.PopupMenu != null)
  727. {
  728. e.Handle = true;
  729. }
  730. }
  731. }
  732. break;
  733. }
  734. }
  735. private void PreviewExcute(object sender, ExecutedRoutedEventArgs e)
  736. {
  737. if (e.Command == ApplicationCommands.Copy)
  738. {
  739. VerifyPasswordResult result = SecurityHelper.VerifyPasswordForSelectedPermissions(PDFViewer.Document, Model.Dialog.ToolsDialogs.SaftyDialogs.EnumPermissionsSet.StatusAllowsCopying, dialogs);
  740. if (result.IsDiscryptied)
  741. {
  742. if (result.Password != null)
  743. {
  744. string filePath = PDFViewer.Document.FilePath;
  745. var unlockresult = PDFViewer.Document.CheckOwnerPassword(result.Password);
  746. }
  747. }
  748. else
  749. {
  750. e.Handled = true;
  751. }
  752. }
  753. }
  754. /// <summary>
  755. /// 右键菜单,选中字体样式按钮状态
  756. /// </summary>
  757. /// <param name="annot"></param>
  758. private void PopMenuCheckedFontFamily(AnnotHandlerEventArgs annot)
  759. {
  760. if (annot != null)
  761. {
  762. if (annot.EventType == AnnotArgsType.AnnotFreeText)
  763. {
  764. var freeText = annot as FreeTextAnnotArgs;
  765. string fontFamily = freeText.FontFamily.ToString();
  766. if (fontFamily == "Arial")
  767. {
  768. fontFamily = "Helvetica";
  769. }
  770. if (fontFamily == "Courier New")
  771. {
  772. fontFamily = "Courier";
  773. }
  774. if (fontFamily == "Times New Roman")
  775. {
  776. fontFamily = "Times";
  777. }
  778. FreeTextAnnotPopMenu.SetIsChecked(fontFamily, true);
  779. }
  780. }
  781. }
  782. /// <summary>
  783. /// 右键菜单,选中文本内容对齐按钮状态
  784. /// </summary>
  785. /// <param name="annot"></param>
  786. private void PopMenuCheckedTextAglin(AnnotHandlerEventArgs annot)
  787. {
  788. if (annot != null)
  789. {
  790. if (annot.EventType == AnnotArgsType.AnnotFreeText)
  791. {
  792. var freeText = annot as FreeTextAnnotArgs;
  793. switch (freeText.Align)
  794. {
  795. case TextAlignment.Left:
  796. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinLeft", true);
  797. break;
  798. case TextAlignment.Center:
  799. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinCenter", true);
  800. break;
  801. case TextAlignment.Right:
  802. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinRight", true);
  803. break;
  804. case TextAlignment.Justify:
  805. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinJustify", true);
  806. break;
  807. default:
  808. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinLeft", false);
  809. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinCenter", false);
  810. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinRight", false);
  811. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinJustify", false);
  812. break;
  813. }
  814. }
  815. }
  816. }
  817. //右键菜单,选中虚实线按钮状态
  818. private void PopMenuCheckedLineDash(AnnotHandlerEventArgs annot)
  819. {
  820. if (annot != null)
  821. {
  822. bool isSolidLineDash = true;
  823. if (annot.EventType == AnnotArgsType.AnnotFreehand)
  824. {
  825. var freeHand = annot as FreehandAnnotArgs;
  826. isSolidLineDash = AnnotTransfer.IsSolidStyle(freeHand.LineDash);
  827. FreeHandAnnotPopMenu.SetIsChecked(isSolidLineDash ? "FreeHandSolid" : "FreeHandDash", true);
  828. }
  829. else if (annot.EventType == AnnotArgsType.AnnotSquare)
  830. {
  831. var square = annot as SquareAnnotArgs;
  832. isSolidLineDash = AnnotTransfer.IsSolidStyle(square.LineDash);
  833. ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
  834. }
  835. else if (annot.EventType == AnnotArgsType.AnnotCircle)
  836. {
  837. var circle = annot as CircleAnnotArgs;
  838. isSolidLineDash = AnnotTransfer.IsSolidStyle(circle.LineDash);
  839. ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
  840. }
  841. else if (annot.EventType == AnnotArgsType.AnnotLine)
  842. {
  843. var line = annot as LineAnnotArgs;
  844. isSolidLineDash = AnnotTransfer.IsSolidStyle(line.LineDash);
  845. ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
  846. }
  847. }
  848. }
  849. /// <summary>
  850. /// 内容选择工具
  851. /// </summary>
  852. /// <param name="sender"></param>
  853. /// <param name="e"></param>
  854. private void PDFViewer_SnapshotCommandHandler(object sender, SnapshotCommandArgs e)
  855. {
  856. SnapshotEditToolArgs snapToolArgs = new SnapshotEditToolArgs();
  857. if (PDFViewer.ToolManager.CurrentAnnotArgs is SnapshotEditToolArgs)
  858. {
  859. snapToolArgs = (SnapshotEditToolArgs)PDFViewer.ToolManager.CurrentAnnotArgs;
  860. SnapshotEditMenuViewModel.SnapToolArgs = snapToolArgs;
  861. SnapshotEditMenuViewModel.PDFViewer = PDFViewer;
  862. SnapshotEditMenuViewModel.areaCropPageUndoManager = new AreaCropPageUndoManager(PDFViewer);
  863. SnapshotEditMenuViewModel.SnapToolEvent -= SnapshotEditMenuViewModel_SnapToolEvent; ;
  864. SnapshotEditMenuViewModel.SnapToolEvent += SnapshotEditMenuViewModel_SnapToolEvent;
  865. var popMenu = App.Current.FindResource("SnapshotContextMenu") as ContextMenu;
  866. if (e.HitSnapshotTool && e.SnapshotRect.Width > 0 && e.SnapshotRect.Height > 0)
  867. {
  868. e.PopupMenu = popMenu;
  869. e.Handle = true;
  870. if (popMenu != null && popMenu.Items.Count == 5)
  871. {
  872. //复制
  873. MenuItem menuItem = popMenu.Items[0] as MenuItem;
  874. menuItem.CommandTarget = PDFViewer;
  875. menuItem.Command = SnapshotEditMenuViewModel.SnapCopyCommand;
  876. //导出
  877. menuItem = popMenu.Items[1] as MenuItem;
  878. menuItem.CommandTarget = PDFViewer;
  879. if (menuItem.Items.Count == 3)
  880. {
  881. MenuItem menuItem1 = menuItem.Items[0] as MenuItem;
  882. menuItem1.CommandTarget = PDFViewer;
  883. menuItem1.Command = SnapshotEditMenuViewModel.ExportPNGCommand;
  884. menuItem1 = menuItem.Items[1] as MenuItem;
  885. menuItem1.CommandTarget = PDFViewer;
  886. menuItem1.Command = SnapshotEditMenuViewModel.ExportJPGCommand;
  887. menuItem1 = menuItem.Items[2] as MenuItem;
  888. menuItem1.CommandTarget = PDFViewer;
  889. menuItem1.Command = SnapshotEditMenuViewModel.ExportPDFCommand;
  890. }
  891. //裁剪
  892. menuItem = popMenu.Items[2] as MenuItem;
  893. menuItem.CommandTarget = PDFViewer;
  894. menuItem.Command = SnapshotEditMenuViewModel.CroppingCommand;
  895. //缩放至所选区域
  896. menuItem = popMenu.Items[3] as MenuItem;
  897. menuItem.CommandTarget = PDFViewer;
  898. menuItem.Visibility = Visibility.Collapsed;
  899. //menuItem.Command = snapshotEditMenuViewModel.CroppingCommand;
  900. //打印
  901. menuItem = popMenu.Items[4] as MenuItem;
  902. menuItem.CommandTarget = PDFViewer;
  903. menuItem.Command = SnapshotEditMenuViewModel.PrintCommand;
  904. }
  905. }
  906. }
  907. }
  908. private void SnapshotEditMenuViewModel_SnapToolEvent(object sender, KeyValuePair<string, object> e)
  909. {
  910. switch (e.Key)
  911. {
  912. case "CloseSnap":
  913. {
  914. #region to do
  915. //var item = PDFViewerTab.SelectedItem as TabItem;
  916. //if (item == null)
  917. //{
  918. // ClearSelectedToolPanel();
  919. // return;
  920. //}
  921. //Grid grid = item.Content as Grid;
  922. //if (grid == null || grid.Children.Count == 0)
  923. //{
  924. // ClearSelectedToolPanel();
  925. // return;
  926. //}
  927. //PDFViewerCtrl pdfViewer = grid.Children[0] as PDFViewerCtrl;
  928. //if (pdfViewer == null)
  929. //{
  930. // ClearSelectedToolPanel();
  931. // return;
  932. //}
  933. #endregion to do
  934. switch (PDFViewer.MouseMode)
  935. {
  936. case MouseModes.SelectTextTool:
  937. break;
  938. default:
  939. BtnSelecttoolIsChecked = false;
  940. //BtnHandIsChecked = true;
  941. PDFViewer.EnableZoom(true);
  942. PDFViewer.EnableScroll(true);
  943. PDFViewer.SetMouseMode(MouseModes.PanTool);
  944. break;
  945. }
  946. }
  947. break;
  948. default:
  949. break;
  950. }
  951. }
  952. private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
  953. {
  954. bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  955. AnnotationContentViewModel viewModel = null;
  956. AnnotationContent annotation = null;
  957. if (viewContentViewModel.OpenBOTA == true)
  958. {
  959. viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out annotation);
  960. }
  961. bool isMultiple = false;
  962. Dictionary<int, List<int>> selectAnnotDicts = new Dictionary<int, List<int>>();
  963. if (e != null && e.Count > 0)
  964. {
  965. for (int i = 0; i < e.Count; i++)
  966. {
  967. AnnotEditEvent editEvent = e[i];
  968. bool isVisible = PDFViewer.CheckAnnotVisible(editEvent.PageIndex, editEvent.AnnotIndex);
  969. var annot = editEvent.EditAnnotArgs;
  970. switch (editEvent.EditAction)
  971. {
  972. case ActionType.Add:
  973. #region 区分复制填写签名图形
  974. if (IsPasteShape)
  975. {
  976. if (editEvent.EditAnnotArgs.EventType == AnnotArgsType.AnnotFreehand)
  977. {
  978. if (ShapeNames.Count != 0 && ShapeNames[i] != "Annot")
  979. {
  980. try
  981. {
  982. viewContentViewModel.FillAndSign.Add(new FillAndSignIsShape(editEvent.PageIndex, editEvent.AnnotIndex, ShapeNames[i]));
  983. }
  984. catch { }
  985. }
  986. }
  987. }
  988. #endregion 区分复制填写签名图形
  989. if (viewContentViewModel.CurrentBar != "TabItemAnnotation")
  990. {
  991. //填写与签名在此区域不选中,不添加selectAnnotDicts词典当中
  992. }
  993. else
  994. {
  995. if (PropertyPanel.IsMultiSelected)
  996. {
  997. if (selectAnnotDicts.ContainsKey(editEvent.PageIndex) == false)
  998. {
  999. selectAnnotDicts.Add(editEvent.PageIndex, new List<int>());
  1000. selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1001. }
  1002. else
  1003. {
  1004. selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1005. }
  1006. isMultiple = true;
  1007. }
  1008. else
  1009. {
  1010. if (annot.EventType == AnnotArgsType.AnnotSquare || annot.EventType == AnnotArgsType.AnnotCircle ||
  1011. annot.EventType == AnnotArgsType.AnnotLine || annot.EventType == AnnotArgsType.AnnotStamp ||
  1012. annot.EventType==AnnotArgsType.AnnotLink
  1013. /*|| annot.EventType == AnnotArgsType.AnnotSticky ||annot.EventType == AnnotArgsType.AnnotFreeText || annot.EventType == AnnotArgsType.AnnotFreehand*/)
  1014. {
  1015. if (selectAnnotDicts.ContainsKey(editEvent.PageIndex) == false)
  1016. {
  1017. selectAnnotDicts.Add(editEvent.PageIndex, new List<int>());
  1018. selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1019. }
  1020. else
  1021. {
  1022. selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1023. }
  1024. isMultiple = true;
  1025. }
  1026. }
  1027. }
  1028. if (viewModel != null)
  1029. {
  1030. int pageindex = editEvent.PageIndex;
  1031. int annotindex = editEvent.AnnotIndex;
  1032. viewModel.UpdateAddedAnnot(pageindex, annotindex);
  1033. }
  1034. //添加书签注释,用于未保存前跟图章手绘注释的区分
  1035. if (StrAnnotToolChecked == "Signature")
  1036. {
  1037. AddAnnotSignature(editEvent.EditAnnotArgs);
  1038. }
  1039. //if (editEvent.EditAnnotArgs.EventType == AnnotArgsType.AnnotFreeText)
  1040. //{
  1041. // (editEvent.EditAnnotArgs as FreeTextAnnotArgs).LineWidth = 0;
  1042. //}
  1043. break;
  1044. case ActionType.Modify:
  1045. if (string.IsNullOrEmpty(StrAnnotToolChecked) == false)
  1046. {
  1047. List<AnnotHandlerEventArgs> selectedArgs = new List<AnnotHandlerEventArgs>() { annot };
  1048. switch (annot.EventType)
  1049. {
  1050. case AnnotArgsType.AnnotFreeText://文本
  1051. GetFreetext(selectedArgs);
  1052. break;
  1053. }
  1054. }
  1055. if (viewModel != null)
  1056. {
  1057. int pageindex = editEvent.PageIndex;
  1058. int annotindex = editEvent.AnnotIndex;
  1059. viewModel.UpdateModifiedAnnot(pageindex, annotindex);
  1060. }
  1061. break;
  1062. case ActionType.Del:
  1063. //isTabItemAnnotation = IsBOTATabItemShow(out bOTAContentViewModel, out bOTAContent, "TabItemAnnotation");
  1064. //if (viewContentViewModel.OpenBOTA == true && bOTAContent.TabItemAnnotation.IsSelected)
  1065. //{
  1066. // AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
  1067. #region//填写与签名 删除缓存信息列表
  1068. //if (Shape != "None")
  1069. //{
  1070. for (int j = 0; j < viewContentViewModel.FillAndSign.Count; j++)
  1071. {
  1072. if (viewContentViewModel.FillAndSign[j].PageIndex == editEvent.PageIndex && viewContentViewModel.FillAndSign[j].AnnotIndex == editEvent.AnnotIndex)
  1073. {
  1074. viewContentViewModel.FillAndSign.Remove(viewContentViewModel.FillAndSign[j]);
  1075. }
  1076. }
  1077. for (int j = 0; j < viewContentViewModel.AnnotSignatures.Count; j++)
  1078. {
  1079. if (viewContentViewModel.AnnotSignatures[j].Item1 == editEvent.PageIndex && viewContentViewModel.AnnotSignatures[j].Item2 == editEvent.AnnotIndex)
  1080. {
  1081. viewContentViewModel.AnnotSignatures.Remove(viewContentViewModel.AnnotSignatures[j]);
  1082. }
  1083. }
  1084. //}
  1085. #endregion PDFViewer事件
  1086. if (viewModel != null)
  1087. {
  1088. int pageindex = editEvent.PageIndex;
  1089. int annotindex = editEvent.AnnotIndex;
  1090. viewModel.DeleteModifiedAnnot(pageindex, annotindex);
  1091. }
  1092. if (string.IsNullOrEmpty(StrAnnotToolChecked))
  1093. {
  1094. ExitAnnotationTool();
  1095. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  1096. }
  1097. else
  1098. {
  1099. switch (StrAnnotToolChecked)
  1100. {
  1101. case "Link":
  1102. PropertyPanel.IsAddLink = true;
  1103. GetLink();
  1104. break;
  1105. }
  1106. }
  1107. break;
  1108. case ActionType.TextEdit:
  1109. break;
  1110. default:
  1111. break;
  1112. }
  1113. }
  1114. IsPasteShape = false;
  1115. if (isMultiple && selectAnnotDicts.Count >= 1)
  1116. {
  1117. //PDFViewer.DisableClearSelectAnnot(false);
  1118. PDFViewer.ClearSelectAnnots();
  1119. if (StrAnnotToolChecked != "Signature")
  1120. {
  1121. //PDFViewer.DisableClearSelectAnnot(true);
  1122. PDFViewer.SelectAnnotation(selectAnnotDicts);
  1123. //禁止取消选中注释
  1124. //PDFViewer.DisableClearSelectAnnot(false);
  1125. }
  1126. }
  1127. //MultipleSelectionAnnot(e);
  1128. //空白处 右键菜单 添加注释 为单次添加,不连续添加
  1129. if (IsNoSelectMenu && PropertyPanel.IsAddLink == false)
  1130. {
  1131. IsNoSelectMenu = false;
  1132. ExitAnnotationTool();
  1133. }
  1134. }
  1135. }
  1136. //复制多个注释,粘贴后,默认注释未选中状态
  1137. private void MultipleSelectionAnnot(List<AnnotEditEvent> e)
  1138. {
  1139. bool isAdd = false;
  1140. Dictionary<int, List<int>> selectAnnotDicts = new Dictionary<int, List<int>>();
  1141. foreach (var item in e)
  1142. {
  1143. if (item.EditAction == ActionType.Add || item.EditAction == ActionType.Modify)
  1144. {
  1145. var annot = item.EditAnnotArgs;
  1146. if (annot.EventType == AnnotArgsType.AnnotSquare || annot.EventType == AnnotArgsType.AnnotCircle ||
  1147. annot.EventType == AnnotArgsType.AnnotLine || annot.EventType == AnnotArgsType.AnnotStamp || annot.EventType == AnnotArgsType.AnnotFreeText || annot.EventType == AnnotArgsType.AnnotFreehand)
  1148. {
  1149. if (selectAnnotDicts.ContainsKey(item.PageIndex) == false)
  1150. {
  1151. selectAnnotDicts.Add(item.PageIndex, new List<int>());
  1152. selectAnnotDicts[item.PageIndex].Add(item.AnnotIndex);
  1153. }
  1154. else
  1155. {
  1156. selectAnnotDicts[item.PageIndex].Add(item.AnnotIndex);
  1157. }
  1158. isAdd = true;
  1159. }
  1160. }
  1161. }
  1162. if (isAdd && selectAnnotDicts.Count >= 1)
  1163. {
  1164. PDFViewer.ClearSelectAnnots();
  1165. if (StrAnnotToolChecked != "Signature")
  1166. {
  1167. PDFViewer.SelectAnnotation(selectAnnotDicts);
  1168. }
  1169. }
  1170. }
  1171. //阅读页悬浮相应
  1172. /// <summary>
  1173. /// 阅读页鼠标悬浮在注释上的虚线
  1174. /// </summary>
  1175. /// <param name="sender"></param>
  1176. /// <param name="e"></param>
  1177. private void PDFViewer_AnnotHoverHandler(object sender, AnnotHoverData e)
  1178. {
  1179. if (e != null && e.DrawContext != null)
  1180. {
  1181. if (StrAnnotToolChecked != "Link")
  1182. {
  1183. if (e.Annot is CPDFLinkAnnotation linkAnnotation)
  1184. {
  1185. return;
  1186. }
  1187. }
  1188. if (StrAnnotToolChecked == "Freehand")
  1189. {
  1190. return;
  1191. }
  1192. Rect hoverRect = new Rect(
  1193. e.PaintRect.Left - 2,
  1194. e.PaintRect.Top - 2,
  1195. e.PaintRect.Width + 4,
  1196. e.PaintRect.Height + 4);
  1197. if (e.Annot is CPDFTextAnnotation sticky)
  1198. {
  1199. hoverRect = new Rect(
  1200. e.PaintRect.Left - 2,
  1201. e.PaintRect.Top + 2,
  1202. e.PaintRect.Width + 5,
  1203. e.PaintRect.Height + 2);
  1204. }
  1205. Pen hoverPen = new Pen(new SolidColorBrush(Color.FromArgb(0xff, 0x11, 0x8A, 0xff)), 1);
  1206. hoverPen.DashStyle = DashStyles.Dash;
  1207. e.DrawContext?.DrawRectangle(null, hoverPen, hoverRect);
  1208. //便签,显示ToolTip内容
  1209. if (e.Annot != null && e.Annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_TEXT)
  1210. {
  1211. PopAnnotToolTip(e.Annot.GetRect(), hoverRect, e.Annot.GetContent());
  1212. return;
  1213. }
  1214. }
  1215. CloseAnnotToolTip();
  1216. }
  1217. private void PDFViewer_MouseMove(object sender, MouseEventArgs e)
  1218. {
  1219. if (sender != null && PDFViewer.ToolTip != null && PDFViewer.Parent != null)
  1220. {
  1221. //鼠标移到注释之外,关闭ToolTip浮窗
  1222. var newPoint = e.GetPosition(PDFViewer.Parent as ContentControl);
  1223. var isOutw = newPoint.X > (oldRect.X + oldRect.Width + 4);
  1224. var isOuth = newPoint.Y > (oldRect.Y + oldRect.Height + 4);
  1225. if (newPoint.X < oldRect.X || newPoint.Y < oldRect.Y || isOutw || isOuth)
  1226. {
  1227. CloseAnnotToolTip();
  1228. }
  1229. }
  1230. }
  1231. private Rect oldRect = new Rect(0, 0, 0, 0);
  1232. private void PopAnnotToolTip(CRect placementRect, Rect hoverRect, string content)
  1233. {
  1234. //便签,显示ToolTip内容
  1235. if (PDFViewer.ToolTip == null)
  1236. {
  1237. if (string.IsNullOrEmpty(content) == false)
  1238. {
  1239. ToolTip TipChild = new ToolTip();
  1240. TipChild.Style = App.Current.Resources["FlowToolTip"] as Style;
  1241. TipChild.MaxWidth = 246;
  1242. TipChild.Content = content;
  1243. TipChild.Visibility = Visibility.Visible;
  1244. TipChild.IsOpen = true;
  1245. TipChild.Placement = PlacementMode.Right;
  1246. TipChild.PlacementRectangle = new Rect(placementRect.left, placementRect.top, placementRect.right, placementRect.bottom);
  1247. TipChild.PlacementTarget = PDFViewer.Parent as ContentControl;
  1248. TipChild.Placement = PlacementMode.MousePoint;
  1249. PDFViewer.ToolTip = TipChild;
  1250. oldRect = hoverRect;
  1251. PDFViewer.MouseMove -= PDFViewer_MouseMove;
  1252. PDFViewer.MouseMove += PDFViewer_MouseMove;
  1253. }
  1254. }
  1255. }
  1256. //关闭ToolTip
  1257. private void CloseAnnotToolTip()
  1258. {
  1259. if (PDFViewer.ToolTip != null && PDFViewer.ToolTip is ToolTip)
  1260. {
  1261. ToolTip oldTips = (ToolTip)PDFViewer.ToolTip;
  1262. oldTips.IsOpen = false;
  1263. oldTips.Visibility = Visibility.Collapsed;
  1264. PDFViewer.ToolTip = null;
  1265. PDFViewer.MouseMove -= PDFViewer_MouseMove;
  1266. oldRect = new Rect(0, 0, 0, 0);
  1267. }
  1268. }
  1269. #endregion PDFViewer事件
  1270. #region BindingEvent事件
  1271. //同一属性面板,不同的注释类型
  1272. private void AnnotPropertyPanel_AnnotTypeChanged(object sender, Dictionary<AnnotArgsType, object> e)
  1273. {
  1274. if (e != null && sender is SharpsAnnotPropertyViewModel sharpsAnnot)
  1275. {
  1276. AnnotHandlerEventArgs annotArgs = null;
  1277. //PropertyPanel.SaveLastAnnot();
  1278. List<AnnotHandlerEventArgs> annots = new List<AnnotHandlerEventArgs>();
  1279. foreach (AnnotArgsType argsType in e.Keys)
  1280. {
  1281. if (PropertyPanel.annot != null)
  1282. {
  1283. if (PropertyPanel.annot.EventType != argsType)
  1284. {
  1285. PDFViewer.DisableClearSelectAnnot(false);
  1286. PDFViewer.ClearSelectAnnots();
  1287. PDFViewer.SetMouseMode(MouseModes.PanTool);
  1288. CurrentSelectedAnnot = null;
  1289. }
  1290. }
  1291. switch (argsType)
  1292. {
  1293. case AnnotArgsType.AnnotSquare:
  1294. #region TO DO
  1295. //选择一个形状注释A,在选择B(非多选),修改属性成功,以下操作的操作可以解决,
  1296. //可能会出现选择注释A,鼠标直接点击属性面板,注释A取消选中,但还可以对注释A更改属性的BUG
  1297. if (CurrentSelectedAnnot != null)
  1298. {
  1299. if (CurrentSelectedAnnot.EventType == AnnotArgsType.AnnotSquare)
  1300. {
  1301. CurrentSelectedAnnot.PageIndex = -1;
  1302. CurrentSelectedAnnot.AnnotIndex = -1;
  1303. CurrentSelectedAnnot.ClientRect = Rect.Empty;
  1304. annots.Add(CurrentSelectedAnnot);
  1305. }
  1306. }
  1307. if (annots.Count > 0)
  1308. {
  1309. annotArgs = GetRect(annots);
  1310. }
  1311. else
  1312. {
  1313. annotArgs = GetRect();
  1314. }
  1315. #endregion TO DO
  1316. //annotArgs = GetRect();
  1317. break;
  1318. case AnnotArgsType.AnnotCircle:
  1319. #region TO DO
  1320. if (CurrentSelectedAnnot != null)
  1321. {
  1322. if (CurrentSelectedAnnot.EventType == AnnotArgsType.AnnotCircle)
  1323. {
  1324. CurrentSelectedAnnot.PageIndex = -1;
  1325. CurrentSelectedAnnot.AnnotIndex = -1;
  1326. CurrentSelectedAnnot.ClientRect = Rect.Empty;
  1327. annots.Add(CurrentSelectedAnnot);
  1328. }
  1329. }
  1330. if (annots.Count > 0)
  1331. {
  1332. annotArgs = GetCircle(annots);
  1333. }
  1334. else
  1335. {
  1336. annotArgs = GetCircle();
  1337. }
  1338. #endregion TO DO
  1339. //annotArgs = GetCircle();
  1340. break;
  1341. case AnnotArgsType.AnnotLine:
  1342. var LineTag = e[argsType] as string;
  1343. #region TO DO
  1344. if (CurrentSelectedAnnot != null)
  1345. {
  1346. if (CurrentSelectedAnnot.EventType == AnnotArgsType.AnnotLine)
  1347. {
  1348. CurrentSelectedAnnot.PageIndex = -1;
  1349. CurrentSelectedAnnot.AnnotIndex = -1;
  1350. CurrentSelectedAnnot.ClientRect = Rect.Empty;
  1351. if (CurrentSelectedAnnot is LineAnnotArgs lineAnnotArgs)
  1352. {
  1353. if (lineAnnotArgs.HeadLineType >= (C_LINE_TYPE)1 || lineAnnotArgs.TailLineType >= (C_LINE_TYPE)1)
  1354. {
  1355. if (LineTag == "Arrow")
  1356. {
  1357. annots.Add(CurrentSelectedAnnot);
  1358. }
  1359. }
  1360. else
  1361. {
  1362. if (LineTag == "Line")
  1363. {
  1364. annots.Add(CurrentSelectedAnnot);
  1365. }
  1366. }
  1367. }
  1368. }
  1369. }
  1370. if (annots.Count > 0)
  1371. {
  1372. annotArgs = GetArrowLine(LineTag, annots);
  1373. }
  1374. else
  1375. {
  1376. annotArgs = GetArrowLine(LineTag);
  1377. }
  1378. #endregion TO DO
  1379. //annotArgs = GetArrowLine(LineTag);
  1380. break;
  1381. }
  1382. ShowPropertyPanel();
  1383. if (string.IsNullOrEmpty(StrAnnotToolChecked) || StrAnnotToolChecked != "Rect")
  1384. {
  1385. //PDFViewer.SetMouseMode(MouseModes.PanTool);
  1386. return;
  1387. }
  1388. if (annotArgs != null)
  1389. {
  1390. annotArgs.Author = Settings.Default.AppProperties.Description.Author;
  1391. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  1392. PDFViewer.SetToolParam(annotArgs);
  1393. }
  1394. }
  1395. }
  1396. }
  1397. //来自属性面板的事件,更改颜色等属性而触发
  1398. private void AnnotPropertyPanel_DataChanged(object sender, Dictionary<AnnotArgsType, object> e)
  1399. {
  1400. if (e != null)
  1401. {
  1402. foreach (AnnotArgsType argsType in e.Keys)
  1403. {
  1404. var key = ToolExpandDict.FirstOrDefault(q => q.Value == argsType);
  1405. switch (argsType)
  1406. {
  1407. case AnnotArgsType.AnnotHighlight:
  1408. if (e[argsType] is Color)
  1409. {
  1410. HighLightColor = new SolidColorBrush((Color)e[argsType]);
  1411. }
  1412. if (e[argsType] is double)
  1413. {
  1414. HighLightOpacity = (double)e[argsType];
  1415. }
  1416. //创建注释后,修改注释属性,可用于下次创建的注释
  1417. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1418. {
  1419. if (StrAnnotToolChecked == key.Key)
  1420. {
  1421. PDFViewer.SetToolParam(PropertyPanel.annot);
  1422. }
  1423. }
  1424. break;
  1425. case AnnotArgsType.AnnotUnderline:
  1426. if (e[argsType] is Color)
  1427. {
  1428. UnderLineColor = new SolidColorBrush((Color)e[argsType]);
  1429. }
  1430. if (e[argsType] is double)
  1431. {
  1432. underLineOpacity = (double)e[argsType];
  1433. }
  1434. //创建注释后,修改注释属性,可用于下次创建的注释
  1435. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1436. {
  1437. if (StrAnnotToolChecked == key.Key)
  1438. {
  1439. PDFViewer.SetToolParam(PropertyPanel.annot);
  1440. }
  1441. }
  1442. break;
  1443. case AnnotArgsType.AnnotSquiggly:
  1444. if (e[argsType] is Color)
  1445. {
  1446. SquigglyColor = new SolidColorBrush((Color)e[argsType]);
  1447. }
  1448. if (e[argsType] is double)
  1449. {
  1450. SquigglyOpacity = (double)e[argsType];
  1451. }
  1452. //创建注释后,修改注释属性,可用于下次创建的注释
  1453. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1454. {
  1455. if (StrAnnotToolChecked == key.Key)
  1456. {
  1457. PDFViewer.SetToolParam(PropertyPanel.annot);
  1458. }
  1459. }
  1460. break;
  1461. case AnnotArgsType.AnnotStrikeout:
  1462. if (e[argsType] is Color)
  1463. {
  1464. StrikeoutColor = new SolidColorBrush((Color)e[argsType]);
  1465. }
  1466. if (e[argsType] is double)
  1467. {
  1468. StrikeoutOpacity = (double)e[argsType];
  1469. }
  1470. //创建注释后,修改注释属性,可用于下次创建的注释
  1471. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1472. {
  1473. if (StrAnnotToolChecked == key.Key)
  1474. {
  1475. PDFViewer.SetToolParam(PropertyPanel.annot);
  1476. }
  1477. }
  1478. break;
  1479. case AnnotArgsType.AnnotFreehand:
  1480. if (e[argsType] is FreehandAnnotArgs)
  1481. {
  1482. var annot = e[argsType] as FreehandAnnotArgs;
  1483. if (annot != null)
  1484. {
  1485. if (PropertyPanel != null)
  1486. {
  1487. //属性面板,切换橡皮擦后,再回到画笔时,需要恢复最近画笔的属性值
  1488. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  1489. PropertyPanel.AnnotEvent = AnnotEvent;
  1490. var AnnotEvents = new List<AnnotAttribEvent>();
  1491. AnnotEvents.Add(AnnotEvent);
  1492. PropertyPanel.AnnotEvents = AnnotEvents;
  1493. PropertyPanel.annot = annot;
  1494. //手绘注释工具按钮的属性
  1495. // FreehandPath.Opacity = annot.Transparency;
  1496. // FreehandPath.Fill = new SolidColorBrush(annot.InkColor);
  1497. }
  1498. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1499. {
  1500. if (StrAnnotToolChecked == key.Key)
  1501. {
  1502. PDFViewer.SetToolParam(PropertyPanel.annot);
  1503. }
  1504. }
  1505. }
  1506. }
  1507. break;
  1508. case AnnotArgsType.AnnotErase:
  1509. if (e[argsType] is ToggleButton)
  1510. {
  1511. ToggleButton clickBtn = e[argsType] as ToggleButton;
  1512. if (clickBtn.IsChecked == true)
  1513. {
  1514. if (clickBtn.Tag.ToString() != "PenBtn")
  1515. {
  1516. CustomIconToggleBtn btn = new CustomIconToggleBtn();
  1517. btn.Tag = "Freehand";
  1518. btn.IsChecked = true;
  1519. BtnMyTools_Click(btn);
  1520. break;
  1521. }
  1522. else
  1523. {
  1524. CreateEraseArgs();
  1525. }
  1526. }
  1527. }
  1528. break;
  1529. case AnnotArgsType.AnnotSquare:
  1530. case AnnotArgsType.AnnotCircle:
  1531. case AnnotArgsType.AnnotLine:
  1532. case AnnotArgsType.AnnotFreeText:
  1533. //创建注释后,修改注释属性,可用于下次创建的注释
  1534. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1535. {
  1536. if (StrAnnotToolChecked == "Rect" && PropertyPanel.SharpsAnnot == key.Key)
  1537. {
  1538. PDFViewer.SetToolParam(PropertyPanel.annot);
  1539. PropertyPanel.SaveLastAnnot();
  1540. }
  1541. }
  1542. break;
  1543. }
  1544. }
  1545. }
  1546. }
  1547. private void CreateEraseArgs()
  1548. {
  1549. EraseArgs eraseArgs = new EraseArgs();
  1550. eraseArgs.UIBorderColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
  1551. eraseArgs.UIFillColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
  1552. eraseArgs.Thickness = 10;
  1553. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotErase);
  1554. if (annotProperty != null)
  1555. {
  1556. eraseArgs.Thickness = annotProperty.Thickness;
  1557. }
  1558. PDFViewer.ClearSelectAnnots(false);
  1559. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  1560. PDFViewer.SetToolParam(eraseArgs);
  1561. List<AnnotHandlerEventArgs> eraseArgsList = new List<AnnotHandlerEventArgs>();
  1562. if (eraseArgs != null)
  1563. eraseArgsList.Add(eraseArgs);
  1564. AddToPropertyPanel("FreehandAnnotProperty", "Freehand", eraseArgsList);
  1565. }
  1566. #endregion BindingEvent事件
  1567. }
  1568. }