AnnotToolContentViewModel.Command.cs 104 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279
  1. using ComDocumentAIKit;
  2. using ComPDFKit.Import;
  3. using ComPDFKit.PDFAnnotation;
  4. using ComPDFKit.PDFDocument;
  5. using ComPDFKit.PDFDocument.Action;
  6. using ComPDFKit.PDFPage;
  7. using ComPDFKitViewer;
  8. using ComPDFKitViewer.AnnotEvent;
  9. using ComPDFKitViewer.PdfViewer;
  10. using DryIoc;
  11. using ImTools;
  12. using PDF_Master.CustomControl;
  13. using PDF_Master.EventAggregators;
  14. using PDF_Master.Helper;
  15. using PDF_Master.Model.AnnotPanel;
  16. using PDF_Master.Model.BOTA;
  17. using PDF_Master.Model.FillAndSign;
  18. using PDF_Master.Properties;
  19. using PDF_Master.ViewModels.BOTA;
  20. using PDF_Master.ViewModels.PropertyPanel.AnnotPanel;
  21. using PDF_Master.ViewModels.Tools.AnnotManager;
  22. using PDF_Master.Views;
  23. using PDF_Master.Views.BOTA;
  24. using PDF_Master.Views.PropertyPanel.AnnotPanel;
  25. using PDFSettings;
  26. using Prism.Mvvm;
  27. using Prism.Regions;
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Diagnostics;
  31. using System.Linq;
  32. using System.Windows;
  33. using System.Windows.Annotations;
  34. using System.Windows.Controls;
  35. using System.Windows.Controls.Primitives;
  36. using System.Windows.Input;
  37. using System.Windows.Markup;
  38. using System.Windows.Media;
  39. namespace PDF_Master.ViewModels.Tools
  40. {
  41. public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
  42. {
  43. #region 事件绑定和解绑
  44. private void BindingEvent()
  45. {
  46. //属性面板与注释工具栏绑定:属性面板的属性变化,会同步注释工具栏的属性值
  47. //比如在属性面板里更改注释颜色,会同时更新工具栏对应的工具颜色
  48. PropertyPanel.DataChanged -= AnnotPropertyPanel_DataChanged;
  49. PropertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
  50. PropertyPanel.AnnotTypeChanged -= AnnotPropertyPanel_AnnotTypeChanged;
  51. PropertyPanel.AnnotTypeChanged += AnnotPropertyPanel_AnnotTypeChanged;
  52. //快捷键
  53. KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
  54. KeyEventsHelper.KeyDown += ShortCut_KeyDown;
  55. }
  56. private void UnBindingEvent()
  57. {
  58. PropertyPanel.DataChanged -= AnnotPropertyPanel_DataChanged;
  59. PropertyPanel.AnnotTypeChanged -= AnnotPropertyPanel_AnnotTypeChanged;
  60. //快捷盘解绑
  61. KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
  62. }
  63. private void BindingPDFViewerHandler()
  64. {
  65. //来自PDFViewer的响应事件
  66. if (PDFViewer != null)
  67. {
  68. PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
  69. PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
  70. PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
  71. PDFViewer.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
  72. PDFViewer.AnnotCommandHandler -= PDFViewer_AnnotCommandHandler;
  73. PDFViewer.AnnotCommandHandler += PDFViewer_AnnotCommandHandler;
  74. PDFViewer.SnapshotCommandHandler -= PDFViewer_SnapshotCommandHandler;
  75. PDFViewer.SnapshotCommandHandler += PDFViewer_SnapshotCommandHandler;
  76. PDFViewer.PDFActionHandler -= PDFViewer_PDFActionHandler;
  77. PDFViewer.PDFActionHandler += PDFViewer_PDFActionHandler;
  78. PDFViewer.AnnotHoverHandler -= PDFViewer_AnnotHoverHandler;
  79. PDFViewer.AnnotHoverHandler += PDFViewer_AnnotHoverHandler;
  80. PDFViewer.PreviewMouseLeftButtonDown -= PDFViewer_PreviewMouseLeftButtonDown;
  81. PDFViewer.PreviewMouseLeftButtonDown += PDFViewer_PreviewMouseLeftButtonDown;
  82. PDFViewer.MouseLeftButtonUp -= PDFViewer_MouseLeftButtonUp;
  83. PDFViewer.MouseLeftButtonUp += PDFViewer_MouseLeftButtonUp;
  84. CommandManager.AddPreviewExecutedHandler(PDFViewer, PreviewExcutePDFViewer);
  85. }
  86. }
  87. //判断
  88. private void PreviewExcutePDFViewer(object sender, ExecutedRoutedEventArgs e)
  89. {
  90. if (e.Command == ApplicationCommands.Paste)
  91. {
  92. IsPasteShape = true;
  93. ShapeNames.Clear();
  94. var items = PDFViewer.GetCopyAnnotData();
  95. foreach (var item in items)
  96. {
  97. bool IsShape = false;
  98. if (item is FreehandAnnotArgs)
  99. {
  100. foreach (var point in ViewContentViewModel.FillAndSign)
  101. {
  102. if ((item as FreehandAnnotArgs).PageIndex == point.PageIndex && (item as FreehandAnnotArgs).AnnotIndex == point.AnnotIndex)
  103. {
  104. ShapeNames.Add(point.Shape);
  105. IsShape = true;
  106. continue;
  107. }
  108. }
  109. if (!IsShape)
  110. {
  111. ShapeNames.Add("Annot");
  112. }
  113. }
  114. else
  115. {
  116. ShapeNames.Add("Annot");
  117. }
  118. }
  119. }
  120. if (e.Command == ApplicationCommands.Copy)
  121. {
  122. }
  123. }
  124. private void UnBindingPDFViewerHandler()
  125. {
  126. if (PDFViewer != null)
  127. {
  128. PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
  129. PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
  130. PDFViewer.AnnotCommandHandler -= PDFViewer_AnnotCommandHandler;
  131. PDFViewer.SnapshotCommandHandler -= PDFViewer_SnapshotCommandHandler;
  132. PDFViewer.PDFActionHandler -= PDFViewer_PDFActionHandler;
  133. PDFViewer.AnnotHoverHandler -= PDFViewer_AnnotHoverHandler;
  134. PDFViewer.PreviewMouseLeftButtonDown -= PDFViewer_PreviewMouseLeftButtonDown;
  135. }
  136. }
  137. #endregion 事件绑定和解绑
  138. #region 与触发事件调用相关的函数
  139. public StickyAnnotArgs GetCurrentAnnot { get; set; }
  140. //鼠标左键双击注释
  141. private void PDFViewer_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  142. {
  143. if (e.ClickCount == 1)
  144. {
  145. //不禁止取消选中注释
  146. //PDFViewer.DisableClearSelectAnnot(false);
  147. //if (viewContentViewModel.mainViewModel.IsBookMode)
  148. //{
  149. // PDFViewer.SetMouseMode(MouseModes.PanTool);
  150. // var annotArgs = new SelectToolArgs();
  151. // PDFViewer.SetToolParam(annotArgs);
  152. //}
  153. //PropertyPanel.IsSharpAnnotSelected = true;
  154. //PropertyPanel.IsFreeHandSelected = true;
  155. //PDFViewer.ClearSelectAnnots();
  156. //注释工具 选中图章,阅读页选择其他注释后,点击阅读页空白,属性面板需要显示图章面板
  157. //if (StrAnnotToolChecked == "Stamp")
  158. //{
  159. // GetStamp();
  160. //}
  161. //AnnotHandlerEventArgs annotArgs = CurrentSelectedAnnot;
  162. //if (annotArgs != null)
  163. //{
  164. // var type = annotArgs.EventType;
  165. // if (type == AnnotArgsType.AnnotSticky)
  166. // {
  167. // customStickyPopup.GetCurrentAnnot = GetCurrentAnnot;
  168. // customStickyPopup.GetPDFViewer = PDFViewer;
  169. // //多个文档时候,未知原因弹窗对象没有更改,导致PDFViewer以及GetCurrentAnnot,没有及时刷新
  170. // PDFViewer.SetStickyNotePop(customStickyPopup);
  171. // (annotArgs as StickyAnnotArgs).PopupEditWnd();
  172. // }
  173. //}
  174. }
  175. #region 0515调整的双击逻辑
  176. //if (e.ClickCount == 2)
  177. //{
  178. // if (CurrentSelectedAnnot != null)
  179. // {
  180. // var type = CurrentSelectedAnnot.EventType;
  181. // if (type != AnnotArgsType.AnnotSticky && type != AnnotArgsType.AnnotFreeText && type != AnnotArgsType.AnnotLink
  182. // /*&&
  183. // type != AnnotArgsType.AnnotHighlight && type != AnnotArgsType.AnnotUnderline
  184. // && type != AnnotArgsType.AnnotStrikeout*/)
  185. // {
  186. // int dpi = DpiHelpers.Dpi;
  187. // var rect = CurrentSelectedAnnot.ClientRect;
  188. // rect = new Rect(
  189. // rect.Left * PDFViewer.ZoomFactor,
  190. // rect.Top * PDFViewer.ZoomFactor,
  191. // rect.Width * PDFViewer.ZoomFactor,
  192. // rect.Height * PDFViewer.ZoomFactor);
  193. // if (PDFViewer.Parent is ContentControl ui)
  194. // {
  195. // //var ui = PDFViewer.Parent as ContentControl;
  196. // if (ui != null)
  197. // {
  198. // var point = e.GetPosition(ui);
  199. // int pageIndex = 0;
  200. // Point pagePoint = new Point(0, 0);
  201. // PDFViewer.ConvertViewPointToPage(point, out pageIndex, out pagePoint);
  202. // if (pagePoint.X >= rect.Left && pagePoint.X <= rect.Right && pagePoint.Y >= rect.Top && pagePoint.Y <= rect.Bottom)
  203. // PopAnnotNoteText(CurrentSelectedAnnot);
  204. // }
  205. // }
  206. // }
  207. // if (type == AnnotArgsType.AnnotSticky)
  208. // {
  209. // customStickyPopup.GetCurrentAnnot = GetCurrentAnnot;
  210. // customStickyPopup.GetPDFViewer = PDFViewer;
  211. // //多个文档时候,未知原因弹窗对象没有更改,导致PDFViewer以及GetCurrentAnnot,没有及时刷新
  212. // PDFViewer.SetStickyNotePop(customStickyPopup);
  213. // (CurrentSelectedAnnot as StickyAnnotArgs).PopupEditWnd();
  214. // }
  215. // }
  216. //}
  217. #endregion 0515调整的双击逻辑
  218. }
  219. private void PDFViewer_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  220. {
  221. //BOTA所有列表都需要响应 单击阅读页取消多选
  222. if (ViewContentViewModel.OpenBOTA == true)
  223. {
  224. int annotCount = PDFViewer.GetSelectAnnotCount();
  225. if (annotCount == 0)
  226. {
  227. //2023/08/23 Windows:BOTA列表,移除点击阅读页取消选中逻辑
  228. //this.events.GetEvent<CleanSelectAllEvent>().Publish(new CleanSelectAllArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, IsCleanSelectAll = true });
  229. CleanAnnotationSelect();
  230. }
  231. else if (annotCount == 1)
  232. {
  233. selectedAnnotation = PDFViewer.GetSelectionAnnots()[0];
  234. }
  235. }
  236. }
  237. private void CleanAnnotationSelect()
  238. {
  239. bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  240. if (ViewContentViewModel.OpenBOTA && bOTAContent.TabItemAnnotation.IsSelected)
  241. {
  242. AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
  243. if (annotation.AnnotationList.SelectedItems.Count > 0)
  244. {
  245. annotation.AnnotationList.SelectedItems.Clear();
  246. }
  247. }
  248. }
  249. //超链接跳转
  250. private void PDFViewer_PDFActionHandler(object sender, ComPDFKit.PDFDocument.Action.CPDFAction action)
  251. {
  252. if (action == null)
  253. {
  254. return;
  255. }
  256. switch (action.ActionType)
  257. {
  258. case C_ACTION_TYPE.ACTION_TYPE_GOTO:
  259. if (PDFViewer != null)
  260. {
  261. CPDFGoToAction gotoAction = action as CPDFGoToAction;
  262. CPDFDestination dest = gotoAction.GetDestination(PDFViewer.Document);
  263. if (dest != null)
  264. {
  265. CPDFPage docPage = PDFViewer.Document.PageAtIndex(dest.PageIndex, false);
  266. if (docPage != null)
  267. {
  268. PDFViewer.GoToPage(dest.PageIndex, new System.Windows.Point(dest.Position_X, docPage.PageSize.Height - dest.Position_Y));
  269. }
  270. else
  271. {
  272. PDFViewer.GoToPage(dest.PageIndex, new System.Windows.Point(dest.Position_X, dest.Position_Y));
  273. }
  274. }
  275. }
  276. break;
  277. case C_ACTION_TYPE.ACTION_TYPE_URI:
  278. {
  279. CPDFUriAction uriAction = action as CPDFUriAction;
  280. string uri = uriAction.GetUri();
  281. try
  282. {
  283. if (!string.IsNullOrEmpty(uri))
  284. {
  285. Process.Start(uri);
  286. }
  287. }
  288. catch
  289. {
  290. }
  291. }
  292. break;
  293. }
  294. }
  295. private void GetSelectedAnnots(AnnotAttribEvent e, bool isActive = false)
  296. {
  297. var annot = e.AnnotItemsList[0];
  298. switch (annot.EventType)
  299. {
  300. case AnnotArgsType.AnnotHighlight:
  301. if (e.IsAnnotCreateReset)
  302. {
  303. GetHighLight();
  304. }
  305. else
  306. {
  307. GetHighLight(e.AnnotItemsList);
  308. }
  309. break;
  310. case AnnotArgsType.AnnotUnderline:
  311. if (e.IsAnnotCreateReset)
  312. {
  313. GetUnderLine();
  314. }
  315. else
  316. {
  317. GetUnderLine(e.AnnotItemsList);
  318. }
  319. break;
  320. case AnnotArgsType.AnnotStrikeout:
  321. if (e.IsAnnotCreateReset)
  322. {
  323. GetStrikeout();
  324. }
  325. else
  326. {
  327. GetStrikeout(e.AnnotItemsList);
  328. }
  329. break;
  330. case AnnotArgsType.AnnotSquiggly:
  331. GetSquiggly(e.AnnotItemsList);
  332. break;
  333. case AnnotArgsType.AnnotFreehand:
  334. GetFreehand(e.AnnotItemsList);
  335. break;
  336. case AnnotArgsType.AnnotFreeText:
  337. //根据状态设置对应的界面
  338. //if (e.IsAnnotCreateReset)
  339. //{
  340. // GetFreetext();
  341. //}
  342. //else
  343. //{
  344. // GetFreetext(e.AnnotItemsList);
  345. //}
  346. //暂时不根据状态设置对应的界面,需要拿到数据
  347. //文本注释 (字体大小样式)修改属性后,点击阅读页会置原
  348. //先这样操作,若有问题再改回来
  349. GetFreetext(e.AnnotItemsList);
  350. break;
  351. case AnnotArgsType.AnnotSquare:
  352. GetRect(e.AnnotItemsList);
  353. break;
  354. case AnnotArgsType.AnnotCircle:
  355. GetCircle(e.AnnotItemsList);
  356. break;
  357. case AnnotArgsType.AnnotLine:
  358. bool isLine = true;
  359. if (e.Attribs.ContainsKey(AnnotAttrib.LineStart))
  360. {
  361. 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)
  362. {
  363. isLine = false;
  364. }
  365. }
  366. if (e.Attribs.ContainsKey(AnnotAttrib.LineEnd))
  367. {
  368. 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)
  369. {
  370. isLine = false;
  371. }
  372. }
  373. if (isLine)
  374. GetArrowLine("Line", e.AnnotItemsList);
  375. else
  376. GetArrowLine("Arrow", e.AnnotItemsList);
  377. break;
  378. case AnnotArgsType.AnnotLink:
  379. //viewContentViewModel.IsCreateLink = false;
  380. //e.IsAnnotCreateReset= true;
  381. if (StrAnnotToolChecked == "Link")
  382. {
  383. PropertyPanel.IsAddLink = false;
  384. }
  385. GetLink(e.AnnotItemsList, e);
  386. break;
  387. case AnnotArgsType.AnnotSticky:
  388. GetStickyNote(e.AnnotItemsList);
  389. GetCurrentAnnot = e.AnnotItemsList[0] as StickyAnnotArgs;
  390. customStickyPopup.GetCurrentAnnot = GetCurrentAnnot;
  391. customStickyPopup.GetPDFViewer = PDFViewer;
  392. customStickyPopup.AnnotToolContentVM = this;
  393. //多个文档时候,未知原因弹窗对象没有更改,导致PDFViewer以及GetCurrentAnnot,没有及时刷新
  394. PDFViewer.SetStickyNotePop(customStickyPopup);
  395. if (e.IsAnnotCreateReset)
  396. {
  397. PropertyPanel.annot = e.AnnotItemsList[0];
  398. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib(), PDFViewer);
  399. PropertyPanel.AnnotEvents = null;
  400. PropertyPanel.AnnotEvent = AnnotEvent;
  401. PropertyPanel.annotlists = e.AnnotItemsList;
  402. }
  403. //0515 调整单击 便签弹窗
  404. if (e.AnnotItemsList.Count == 1 && e.IsMouseRightActive == false)
  405. {
  406. if (e.AnnotItemsList[0] is StickyAnnotArgs stickyAnnotArgs)
  407. {
  408. stickyAnnotArgs.PopupEditWnd();
  409. CloseAnnotToolTip();
  410. }
  411. }
  412. else
  413. {
  414. customStickyPopup.Close();
  415. }
  416. break;
  417. case AnnotArgsType.AnnotStamp:
  418. if (e.IsAnnotCreateReset == false)
  419. {
  420. GetStamp();
  421. }
  422. break;
  423. }
  424. }
  425. /// <summary>
  426. /// 选中注释 区分签名、图章、手绘
  427. /// </summary>
  428. /// <param name="annotlist"></param>
  429. private void SelectedSignature(List<AnnotHandlerEventArgs> annotlist)
  430. {
  431. if (annotlist == null || annotlist.Count == 0)
  432. return;
  433. var annot = annotlist[0];
  434. if (annot.EventType != AnnotArgsType.AnnotStamp && annot.EventType != AnnotArgsType.AnnotFreehand)
  435. return;
  436. if (annot.PageIndex < 0 || annot.AnnotIndex < 0)
  437. return;
  438. var signAnnot = ViewContentViewModel.AnnotSignatures.FirstOrDefault(temp => temp.Item1 == annot.PageIndex && temp.Item2 == annot.AnnotIndex);
  439. if (signAnnot == null)
  440. {
  441. //var key = ToolExpandDict.FirstOrDefault(q => q.Value == annot.EventType);
  442. //if (!string.IsNullOrEmpty(StrAnnotToolChecked))
  443. // StrAnnotToolChecked = key.Key.ToString();
  444. //if (annot.EventType == AnnotArgsType.AnnotStamp)
  445. //{
  446. // StrAnnotToolChecked = "Stamp";
  447. //}
  448. //else
  449. //{
  450. // StrAnnotToolChecked = "";
  451. //}
  452. }
  453. else
  454. {
  455. if (string.IsNullOrEmpty(StrAnnotToolChecked))
  456. {
  457. ViewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  458. //GetSignature();
  459. //StrAnnotToolChecked = "Signature";
  460. }
  461. }
  462. }
  463. private void AddAnnotSignature(AnnotHandlerEventArgs annot)
  464. {
  465. if ((annot.EventType != AnnotArgsType.AnnotStamp && annot.EventType != AnnotArgsType.AnnotFreehand) ||
  466. (annot.PageIndex < 0 || annot.AnnotIndex < 0)) return;
  467. if (StrAnnotToolChecked == "Signature")
  468. {
  469. if (ViewContentViewModel.AnnotSignatures == null)
  470. ViewContentViewModel.AnnotSignatures = new List<Tuple<int, int>>();
  471. var signAnnot = ViewContentViewModel.AnnotSignatures.FirstOrDefault(temp => temp.Item1 == annot.PageIndex && temp.Item2 == annot.AnnotIndex);
  472. if (signAnnot == null)
  473. {
  474. ViewContentViewModel.AnnotSignatures.Add(new Tuple<int, int>(annot.PageIndex, annot.AnnotIndex));
  475. }
  476. }
  477. }
  478. #endregion 与触发事件调用相关的函数
  479. #region PDFViewer事件
  480. private AnnotHandlerEventArgs CurrentSelectedAnnot = null;
  481. private bool isShowPropertyPanel = false;
  482. //选中和非选中注释
  483. private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
  484. {
  485. CurrentSelectedAnnot = null;
  486. if (ViewContentViewModel.CurrentBar != "TabItemAnnotation")
  487. {
  488. //viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  489. return;
  490. }
  491. if (e == null)
  492. {
  493. //注释列表取消选中
  494. //不能写在这里 容易造成死循环
  495. ViewContentViewModel.mainViewModel.AnnotMouseLeftButtonDown = false;
  496. if (ViewContentViewModel.IsRightMenuSelectedTextAddLink || ViewContentViewModel.IsRightMenuCreateLink)
  497. {
  498. ViewContentViewModel.IsRightMenuSelectedTextAddLink = false;
  499. ViewContentViewModel.IsRightMenuCreateLink = false;
  500. ViewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  501. var annotArgs = new SelectToolArgs();
  502. PDFViewer.SetToolParam(annotArgs);
  503. return;
  504. }
  505. if (string.IsNullOrWhiteSpace(StrAnnotToolChecked))
  506. {
  507. //PDFViewer.ClearSelectAnnots();
  508. CleanPropertyPanel();
  509. if (PropertyPanel.IsAddLink == false && ViewContentViewModel.IsReadModeShow == false)
  510. {
  511. bool iso = ViewContentViewModel.mainViewModel.IsBookMode;
  512. ViewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  513. }
  514. //PDFViewer.SetMouseMode(MouseModes.PanTool);
  515. //HandToolIsCheckedEvent(false);
  516. return;
  517. }
  518. else
  519. {
  520. SetTextAnnotProperty();
  521. SetSharpsAnnotProperty();
  522. //不可以写,手绘 改透明度 会有问题
  523. //if (StrAnnotToolChecked == "Freehand")
  524. //{
  525. // GetFreehand();
  526. //}
  527. //if (StrAnnotToolChecked== "StickyNote")
  528. //{
  529. // CleanPropertyPanel();
  530. // GetStickyNote();
  531. //}
  532. //点击空白需要清空
  533. if (StrAnnotToolChecked == "Freetext")
  534. {
  535. CleanPropertyPanel();
  536. }
  537. //注释工具 选中图章,阅读页选择其他注释后,点击阅读页空白,属性面板需要显示图章面板
  538. if (StrAnnotToolChecked == "Stamp")
  539. {
  540. GetStamp();
  541. }
  542. }
  543. }
  544. if (e != null)
  545. {
  546. if (e.IsMouseRightActive)
  547. {
  548. ViewContentViewModel.mainViewModel.AnnotMouseLeftButtonDown = true;
  549. CloseAnnotToolTip();
  550. if (string.IsNullOrEmpty(StrAnnotToolChecked))
  551. {
  552. ShowPropertyPanel(false);
  553. return;
  554. }
  555. }
  556. var annot = e.AnnotItemsList[0];
  557. if (annot != null)
  558. {
  559. if (e.AnnotItemsList.Count == 1)
  560. {
  561. ViewContentViewModel.IsMultiSelected = false;
  562. //IsAnnotCreateReset:是否为创建注释的状态
  563. if (e.IsAnnotCreateReset == false)
  564. {
  565. CurrentSelectedAnnot = annot;
  566. //未选注释工具-形状注释,选中形状注释,属性面板不显示(矩形、圆、线、箭头)
  567. //未选注释工具-手绘,选中手绘注释,属性面板不显示橡皮擦
  568. SetPropertyPanelValue(annot);
  569. if (ViewContentViewModel.mainViewModel.IsBookMode == false)
  570. {
  571. GetSelectedAnnots(e, true);
  572. }
  573. PropertyPanelShowOrVisibility(e, annot);
  574. //注释列表同步选中
  575. SelectedBotaAnnotationList(e);
  576. }
  577. else
  578. {
  579. if (!string.IsNullOrEmpty(StrAnnotToolChecked) || PropertyPanel.IsAddLink == true)
  580. {
  581. GetSelectedAnnots(e);
  582. PDFViewer.SetToolParam(annot);
  583. }
  584. else
  585. {
  586. if (IsNoSelectMenu)
  587. {
  588. return;
  589. }
  590. CleanPropertyPanel();
  591. PDFViewer.SetMouseMode(MouseModes.PanTool);
  592. HandToolIsCheckedEvent(false);
  593. ViewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  594. }
  595. #region //TODO: 修改注释后,会作用到之后添加的注释中。因此先把此逻辑“创建注释后,会自动回到默认值”注释掉
  596. //注释代码原因:设计已经重新调整逻辑:所有注释创建后,编辑属性,所有属性会作用于下次创建的注释中。
  597. //if (annot.EventType != AnnotArgsType.AnnotStrikeout &&
  598. //annot.EventType != AnnotArgsType.AnnotUnderline &&
  599. //annot.EventType != AnnotArgsType.AnnotHighlight &&
  600. //annot.EventType != AnnotArgsType.AnnotSquiggly &&
  601. //annot.EventType != AnnotArgsType.AnnotLink &&
  602. //annot.EventType != AnnotArgsType.AnnotFreehand &&
  603. //annot.EventType != AnnotArgsType.AnnotSticky &&
  604. //)
  605. //{
  606. // if (ToolExpandDict.ContainsValue(e.AnnotItemsList[0].EventType))
  607. // {
  608. // var strLineAnnotTag = "";
  609. // if (e.AnnotItemsList[0] is LineAnnotArgs)
  610. // {
  611. // var lineAnnot = e.AnnotItemsList[0] as LineAnnotArgs;
  612. // if (lineAnnot.HeadLineType == C_LINE_TYPE.LINETYPE_NONE && lineAnnot.TailLineType == C_LINE_TYPE.LINETYPE_NONE)
  613. // {
  614. // strLineAnnotTag = "Line";
  615. // }
  616. // else
  617. // {
  618. // strLineAnnotTag = "Arrow";
  619. // }
  620. // }
  621. // foreach (var item in ToolExpandDict)
  622. // {
  623. // if (item.Value == e.AnnotItemsList[0].EventType)
  624. // {
  625. // annot = null;//新建注释时,回到默认值
  626. // if (string.IsNullOrEmpty(strLineAnnotTag))
  627. // {
  628. // FindAnnotTypeKey(item.Key, ref annot);
  629. // break;
  630. // }
  631. // else
  632. // {
  633. // if (strLineAnnotTag == item.Key)
  634. // {
  635. // FindAnnotTypeKey(item.Key, ref annot);
  636. // break;
  637. // }
  638. // }
  639. // }
  640. // }
  641. // PDFViewer.SetToolParam(annot);
  642. // }
  643. //}
  644. //设计重新调整,阅读页空白处,右键菜单,添加链接需要显示,其他和pro mac一样的效果,不显示属性栏
  645. //if (isRightMenuAddAnnot && annot.EventType!=AnnotArgsType.AnnotLink)
  646. //{
  647. // ShowPropertyPanel(false);
  648. //}
  649. //else
  650. //{
  651. // ShowPropertyPanel();
  652. //}
  653. #endregion //TODO: 修改注释后,会作用到之后添加的注释中。因此先把此逻辑“创建注释后,会自动回到默认值”注释掉
  654. }
  655. }
  656. else
  657. {
  658. //框选注释
  659. BoxAnnotation(e);
  660. }
  661. }
  662. }
  663. }
  664. /// <summary>
  665. /// 框选注释
  666. /// </summary>
  667. /// <param name="e"></param>
  668. private void BoxAnnotation(AnnotAttribEvent e)
  669. {
  670. PropertyPanel.annotlists = e.AnnotItemsList;
  671. ViewContentViewModel.IsMultiSelected = true;
  672. //viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  673. // MVP 在对多选注释做处理
  674. bool isDifferentAnnotTyle = AnnotTransfer.IsDifferentTypeAnnots(e.AnnotItemsList);
  675. if (ViewContentViewModel.mainViewModel.IsBookMode)
  676. {
  677. ShowPropertyPanel(false);
  678. }
  679. else
  680. {
  681. BottomToolContent bottomTool = null;
  682. BottomToolContentViewModel bottomToolVM = ViewContentViewModel.GetBottomToolContentVM(ref bottomTool);
  683. if (isDifferentAnnotTyle)
  684. {
  685. if (bottomToolVM != null)
  686. {
  687. if (bottomToolVM.IsShowViewModular == false)
  688. {
  689. //viewContentViewModel.IsReadModeShow = false;
  690. ViewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  691. ShowPropertyPanel(false);
  692. }
  693. }
  694. else
  695. {
  696. //viewContentViewModel.IsReadModeShow = false;
  697. ViewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  698. ShowPropertyPanel(false);
  699. }
  700. }
  701. else
  702. {
  703. ViewContentViewModel.IsReadModeShow = false;
  704. if (bottomToolVM != null)
  705. {
  706. bottomToolVM.IsShowViewModular = false;
  707. }
  708. GetSelectedAnnots(e);
  709. if (string.IsNullOrEmpty(StrAnnotToolChecked) == true)
  710. {
  711. var count = e.AnnotItemsList.FindAll(r => r.EventType == AnnotArgsType.AnnotStamp).Count;
  712. if (count > 0)
  713. {
  714. ShowPropertyPanel(false);
  715. }
  716. else
  717. {
  718. ShowPropertyPanel(true);
  719. }
  720. }
  721. else
  722. {
  723. ShowPropertyPanel(true);
  724. }
  725. }
  726. }
  727. }
  728. /// <summary>
  729. /// 设置选中注释工具 签名,面板的显示
  730. /// </summary>
  731. /// <param name="e"></param>
  732. /// <param name="annot"></param>
  733. private void PropertyPanelShowOrVisibility(AnnotAttribEvent e, AnnotHandlerEventArgs annot)
  734. {
  735. SelectedSignature(e.AnnotItemsList);
  736. if (Settings.Default.AppProperties.InitialVIew.AutoExpandProperty
  737. && annot.EventType != AnnotArgsType.AnnotStamp && StrAnnotToolChecked != "Signature"
  738. && annot.EventType != AnnotArgsType.AnnotLink && ViewContentViewModel.mainViewModel.IsBookMode == false)
  739. {
  740. var signAnnot = ViewContentViewModel.AnnotSignatures.FirstOrDefault(temp => temp.Item1 == annot.PageIndex && temp.Item2 == annot.AnnotIndex);
  741. if (signAnnot == null)
  742. {
  743. if (e.IsMouseRightActive)
  744. {
  745. ShowPropertyPanel(isShowPropertyPanel);
  746. }
  747. else
  748. {
  749. ShowPropertyPanel(true);
  750. }
  751. }
  752. }
  753. else if (StrAnnotToolChecked == "Signature")
  754. {
  755. GetSignature();
  756. }
  757. }
  758. /// <summary>
  759. /// 设置选中注释工具形状, 点击阅读页空白时候显示内容
  760. /// </summary>
  761. private void SetSharpsAnnotProperty()
  762. {
  763. if (StrAnnotToolChecked == "Rect" && PropertyPanel.IsSelectedTextAddShape == false)
  764. {
  765. //AnnotHandlerEventArgs annotArgs = null;//暂时不知道会不会影响效果,先注释
  766. //此处不能用这个方法更新创建注释的属性 会导致死循环
  767. //选择文字 点击矩形 会导致死循环
  768. // FindAnnotTypeKey(StrAnnotToolChecked, ref annotArgs);
  769. CleanPropertyPanel();
  770. switch (PropertyPanel.SharpsAnnot)
  771. {
  772. case "Rect":
  773. GetRect();
  774. break;
  775. case "Circle":
  776. GetCircle();
  777. break;
  778. case "Arrow":
  779. GetArrowLine("Arrow");
  780. break;
  781. case "Line":
  782. GetArrowLine("Line");
  783. break;
  784. }
  785. //return; //暂时不知道会不会影响效果,先注释
  786. }
  787. }
  788. /// <summary>
  789. /// 设置选中注释工具高亮、下划线、删除线, 点击阅读页空白时候显示内容
  790. /// </summary>
  791. private void SetTextAnnotProperty()
  792. {
  793. switch (StrAnnotToolChecked)
  794. {
  795. case "HighLight"://字体高亮
  796. CleanPropertyPanel();
  797. if (selectedAnnotation != null)
  798. {
  799. if (selectedAnnotation.EventType == AnnotArgsType.AnnotHighlight)
  800. {
  801. GetHighLight();
  802. }
  803. }
  804. else
  805. {
  806. GetHighLight();
  807. }
  808. break;
  809. case "UnderLine"://下划线
  810. CleanPropertyPanel();
  811. if (selectedAnnotation != null)
  812. {
  813. if (selectedAnnotation.EventType == AnnotArgsType.AnnotUnderline)
  814. {
  815. GetUnderLine();
  816. }
  817. }
  818. else
  819. {
  820. GetUnderLine();
  821. }
  822. break;
  823. case "Strikeout"://删除线
  824. CleanPropertyPanel();
  825. if (selectedAnnotation != null)
  826. {
  827. if (selectedAnnotation.EventType == AnnotArgsType.AnnotStrikeout)
  828. {
  829. GetStrikeout();
  830. }
  831. }
  832. else
  833. {
  834. GetStrikeout();
  835. }
  836. break;
  837. }
  838. }
  839. /// <summary>
  840. ///未选注释工具-形状注释,选中形状注释,属性面板不显示(矩形、圆、线、箭头)
  841. ///未选注释工具-手绘,选中手绘注释,属性面板不显示橡皮擦
  842. /// </summary>
  843. /// <param name="annot"></param>
  844. private void SetPropertyPanelValue(AnnotHandlerEventArgs annot)
  845. {
  846. if (StrAnnotToolChecked != "Rect"
  847. && (annot.EventType == AnnotArgsType.AnnotSquare ||
  848. annot.EventType == AnnotArgsType.AnnotCircle ||
  849. annot.EventType == AnnotArgsType.AnnotLine))
  850. {
  851. PropertyPanel.IsSharpAnnotSelected = false;
  852. }
  853. else
  854. {
  855. PropertyPanel.IsSharpAnnotSelected = true;
  856. }
  857. if (StrAnnotToolChecked != "Freehand" && annot.EventType == AnnotArgsType.AnnotFreehand)
  858. {
  859. PropertyPanel.IsFreeHandSelected = false;
  860. }
  861. else
  862. {
  863. PropertyPanel.IsFreeHandSelected = true;
  864. }
  865. isShowPropertyPanel = ViewContentViewModel.IsPropertyOpen;
  866. }
  867. private void CleanPropertyPanel()
  868. {
  869. PropertyPanel.annot = null;
  870. PropertyPanel.AnnotEvents = null;
  871. PropertyPanel.AnnotEvent = null;
  872. PropertyPanel.annotlists = null;
  873. }
  874. /// <summary>
  875. /// 注释列表同步选中
  876. /// </summary>
  877. /// <param name="e"></param>
  878. private void SelectedBotaAnnotationList(AnnotAttribEvent e)
  879. {
  880. #region 之前版本
  881. //var list = e.GetPageAnnotsIndex();
  882. //bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  883. ////if (viewContentViewModel.OpenBOTA == false || isTabItemAnnotation == false || bOTAContent.TabItemAnnotation.IsSelected == false)
  884. ////{
  885. //// viewContentViewModel.OpenBOTA = true;
  886. //// bOTAContent.TabItemAnnotation.IsSelected = true;
  887. ////}
  888. //if (ViewContentViewModel.OpenBOTA == true && isTabItemAnnotation == true /*&& bOTAContent.TabItemAnnotation.IsSelected == true*/ && list != null && list.Count > 0)
  889. //{
  890. // if (list.Keys.Count == 0)
  891. // {
  892. // return;
  893. // }
  894. // var pageindex = new List<int>(list.Keys);
  895. // List<int> annotes = new List<int>();
  896. // list.TryGetValue(pageindex[0], out annotes);
  897. // int annoteindex = annotes[0];
  898. // AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
  899. // if (viewModel != null)
  900. // {
  901. // selectedAnnotation = viewModel.AnnotationListItems.FindFirst(a => a.PageIndex == pageindex[0] && a.AnnotIndex == annoteindex);
  902. // viewModel.ScrollToAnnot(pageindex[0], annoteindex, annotation.AnnotationList);
  903. // }
  904. //}
  905. #endregion 之前版本
  906. #region v1.3.0 第一版
  907. //var list = e.GetPageAnnotsIndex();
  908. //if (list != null && list.Count > 0 && ViewContentViewModel.mainViewModel.AnnotMouseLeftButtonDown == false)
  909. //{
  910. // if (list.Keys.Count == 0)
  911. // {
  912. // return;
  913. // }
  914. // var pageindex = new List<int>(list.Keys);
  915. // List<int> annotes = new List<int>();
  916. // list.TryGetValue(pageindex[0], out annotes);
  917. // int annoteindex = annotes[0];
  918. // bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  919. // if (ViewContentViewModel.OpenBOTA == false)
  920. // {
  921. // bOTAContentViewModel.OpenBOTA();
  922. // }
  923. // if (bOTAContent.TabItemAnnotation.IsSelected == false)
  924. // {
  925. // bOTAContent.TabItemAnnotation.IsSelected = true;
  926. // }
  927. // AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
  928. // selectedAnnotation = viewModel.AnnotationListItems.FindFirst(a => a.PageIndex == pageindex[0] && a.AnnotIndex == annoteindex);
  929. // viewModel.ScrollToAnnot(pageindex[0], annoteindex, annotation.AnnotationList);
  930. //}
  931. #endregion v1.3.0 第一版
  932. //形状、图章、签名等是添加后选中,如果注释列表数据量过大,会卡顿,影响用户体验
  933. if (PDFViewer.GetSelectAnnotCount() > 0 && ViewContentViewModel.mainViewModel.AnnotMouseLeftButtonDown == false && string.IsNullOrEmpty(StrAnnotToolChecked))
  934. {
  935. List<AnnotHandlerEventArgs> annotationHandlers = PDFViewer.GetSelectionAnnots();
  936. bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  937. if (ViewContentViewModel.OpenBOTA == false)
  938. {
  939. bOTAContentViewModel.OpenBOTA();
  940. }
  941. if (bOTAContent.TabItemAnnotation.IsSelected == false)
  942. {
  943. bOTAContent.TabItemAnnotation.IsSelected = true;
  944. }
  945. if (annotationHandlers[0].EventType != AnnotArgsType.AnnotLink)
  946. {
  947. events.GetEvent<RefreshAnnotationEvent>().Publish(new RefreshAnnotationArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, IsAll = false, IsSelect = true, Pageindex = annotationHandlers[0].PageIndex, AnnotIndex = annotationHandlers[0].AnnotIndex, IsExpand = false });
  948. }
  949. }
  950. }
  951. //在注释工具的状态下,右键菜单
  952. private void PDFViewer_AnnotCommandHandler(object sender, AnnotCommandArgs e)
  953. {
  954. if (e.AnnotEventArgsList == null || (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool))
  955. return;
  956. if ((UIElement)sender != null)
  957. {
  958. //绑定命令执行前的拦截事件,对于未解密权限的文档进行复制限制
  959. CommandManager.AddPreviewExecutedHandler((UIElement)sender, PreviewExcute);
  960. }
  961. switch (e.CommandType)
  962. {
  963. case CommandType.Context:
  964. if (e.AnnotEventArgsList.Count > 0)
  965. {
  966. if (App.mainWindowViewModel.SelectedItem.IsInReadctonMode && e.AnnotEventArgsList[0].EventType == AnnotArgsType.AnnotRedaction)
  967. {
  968. //绑定标记密文处右键菜单
  969. events.GetEvent<RedactionCommandEvent>().Publish(new RedactionCommandEventArgs() { UniCode = App.mainWindowViewModel.SelectedItem.Unicode, Sender = sender, args = e });
  970. }
  971. else
  972. {
  973. if (e.AnnotEventArgsList.Count == 1)
  974. {
  975. var selectedAnnot = e.AnnotEventArgsList[0];
  976. PopMenuCheckedLineDash(selectedAnnot);
  977. PopMenuCheckedFontFamily(selectedAnnot);
  978. PopMenuCheckedTextAglin(selectedAnnot);
  979. switch (selectedAnnot.EventType)
  980. {
  981. case AnnotArgsType.AnnotHighlight:
  982. case AnnotArgsType.AnnotUnderline:
  983. case AnnotArgsType.AnnotStrikeout:
  984. case AnnotArgsType.AnnotSquiggly:
  985. if (selectedAnnot.EventType == AnnotArgsType.AnnotHighlight)
  986. {
  987. colorContent.ItemSource = AnnotColorList.GetColorList(ColorSelectorType.Highlight);
  988. }
  989. else
  990. {
  991. colorContent.ItemSource = AnnotColorList.GetColorList(ColorSelectorType.Border);
  992. }
  993. e.PopupMenu = HightAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  994. break;
  995. case AnnotArgsType.AnnotFreehand:
  996. e.PopupMenu = FreeHandAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  997. break;
  998. case AnnotArgsType.AnnotFreeText:
  999. e.PopupMenu = FreeTextAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  1000. break;
  1001. case AnnotArgsType.AnnotSticky:
  1002. e.PopupMenu = StrickNoteAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  1003. break;
  1004. case AnnotArgsType.AnnotSquare:
  1005. case AnnotArgsType.AnnotCircle:
  1006. ShapeAnnotPopMenu.SetVisual("ShapeDirect", false);
  1007. ShapeAnnotPopMenu.SetVisual("ShapeFillColor", true);
  1008. e.PopupMenu = ShapeAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  1009. break;
  1010. case AnnotArgsType.AnnotLine:
  1011. ShapeAnnotPopMenu.SetVisual("ShapeFillColor", false);
  1012. ShapeAnnotPopMenu.SetVisual("ShapeDirect", true);
  1013. e.PopupMenu = ShapeAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  1014. break;
  1015. case AnnotArgsType.AnnotLink:
  1016. e.PopupMenu = LinkAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  1017. break;
  1018. case AnnotArgsType.AnnotStamp:
  1019. e.PopupMenu = StampAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  1020. break;
  1021. }
  1022. }
  1023. else
  1024. {
  1025. bool isHigh = true;//是否为高亮
  1026. foreach (var item in e.AnnotEventArgsList)
  1027. {
  1028. if (AnnotTransfer.IsHightAnnot(item) == false)
  1029. {
  1030. isHigh = false;
  1031. break;
  1032. }
  1033. }
  1034. MultiAnnotPopMenu.SetVisual("MultiCopy", !isHigh);
  1035. MultiAnnotPopMenu.SetVisual("MultiCut", !isHigh);
  1036. e.PopupMenu = MultiAnnotPopMenu.OpenMenu(e.AnnotEventArgsList, sender);
  1037. }
  1038. }
  1039. if (e.PopupMenu != null)
  1040. {
  1041. e.Handle = true;
  1042. }
  1043. }
  1044. else
  1045. {
  1046. if (e.PressOnSelectedText || e.CommandTarget == TargetType.ImageSelection)
  1047. {
  1048. //右键添加注释,形状注释添加之后会选中
  1049. ViewContentViewModel.mainViewModel.AnnotMouseLeftButtonDown = true;
  1050. e.PopupMenu = SelectedTextOrImageContextMenu(sender, e);
  1051. if (e.PopupMenu != null)
  1052. {
  1053. e.Handle = true;
  1054. }
  1055. }
  1056. else
  1057. {
  1058. e.PopupMenu = ViewerContextMenu(sender);
  1059. if (e.PopupMenu != null)
  1060. {
  1061. e.Handle = true;
  1062. }
  1063. }
  1064. }
  1065. break;
  1066. default:
  1067. e?.DoCommand();
  1068. break;
  1069. }
  1070. }
  1071. private void PreviewExcute(object sender, ExecutedRoutedEventArgs e)
  1072. {
  1073. if (e.Command == ApplicationCommands.Copy || e.Command == ApplicationCommands.Cut)
  1074. {
  1075. if (!ViewContentViewModel.CheckPermissionBeforeOption())
  1076. {
  1077. //没有权限,或者权限解密不成功时,拦截该命令
  1078. e.Handled = true;
  1079. }
  1080. }
  1081. }
  1082. /// <summary>
  1083. /// 右键菜单,选中字体样式按钮状态
  1084. /// </summary>
  1085. /// <param name="annot"></param>
  1086. private void PopMenuCheckedFontFamily(AnnotHandlerEventArgs annot)
  1087. {
  1088. if (annot != null)
  1089. {
  1090. if (annot.EventType == AnnotArgsType.AnnotFreeText)
  1091. {
  1092. var freeText = annot as FreeTextAnnotArgs;
  1093. string fontFamily = freeText.FontName;
  1094. if (fontFamily == "Arial")
  1095. {
  1096. fontFamily = "Helvetica";
  1097. }
  1098. if (fontFamily == "Courier New")
  1099. {
  1100. fontFamily = "Courier";
  1101. }
  1102. if (fontFamily == "Times New Roman")
  1103. {
  1104. fontFamily = "Times";
  1105. }
  1106. FreeTextAnnotPopMenu.SetIsChecked(fontFamily, true);
  1107. }
  1108. }
  1109. }
  1110. /// <summary>
  1111. /// 右键菜单,选中文本内容对齐按钮状态
  1112. /// </summary>
  1113. /// <param name="annot"></param>
  1114. private void PopMenuCheckedTextAglin(AnnotHandlerEventArgs annot)
  1115. {
  1116. if (annot != null)
  1117. {
  1118. if (annot.EventType == AnnotArgsType.AnnotFreeText)
  1119. {
  1120. var freeText = annot as FreeTextAnnotArgs;
  1121. switch (freeText.Align)
  1122. {
  1123. case TextAlignment.Left:
  1124. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinLeft", true);
  1125. break;
  1126. case TextAlignment.Center:
  1127. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinCenter", true);
  1128. break;
  1129. case TextAlignment.Right:
  1130. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinRight", true);
  1131. break;
  1132. case TextAlignment.Justify:
  1133. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinJustify", true);
  1134. break;
  1135. default:
  1136. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinLeft", false);
  1137. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinCenter", false);
  1138. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinRight", false);
  1139. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinJustify", false);
  1140. break;
  1141. }
  1142. }
  1143. }
  1144. }
  1145. //右键菜单,选中虚实线按钮状态
  1146. private void PopMenuCheckedLineDash(AnnotHandlerEventArgs annot)
  1147. {
  1148. if (annot != null)
  1149. {
  1150. bool isSolidLineDash = true;
  1151. if (annot.EventType == AnnotArgsType.AnnotFreehand)
  1152. {
  1153. var freeHand = annot as FreehandAnnotArgs;
  1154. isSolidLineDash = AnnotTransfer.IsSolidStyle(freeHand.LineDash);
  1155. FreeHandAnnotPopMenu.SetIsChecked(isSolidLineDash ? "FreeHandSolid" : "FreeHandDash", true);
  1156. }
  1157. else if (annot.EventType == AnnotArgsType.AnnotSquare)
  1158. {
  1159. var square = annot as SquareAnnotArgs;
  1160. isSolidLineDash = AnnotTransfer.IsSolidStyle(square.LineDash);
  1161. ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
  1162. }
  1163. else if (annot.EventType == AnnotArgsType.AnnotCircle)
  1164. {
  1165. var circle = annot as CircleAnnotArgs;
  1166. isSolidLineDash = AnnotTransfer.IsSolidStyle(circle.LineDash);
  1167. ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
  1168. }
  1169. else if (annot.EventType == AnnotArgsType.AnnotLine)
  1170. {
  1171. var line = annot as LineAnnotArgs;
  1172. isSolidLineDash = AnnotTransfer.IsSolidStyle(line.LineDash);
  1173. ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
  1174. }
  1175. }
  1176. }
  1177. /// <summary>
  1178. /// 内容选择工具
  1179. /// </summary>
  1180. /// <param name="sender"></param>
  1181. /// <param name="e"></param>
  1182. private void PDFViewer_SnapshotCommandHandler(object sender, SnapshotCommandArgs e)
  1183. {
  1184. SnapshotEditToolArgs snapToolArgs = new SnapshotEditToolArgs();
  1185. if (PDFViewer.ToolManager.CurrentAnnotArgs is SnapshotEditToolArgs)
  1186. {
  1187. snapToolArgs = (SnapshotEditToolArgs)PDFViewer.ToolManager.CurrentAnnotArgs;
  1188. SnapshotEditMenuViewModel.SnapToolArgs = snapToolArgs;
  1189. SnapshotEditMenuViewModel.PDFViewer = PDFViewer;
  1190. SnapshotEditMenuViewModel.areaCropPageUndoManager = new AreaCropPageUndoManager(PDFViewer);
  1191. SnapshotEditMenuViewModel.SnapToolEvent -= SnapshotEditMenuViewModel_SnapToolEvent; ;
  1192. SnapshotEditMenuViewModel.SnapToolEvent += SnapshotEditMenuViewModel_SnapToolEvent;
  1193. var popMenu = App.Current.FindResource("SnapshotContextMenu") as ContextMenu;
  1194. if (e.HitSnapshotTool && e.SnapshotRect.Width > 0 && e.SnapshotRect.Height > 0)
  1195. {
  1196. e.PopupMenu = popMenu;
  1197. e.Handle = true;
  1198. if (popMenu != null && popMenu.Items.Count == 5)
  1199. {
  1200. //复制
  1201. MenuItem menuItem = popMenu.Items[0] as MenuItem;
  1202. menuItem.CommandTarget = PDFViewer;
  1203. menuItem.Command = SnapshotEditMenuViewModel.SnapCopyCommand;
  1204. //导出
  1205. menuItem = popMenu.Items[1] as MenuItem;
  1206. menuItem.CommandTarget = PDFViewer;
  1207. if (menuItem.Items.Count == 3)
  1208. {
  1209. MenuItem menuItem1 = menuItem.Items[0] as MenuItem;
  1210. menuItem1.CommandTarget = PDFViewer;
  1211. menuItem1.Command = SnapshotEditMenuViewModel.ExportPNGCommand;
  1212. menuItem1 = menuItem.Items[1] as MenuItem;
  1213. menuItem1.CommandTarget = PDFViewer;
  1214. menuItem1.Command = SnapshotEditMenuViewModel.ExportJPGCommand;
  1215. menuItem1 = menuItem.Items[2] as MenuItem;
  1216. menuItem1.CommandTarget = PDFViewer;
  1217. menuItem1.Command = SnapshotEditMenuViewModel.ExportPDFCommand;
  1218. }
  1219. //裁剪
  1220. menuItem = popMenu.Items[2] as MenuItem;
  1221. menuItem.CommandTarget = PDFViewer;
  1222. menuItem.Command = SnapshotEditMenuViewModel.CroppingCommand;
  1223. //缩放至所选区域
  1224. menuItem = popMenu.Items[3] as MenuItem;
  1225. menuItem.CommandTarget = PDFViewer;
  1226. menuItem.Visibility = Visibility.Collapsed;
  1227. //menuItem.Command = snapshotEditMenuViewModel.CroppingCommand;
  1228. //打印
  1229. menuItem = popMenu.Items[4] as MenuItem;
  1230. menuItem.CommandTarget = PDFViewer;
  1231. menuItem.Command = SnapshotEditMenuViewModel.PrintCommand;
  1232. }
  1233. //解决内容选择器 右键菜单闪现消失的问题,sdk库有更新,需要确认哪边提交
  1234. System.Threading.Tasks.Task.Factory.StartNew(() =>
  1235. {
  1236. System.Threading.Thread.Sleep(200);
  1237. PDFViewer.Dispatcher.Invoke(() =>
  1238. {
  1239. popMenu.IsOpen = true;
  1240. popMenu.StaysOpen = true;
  1241. });
  1242. });
  1243. }
  1244. }
  1245. }
  1246. private void SnapshotEditMenuViewModel_SnapToolEvent(object sender, KeyValuePair<string, object> e)
  1247. {
  1248. switch (e.Key)
  1249. {
  1250. case "CloseSnap":
  1251. {
  1252. #region to do
  1253. //var item = PDFViewerTab.SelectedItem as TabItem;
  1254. //if (item == null)
  1255. //{
  1256. // ClearSelectedToolPanel();
  1257. // return;
  1258. //}
  1259. //Grid grid = item.Content as Grid;
  1260. //if (grid == null || grid.Children.Count == 0)
  1261. //{
  1262. // ClearSelectedToolPanel();
  1263. // return;
  1264. //}
  1265. //PDFViewerCtrl pdfViewer = grid.Children[0] as PDFViewerCtrl;
  1266. //if (pdfViewer == null)
  1267. //{
  1268. // ClearSelectedToolPanel();
  1269. // return;
  1270. //}
  1271. #endregion to do
  1272. switch (PDFViewer.MouseMode)
  1273. {
  1274. case MouseModes.SelectTextTool:
  1275. break;
  1276. default:
  1277. BtnSelecttoolIsChecked = false;
  1278. //BtnHandIsChecked = true;
  1279. PDFViewer.EnableZoom(true);
  1280. PDFViewer.EnableScroll(true);
  1281. PDFViewer.SetMouseMode(MouseModes.PanTool);
  1282. HandToolIsCheckedEvent(false);
  1283. break;
  1284. }
  1285. }
  1286. break;
  1287. default:
  1288. break;
  1289. }
  1290. }
  1291. private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
  1292. {
  1293. bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  1294. AnnotationContentViewModel viewModel = null;
  1295. AnnotationContent annotation = null;
  1296. //OpenBOTA关闭时也要进入
  1297. //if (viewContentViewModel.OpenBOTA == false)
  1298. //{
  1299. viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out annotation);
  1300. //}
  1301. bool isMultiple = false;
  1302. Dictionary<int, List<int>> selectAnnotDicts = new Dictionary<int, List<int>>();
  1303. Dictionary<int, List<int>> selectFreehandDicts = new Dictionary<int, List<int>>();
  1304. if (e != null && e.Count > 0)
  1305. {
  1306. for (int i = 0; i < e.Count; i++)
  1307. {
  1308. AnnotEditEvent editEvent = e[i];
  1309. bool isVisible = PDFViewer.CheckAnnotVisible(editEvent.PageIndex, editEvent.AnnotIndex);
  1310. var annot = editEvent.EditAnnotArgs;
  1311. switch (editEvent.EditAction)
  1312. {
  1313. case ActionType.Add:
  1314. #region 区分复制填写签名图形
  1315. if (IsPasteShape)
  1316. {
  1317. if (editEvent.EditAnnotArgs.EventType == AnnotArgsType.AnnotFreehand)
  1318. {
  1319. if (ShapeNames.Count != 0 && ShapeNames[i] != "Annot")
  1320. {
  1321. try
  1322. {
  1323. ViewContentViewModel.FillAndSign.Add(new FillAndSignIsShape(editEvent.PageIndex, editEvent.AnnotIndex, ShapeNames[i]));
  1324. }
  1325. catch { }
  1326. }
  1327. }
  1328. }
  1329. #endregion 区分复制填写签名图形
  1330. if (ViewContentViewModel.CurrentBar != "TabItemAnnotation")
  1331. {
  1332. //填写与签名在此区域不选中,不添加selectAnnotDicts词典当中
  1333. }
  1334. else
  1335. {
  1336. if (PropertyPanel.IsMultiSelected)
  1337. {
  1338. if (selectAnnotDicts.ContainsKey(editEvent.PageIndex) == false)
  1339. {
  1340. selectAnnotDicts.Add(editEvent.PageIndex, new List<int>());
  1341. selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1342. }
  1343. else
  1344. {
  1345. selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1346. }
  1347. isMultiple = true;
  1348. }
  1349. else
  1350. {
  1351. if (
  1352. annot.EventType == AnnotArgsType.AnnotSquare || annot.EventType == AnnotArgsType.AnnotCircle ||
  1353. annot.EventType == AnnotArgsType.AnnotLine || annot.EventType == AnnotArgsType.AnnotStamp
  1354. /*|| annot.EventType == AnnotArgsType.AnnotSticky ||annot.EventType == AnnotArgsType.AnnotFreeText */)
  1355. {
  1356. if (selectAnnotDicts.ContainsKey(editEvent.PageIndex) == false)
  1357. {
  1358. selectAnnotDicts.Add(editEvent.PageIndex, new List<int>());
  1359. selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1360. }
  1361. else
  1362. {
  1363. selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1364. }
  1365. isMultiple = true;
  1366. }
  1367. //添加后不选中的注释,需要额外处理
  1368. if (annot.EventType == AnnotArgsType.AnnotFreehand || annot.EventType == AnnotArgsType.AnnotSticky || annot.EventType == AnnotArgsType.AnnotFreeText)
  1369. {
  1370. if (selectFreehandDicts.ContainsKey(editEvent.PageIndex) == false)
  1371. {
  1372. selectFreehandDicts.Add(editEvent.PageIndex, new List<int>());
  1373. selectFreehandDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1374. }
  1375. else
  1376. {
  1377. selectFreehandDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1378. }
  1379. isMultiple = true;
  1380. }
  1381. //复制后 粘贴选中
  1382. if (annot.EventType == AnnotArgsType.AnnotLink)
  1383. {
  1384. PDFViewer.SelectAnnotation(annot.PageIndex, annot.AnnotIndex);
  1385. }
  1386. }
  1387. }
  1388. if (viewModel != null)
  1389. {
  1390. int pageindex = editEvent.PageIndex;
  1391. int annotindex = editEvent.AnnotIndex;
  1392. viewModel.UpdateAddedAnnot(bOTAContent, pageindex, annotindex);
  1393. }
  1394. //添加签名注释,用于未保存前跟图章手绘注释的区分
  1395. if (StrAnnotToolChecked == "Signature")
  1396. {
  1397. AddAnnotSignature(editEvent.EditAnnotArgs);
  1398. }
  1399. //if (editEvent.EditAnnotArgs.EventType == AnnotArgsType.AnnotFreeText)
  1400. //{
  1401. // (editEvent.EditAnnotArgs as FreeTextAnnotArgs).LineWidth = 0;
  1402. //}
  1403. break;
  1404. case ActionType.Modify:
  1405. //undo/redo,字体大小联动,刷新属性面板数据
  1406. if (string.IsNullOrEmpty(StrAnnotToolChecked) == false)
  1407. {
  1408. List<AnnotHandlerEventArgs> selectedArgs = new List<AnnotHandlerEventArgs>() { annot };
  1409. switch (annot.EventType)
  1410. {
  1411. case AnnotArgsType.AnnotFreeText://文本
  1412. GetFreetext(selectedArgs);
  1413. break;
  1414. }
  1415. }
  1416. if (viewModel != null)
  1417. {
  1418. int pageindex = editEvent.PageIndex;
  1419. int annotindex = editEvent.AnnotIndex;
  1420. viewModel.UpdateModifiedAnnot(pageindex, annotindex);
  1421. }
  1422. break;
  1423. case ActionType.Del:
  1424. //isTabItemAnnotation = IsBOTATabItemShow(out bOTAContentViewModel, out bOTAContent, "TabItemAnnotation");
  1425. //if (viewContentViewModel.OpenBOTA == true && bOTAContent.TabItemAnnotation.IsSelected)
  1426. //{
  1427. // AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
  1428. #region//填写与签名 删除缓存信息列表
  1429. //if (Shape != "None")
  1430. //{
  1431. for (int j = 0; j < ViewContentViewModel.FillAndSign.Count; j++)
  1432. {
  1433. if (ViewContentViewModel.FillAndSign[j].PageIndex == editEvent.PageIndex && ViewContentViewModel.FillAndSign[j].AnnotIndex == editEvent.AnnotIndex)
  1434. {
  1435. ViewContentViewModel.FillAndSign.Remove(ViewContentViewModel.FillAndSign[j]);
  1436. }
  1437. }
  1438. for (int j = 0; j < ViewContentViewModel.AnnotSignatures.Count; j++)
  1439. {
  1440. if (ViewContentViewModel.AnnotSignatures[j].Item1 == editEvent.PageIndex && ViewContentViewModel.AnnotSignatures[j].Item2 == editEvent.AnnotIndex)
  1441. {
  1442. ViewContentViewModel.AnnotSignatures.Remove(ViewContentViewModel.AnnotSignatures[j]);
  1443. }
  1444. }
  1445. //}
  1446. #endregion PDFViewer事件
  1447. if (viewModel != null)
  1448. {
  1449. int pageindex = editEvent.PageIndex;
  1450. int annotindex = editEvent.AnnotIndex;
  1451. viewModel.DeleteModifiedAnnot(pageindex, annotindex);
  1452. }
  1453. if (string.IsNullOrEmpty(StrAnnotToolChecked))
  1454. {
  1455. if (ViewContentViewModel.CurrentBar != "TabItemAnnotation")
  1456. {
  1457. //填写与签名在此区域不选中,不添加selectAnnotDicts词典当中
  1458. }
  1459. else
  1460. {
  1461. ExitAnnotationTool();
  1462. ViewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  1463. }
  1464. }
  1465. else
  1466. {
  1467. switch (StrAnnotToolChecked)
  1468. {
  1469. case "Link":
  1470. PropertyPanel.IsAddLink = true;
  1471. GetLink();
  1472. events.GetEvent<LinkAnnotTipCloseEvent>().Publish(new LinkAnnotTipCloseArgs() { UniCode = App.mainWindowViewModel.SelectedItem.Unicode });
  1473. break;
  1474. }
  1475. }
  1476. break;
  1477. case ActionType.TextEdit:
  1478. break;
  1479. default:
  1480. break;
  1481. }
  1482. }
  1483. IsPasteShape = false;
  1484. SetMultipleAnnot(isMultiple, selectAnnotDicts, selectFreehandDicts);
  1485. //MultipleSelectionAnnot(e);
  1486. //空白处 右键菜单 添加注释 为单次添加,不连续添加
  1487. if (IsNoSelectMenu && PropertyPanel.IsAddLink == false)
  1488. {
  1489. ViewContentViewModel.ReadModeIsShowProperty = false;
  1490. IsNoSelectMenu = false;
  1491. ExitAnnotationTool();
  1492. }
  1493. if (ViewContentViewModel.IsRightMenuSelectedTextAddLink == false)
  1494. {
  1495. ViewContentViewModel.ReadModeIsShowProperty = false;
  1496. }
  1497. }
  1498. }
  1499. /// <summary>
  1500. /// 设置多选注释
  1501. /// </summary>
  1502. /// <param name="isMultiple"></param>
  1503. /// <param name="selectAnnotDicts">添加后选中的注释</param>
  1504. /// <param name="selectFreehandDicts">添加后不选中的注释,需要额外处理</param>
  1505. private void SetMultipleAnnot(bool isMultiple, Dictionary<int, List<int>> selectAnnotDicts, Dictionary<int, List<int>> selectFreehandDicts)
  1506. {
  1507. if (isMultiple)
  1508. {
  1509. Dictionary<int, List<int>> dict = new Dictionary<int, List<int>>();
  1510. //阅读页多选注释,只能在当前页多选,不可以跨页多选
  1511. if (selectAnnotDicts.Count >= 1)
  1512. {
  1513. PDFViewer.ClearSelectAnnots();
  1514. //if (StrAnnotToolChecked != "Signature")
  1515. //{
  1516. PDFViewer.SelectAnnotation(selectAnnotDicts);
  1517. if (selectFreehandDicts.Count >= 1)
  1518. {
  1519. if (selectFreehandDicts.FirstOrDefault().Value.Count > 1)
  1520. {
  1521. //先把键都合并到dict中,值都是新创建的
  1522. foreach (var key in selectAnnotDicts.Keys)
  1523. {
  1524. if (!dict.ContainsKey(key))
  1525. {
  1526. dict.Add(key, new List<int>());
  1527. }
  1528. }
  1529. foreach (var key in selectFreehandDicts.Keys)
  1530. {
  1531. if (!dict.ContainsKey(key))
  1532. {
  1533. dict.Add(key, new List<int>());
  1534. }
  1535. }
  1536. //分别将值添加进去
  1537. foreach (var ele in selectAnnotDicts)
  1538. {
  1539. dict[ele.Key].AddRange(ele.Value);
  1540. }
  1541. foreach (var ele in selectFreehandDicts)
  1542. {
  1543. dict[ele.Key].AddRange(ele.Value);
  1544. }
  1545. //Dictionary<int, List<int>> items2 = selectAnnotDicts.Union(selectFreehandDicts).ToDictionary(k => k.Key, v => v.Value);
  1546. PDFViewer.ClearSelectAnnots();
  1547. PDFViewer.SelectAnnotation(dict);
  1548. }
  1549. //}
  1550. }
  1551. }
  1552. else
  1553. {
  1554. if (selectFreehandDicts.Count >= 1)
  1555. {
  1556. if (selectFreehandDicts.FirstOrDefault().Value.Count > 1)
  1557. {
  1558. PDFViewer.ClearSelectAnnots();
  1559. PDFViewer.SelectAnnotation(selectFreehandDicts);
  1560. }
  1561. }
  1562. }
  1563. }
  1564. #region 之前版本
  1565. //if (isMultiple && selectAnnotDicts.Count >= 1)
  1566. //{
  1567. // //PDFViewer.DisableClearSelectAnnot(false);
  1568. // PDFViewer.ClearSelectAnnots();
  1569. // if (StrAnnotToolChecked != "Signature")
  1570. // {
  1571. // //PDFViewer.DisableClearSelectAnnot(true);
  1572. // PDFViewer.SelectAnnotation(selectAnnotDicts);
  1573. // //禁止取消选中注释
  1574. // //PDFViewer.DisableClearSelectAnnot(false);
  1575. // }
  1576. //}
  1577. //if (isMultiple && selectFreehandDicts.Count >= 1)
  1578. //{
  1579. // PDFViewer.ClearSelectAnnots();
  1580. // if (selectFreehandDicts.FirstOrDefault().Value.Count >= 1)
  1581. // {
  1582. // PDFViewer.SelectAnnotation(selectFreehandDicts);
  1583. // }
  1584. //}
  1585. #endregion 之前版本
  1586. }
  1587. //复制多个注释,粘贴后,默认注释未选中状态
  1588. private void MultipleSelectionAnnot(List<AnnotEditEvent> e)
  1589. {
  1590. bool isAdd = false;
  1591. Dictionary<int, List<int>> selectAnnotDicts = new Dictionary<int, List<int>>();
  1592. foreach (var item in e)
  1593. {
  1594. if (item.EditAction == ActionType.Add || item.EditAction == ActionType.Modify)
  1595. {
  1596. var annot = item.EditAnnotArgs;
  1597. if (annot.EventType == AnnotArgsType.AnnotSquare || annot.EventType == AnnotArgsType.AnnotCircle ||
  1598. annot.EventType == AnnotArgsType.AnnotLine || annot.EventType == AnnotArgsType.AnnotStamp || annot.EventType == AnnotArgsType.AnnotFreeText || annot.EventType == AnnotArgsType.AnnotFreehand)
  1599. {
  1600. if (selectAnnotDicts.ContainsKey(item.PageIndex) == false)
  1601. {
  1602. selectAnnotDicts.Add(item.PageIndex, new List<int>());
  1603. selectAnnotDicts[item.PageIndex].Add(item.AnnotIndex);
  1604. }
  1605. else
  1606. {
  1607. selectAnnotDicts[item.PageIndex].Add(item.AnnotIndex);
  1608. }
  1609. isAdd = true;
  1610. }
  1611. }
  1612. }
  1613. if (isAdd && selectAnnotDicts.Count >= 1)
  1614. {
  1615. PDFViewer.ClearSelectAnnots();
  1616. if (StrAnnotToolChecked != "Signature")
  1617. {
  1618. PDFViewer.SelectAnnotation(selectAnnotDicts);
  1619. }
  1620. }
  1621. }
  1622. //阅读页悬浮相应
  1623. /// <summary>
  1624. /// 阅读页鼠标悬浮在注释上的虚线
  1625. /// </summary>
  1626. /// <param name="sender"></param>
  1627. /// <param name="e"></param>
  1628. private void PDFViewer_AnnotHoverHandler(object sender, AnnotHoverData e)
  1629. {
  1630. if (e != null && e.DrawContext != null)
  1631. {
  1632. //if (StrAnnotToolChecked == "Freetext")
  1633. //{
  1634. // if ((e.Annot is CPDFFreeTextAnnotation annotation) == false)
  1635. // {
  1636. // isDown = false;
  1637. // Trace.WriteLine(isDown);
  1638. // return;
  1639. // }
  1640. // else
  1641. // {
  1642. // isDown=true;
  1643. // Trace.WriteLine(isDown);
  1644. // }
  1645. //}
  1646. if (StrAnnotToolChecked != "Link")
  1647. {
  1648. if (e.Annot is CPDFLinkAnnotation linkAnnotation)
  1649. {
  1650. return;
  1651. }
  1652. }
  1653. if (StrAnnotToolChecked == "Freehand" || (IsNoSelectMenu && isRightMenuAddAnnot))
  1654. {
  1655. return;
  1656. }
  1657. Rect hoverRect = new Rect(
  1658. e.PaintRect.Left - 2,
  1659. e.PaintRect.Top - 2,
  1660. e.PaintRect.Width + 4,
  1661. e.PaintRect.Height + 4);
  1662. if (e.Annot is CPDFTextAnnotation sticky)
  1663. {
  1664. hoverRect = new Rect(
  1665. e.PaintRect.Left - 2,
  1666. e.PaintRect.Top + 2,
  1667. e.PaintRect.Width + 5,
  1668. e.PaintRect.Height + 2);
  1669. }
  1670. Pen hoverPen = new Pen(new SolidColorBrush(Color.FromArgb(0xff, 0x11, 0x8A, 0xff)), 1);
  1671. hoverPen.DashStyle = DashStyles.Dash;
  1672. e.DrawContext?.DrawRectangle(null, hoverPen, hoverRect);
  1673. //便签,显示ToolTip内容
  1674. if (e.Annot != null && e.Annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_TEXT)
  1675. {
  1676. PopAnnotToolTip(e.Annot.GetRect(), hoverRect, e.Annot.GetContent());
  1677. return;
  1678. }
  1679. }
  1680. CloseAnnotToolTip();
  1681. }
  1682. private void PDFViewer_MouseMove(object sender, MouseEventArgs e)
  1683. {
  1684. if (sender != null && PDFViewer.ToolTip != null && PDFViewer.Parent != null)
  1685. {
  1686. //鼠标移到注释之外,关闭ToolTip浮窗
  1687. var newPoint = e.GetPosition(PDFViewer.Parent as ContentControl);
  1688. var isOutw = newPoint.X > (oldRect.X + oldRect.Width + 4);
  1689. var isOuth = newPoint.Y > (oldRect.Y + oldRect.Height + 4);
  1690. if (newPoint.X < oldRect.X || newPoint.Y < oldRect.Y || isOutw || isOuth)
  1691. {
  1692. CloseAnnotToolTip();
  1693. }
  1694. }
  1695. }
  1696. private Rect oldRect = new Rect(0, 0, 0, 0);
  1697. private void PopAnnotToolTip(CRect placementRect, Rect hoverRect, string content)
  1698. {
  1699. //便签,显示ToolTip内容
  1700. if (PDFViewer.ToolTip == null)
  1701. {
  1702. if (string.IsNullOrEmpty(content) == false)
  1703. {
  1704. ToolTip TipChild = new ToolTip();
  1705. TipChild.Style = App.Current.Resources["FlowToolTip"] as Style;
  1706. TipChild.MaxWidth = 246;
  1707. TipChild.Content = content;
  1708. TipChild.Visibility = Visibility.Visible;
  1709. TipChild.IsOpen = true;
  1710. TipChild.Placement = PlacementMode.Right;
  1711. TipChild.PlacementRectangle = new Rect(placementRect.left, placementRect.top, placementRect.right, placementRect.bottom);
  1712. TipChild.PlacementTarget = PDFViewer.Parent as ContentControl;
  1713. TipChild.Placement = PlacementMode.MousePoint;
  1714. PDFViewer.ToolTip = TipChild;
  1715. oldRect = hoverRect;
  1716. PDFViewer.MouseMove -= PDFViewer_MouseMove;
  1717. PDFViewer.MouseMove += PDFViewer_MouseMove;
  1718. }
  1719. }
  1720. }
  1721. //关闭ToolTip
  1722. private void CloseAnnotToolTip()
  1723. {
  1724. if (PDFViewer.ToolTip != null && PDFViewer.ToolTip is ToolTip)
  1725. {
  1726. ToolTip oldTips = (ToolTip)PDFViewer.ToolTip;
  1727. oldTips.IsOpen = false;
  1728. oldTips.Visibility = Visibility.Collapsed;
  1729. PDFViewer.ToolTip = null;
  1730. PDFViewer.MouseMove -= PDFViewer_MouseMove;
  1731. oldRect = new Rect(0, 0, 0, 0);
  1732. }
  1733. }
  1734. #endregion PDFViewer事件
  1735. #region BindingEvent事件
  1736. //同一属性面板,不同的注释类型
  1737. private void AnnotPropertyPanel_AnnotTypeChanged(object sender, Dictionary<AnnotArgsType, object> e)
  1738. {
  1739. if (e != null && sender is SharpsAnnotPropertyViewModel sharpsAnnot)
  1740. {
  1741. AnnotHandlerEventArgs annotArgs = null;
  1742. //PropertyPanel.SaveLastAnnot();
  1743. List<AnnotHandlerEventArgs> annots = new List<AnnotHandlerEventArgs>();
  1744. foreach (AnnotArgsType argsType in e.Keys)
  1745. {
  1746. if (PropertyPanel.annot != null)
  1747. {
  1748. if (PropertyPanel.annot.EventType != argsType)
  1749. {
  1750. PDFViewer.DisableClearSelectAnnot(false);
  1751. PDFViewer.ClearSelectAnnots();
  1752. PDFViewer.SetMouseMode(MouseModes.PanTool);
  1753. CurrentSelectedAnnot = null;
  1754. }
  1755. }
  1756. switch (argsType)
  1757. {
  1758. case AnnotArgsType.AnnotSquare:
  1759. #region TO DO
  1760. //选择一个形状注释A,在选择B(非多选),修改属性成功,以下操作的操作可以解决,
  1761. //可能会出现选择注释A,鼠标直接点击属性面板,注释A取消选中,但还可以对注释A更改属性的BUG
  1762. if (CurrentSelectedAnnot != null)
  1763. {
  1764. if (CurrentSelectedAnnot.EventType == AnnotArgsType.AnnotSquare)
  1765. {
  1766. //CurrentSelectedAnnot.PageIndex = -1;
  1767. //CurrentSelectedAnnot.AnnotIndex = -1;
  1768. CurrentSelectedAnnot.ClientRect = Rect.Empty;
  1769. annots.Add(CurrentSelectedAnnot);
  1770. }
  1771. }
  1772. if (annots.Count > 0)
  1773. {
  1774. annotArgs = GetRect(annots);
  1775. }
  1776. else
  1777. {
  1778. annotArgs = GetRect();
  1779. }
  1780. #endregion TO DO
  1781. //annotArgs = GetRect();
  1782. break;
  1783. case AnnotArgsType.AnnotCircle:
  1784. #region TO DO
  1785. if (CurrentSelectedAnnot != null)
  1786. {
  1787. if (CurrentSelectedAnnot.EventType == AnnotArgsType.AnnotCircle)
  1788. {
  1789. //CurrentSelectedAnnot.PageIndex = -1;
  1790. //CurrentSelectedAnnot.AnnotIndex = -1;
  1791. CurrentSelectedAnnot.ClientRect = Rect.Empty;
  1792. annots.Add(CurrentSelectedAnnot);
  1793. }
  1794. }
  1795. if (annots.Count > 0)
  1796. {
  1797. annotArgs = GetCircle(annots);
  1798. }
  1799. else
  1800. {
  1801. annotArgs = GetCircle();
  1802. }
  1803. #endregion TO DO
  1804. //annotArgs = GetCircle();
  1805. break;
  1806. case AnnotArgsType.AnnotLine:
  1807. var LineTag = e[argsType] as string;
  1808. #region TO DO
  1809. if (CurrentSelectedAnnot != null)
  1810. {
  1811. if (CurrentSelectedAnnot.EventType == AnnotArgsType.AnnotLine)
  1812. {
  1813. //CurrentSelectedAnnot.PageIndex = -1;
  1814. //CurrentSelectedAnnot.AnnotIndex = -1;
  1815. CurrentSelectedAnnot.ClientRect = Rect.Empty;
  1816. if (CurrentSelectedAnnot is LineAnnotArgs lineAnnotArgs)
  1817. {
  1818. if (lineAnnotArgs.HeadLineType >= (C_LINE_TYPE)1 || lineAnnotArgs.TailLineType >= (C_LINE_TYPE)1)
  1819. {
  1820. if (LineTag == "Arrow")
  1821. {
  1822. annots.Add(CurrentSelectedAnnot);
  1823. }
  1824. }
  1825. else
  1826. {
  1827. if (LineTag == "Line")
  1828. {
  1829. annots.Add(CurrentSelectedAnnot);
  1830. }
  1831. }
  1832. }
  1833. }
  1834. }
  1835. if (annots.Count > 0)
  1836. {
  1837. annotArgs = GetArrowLine(LineTag, annots);
  1838. }
  1839. else
  1840. {
  1841. annotArgs = GetArrowLine(LineTag);
  1842. }
  1843. #endregion TO DO
  1844. //annotArgs = GetArrowLine(LineTag);
  1845. break;
  1846. }
  1847. ShowPropertyPanel();
  1848. if (string.IsNullOrEmpty(StrAnnotToolChecked) || StrAnnotToolChecked != "Rect")
  1849. {
  1850. //PDFViewer.SetMouseMode(MouseModes.PanTool);
  1851. return;
  1852. }
  1853. if (annotArgs != null)
  1854. {
  1855. annotArgs.Author = Settings.Default.AppProperties.Description.Author;
  1856. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  1857. PDFViewer.SetToolParam(annotArgs);
  1858. }
  1859. }
  1860. }
  1861. }
  1862. //来自属性面板的事件,更改颜色等属性而触发
  1863. private void AnnotPropertyPanel_DataChanged(object sender, Dictionary<AnnotArgsType, object> e)
  1864. {
  1865. if (e != null)
  1866. {
  1867. PropertyPanel.annot.Author = Settings.Default.AppProperties.Description.Author;
  1868. foreach (AnnotArgsType argsType in e.Keys)
  1869. {
  1870. var key = ToolExpandDict.FirstOrDefault(q => q.Value == argsType);
  1871. switch (argsType)
  1872. {
  1873. case AnnotArgsType.AnnotHighlight:
  1874. if (e[argsType] is Color)
  1875. {
  1876. HighLightColor = new SolidColorBrush((Color)e[argsType]);
  1877. }
  1878. if (e[argsType] is double)
  1879. {
  1880. HighLightOpacity = (double)e[argsType];
  1881. }
  1882. //创建注释后,修改注释属性,可用于下次创建的注释
  1883. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1884. {
  1885. if (StrAnnotToolChecked == key.Key)
  1886. {
  1887. PDFViewer.SetToolParam(PropertyPanel.annot);
  1888. }
  1889. }
  1890. break;
  1891. case AnnotArgsType.AnnotUnderline:
  1892. if (e[argsType] is Color)
  1893. {
  1894. UnderLineColor = new SolidColorBrush((Color)e[argsType]);
  1895. }
  1896. if (e[argsType] is double)
  1897. {
  1898. UnderLineOpacity = (double)e[argsType];
  1899. }
  1900. //创建注释后,修改注释属性,可用于下次创建的注释
  1901. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1902. {
  1903. if (StrAnnotToolChecked == key.Key)
  1904. {
  1905. PDFViewer.SetToolParam(PropertyPanel.annot);
  1906. }
  1907. }
  1908. break;
  1909. case AnnotArgsType.AnnotSquiggly:
  1910. if (e[argsType] is Color)
  1911. {
  1912. SquigglyColor = new SolidColorBrush((Color)e[argsType]);
  1913. }
  1914. if (e[argsType] is double)
  1915. {
  1916. SquigglyOpacity = (double)e[argsType];
  1917. }
  1918. //创建注释后,修改注释属性,可用于下次创建的注释
  1919. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1920. {
  1921. if (StrAnnotToolChecked == key.Key)
  1922. {
  1923. PDFViewer.SetToolParam(PropertyPanel.annot);
  1924. }
  1925. }
  1926. break;
  1927. case AnnotArgsType.AnnotStrikeout:
  1928. if (e[argsType] is Color)
  1929. {
  1930. StrikeoutColor = new SolidColorBrush((Color)e[argsType]);
  1931. }
  1932. if (e[argsType] is double)
  1933. {
  1934. StrikeoutOpacity = (double)e[argsType];
  1935. }
  1936. //创建注释后,修改注释属性,可用于下次创建的注释
  1937. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1938. {
  1939. if (StrAnnotToolChecked == key.Key)
  1940. {
  1941. PDFViewer.SetToolParam(PropertyPanel.annot);
  1942. }
  1943. }
  1944. break;
  1945. case AnnotArgsType.AnnotFreehand:
  1946. if (e[argsType] is FreehandAnnotArgs)
  1947. {
  1948. var annot = e[argsType] as FreehandAnnotArgs;
  1949. if (annot != null)
  1950. {
  1951. if (PropertyPanel != null)
  1952. {
  1953. //属性面板,切换橡皮擦后,再回到画笔时,需要恢复最近画笔的属性值
  1954. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib(), PDFViewer);
  1955. PropertyPanel.AnnotEvent = AnnotEvent;
  1956. var AnnotEvents = new List<AnnotAttribEvent>();
  1957. AnnotEvents.Add(AnnotEvent);
  1958. PropertyPanel.AnnotEvents = AnnotEvents;
  1959. PropertyPanel.annot = annot;
  1960. //手绘注释工具按钮的属性
  1961. // FreehandPath.Opacity = annot.Transparency;
  1962. // FreehandPath.Fill = new SolidColorBrush(annot.InkColor);
  1963. }
  1964. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1965. {
  1966. if (StrAnnotToolChecked == key.Key)
  1967. {
  1968. PDFViewer.SetToolParam(PropertyPanel.annot);
  1969. }
  1970. }
  1971. }
  1972. }
  1973. break;
  1974. case AnnotArgsType.AnnotErase:
  1975. if (e[argsType] is ToggleButton)
  1976. {
  1977. ToggleButton clickBtn = e[argsType] as ToggleButton;
  1978. if (clickBtn.IsChecked == true)
  1979. {
  1980. if (clickBtn.Tag.ToString() != "PenBtn")
  1981. {
  1982. CustomIconToggleBtn btn = new CustomIconToggleBtn();
  1983. btn.Tag = "Freehand";
  1984. btn.IsChecked = true;
  1985. BtnMyTools_Click(btn);
  1986. break;
  1987. }
  1988. else
  1989. {
  1990. CreateEraseArgs();
  1991. }
  1992. }
  1993. }
  1994. break;
  1995. case AnnotArgsType.AnnotSquare:
  1996. case AnnotArgsType.AnnotCircle:
  1997. case AnnotArgsType.AnnotLine:
  1998. //创建注释后,修改注释属性,可用于下次创建的注释
  1999. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  2000. {
  2001. if (StrAnnotToolChecked == "Rect")
  2002. {
  2003. if (PropertyPanel.SharpsAnnot == key.Key || (PropertyPanel.SharpsAnnot != key.Key && key.Key == "Arrow"))
  2004. {
  2005. PDFViewer.SetToolParam(PropertyPanel.annot);
  2006. }
  2007. PropertyPanel.SaveLastAnnot();
  2008. }
  2009. }
  2010. break;
  2011. //预设 重新定义后 会将文本内容 带上
  2012. case AnnotArgsType.AnnotFreeText:
  2013. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  2014. {
  2015. if (StrAnnotToolChecked == key.Key)
  2016. {
  2017. if (PropertyPanel.annot is FreeTextAnnotArgs defaultAnnot)
  2018. {
  2019. FreeTextAnnotArgs freetextArgs = new FreeTextAnnotArgs();
  2020. freetextArgs.FontColor = defaultAnnot.FontColor;
  2021. freetextArgs.LineColor = defaultAnnot.LineColor;
  2022. freetextArgs.BgColor = defaultAnnot.BgColor;
  2023. freetextArgs.Transparency = defaultAnnot.Transparency;
  2024. freetextArgs.FontName = defaultAnnot.FontName;
  2025. freetextArgs.FontSize = defaultAnnot.FontSize;
  2026. freetextArgs.IsBold = defaultAnnot.IsBold;
  2027. freetextArgs.IsItalic = defaultAnnot.IsItalic;
  2028. freetextArgs.LineWidth = defaultAnnot.LineWidth;
  2029. freetextArgs.Align = defaultAnnot.Align;
  2030. PDFViewer.SetToolParam(freetextArgs);
  2031. }
  2032. }
  2033. }
  2034. break;
  2035. }
  2036. }
  2037. }
  2038. }
  2039. private void CreateEraseArgs()
  2040. {
  2041. EraseArgs eraseArgs = new EraseArgs();
  2042. eraseArgs.UIBorderColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
  2043. eraseArgs.UIFillColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
  2044. eraseArgs.Thickness = 10;
  2045. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotErase);
  2046. if (annotProperty != null)
  2047. {
  2048. eraseArgs.Thickness = annotProperty.Thickness;
  2049. }
  2050. PDFViewer.ClearSelectAnnots(false);
  2051. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  2052. PDFViewer.SetToolParam(eraseArgs);
  2053. List<AnnotHandlerEventArgs> eraseArgsList = new List<AnnotHandlerEventArgs>();
  2054. if (eraseArgs != null)
  2055. eraseArgsList.Add(eraseArgs);
  2056. AddToPropertyPanel("FreehandAnnotProperty", "Freehand", eraseArgsList);
  2057. }
  2058. #endregion BindingEvent事件
  2059. }
  2060. }