AnnotToolContentViewModel.Command.cs 103 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278
  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. if (PDFViewer.GetSelectAnnotCount() > 0 && ViewContentViewModel.mainViewModel.AnnotMouseLeftButtonDown == false)
  933. {
  934. List<AnnotHandlerEventArgs> annotationHandlers = PDFViewer.GetSelectionAnnots();
  935. bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  936. if (ViewContentViewModel.OpenBOTA == false)
  937. {
  938. bOTAContentViewModel.OpenBOTA();
  939. }
  940. if (bOTAContent.TabItemAnnotation.IsSelected == false)
  941. {
  942. bOTAContent.TabItemAnnotation.IsSelected = true;
  943. }
  944. if (annotationHandlers[0].EventType != AnnotArgsType.AnnotLink)
  945. {
  946. 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 });
  947. }
  948. }
  949. }
  950. //在注释工具的状态下,右键菜单
  951. private void PDFViewer_AnnotCommandHandler(object sender, AnnotCommandArgs e)
  952. {
  953. if (e.AnnotEventArgsList == null || (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool))
  954. return;
  955. if ((UIElement)sender != null)
  956. {
  957. //绑定命令执行前的拦截事件,对于未解密权限的文档进行复制限制
  958. CommandManager.AddPreviewExecutedHandler((UIElement)sender, PreviewExcute);
  959. }
  960. switch (e.CommandType)
  961. {
  962. case CommandType.Context:
  963. if (e.AnnotEventArgsList.Count > 0)
  964. {
  965. if (App.mainWindowViewModel.SelectedItem.IsInReadctonMode && e.AnnotEventArgsList[0].EventType == AnnotArgsType.AnnotRedaction)
  966. {
  967. //绑定标记密文处右键菜单
  968. events.GetEvent<RedactionCommandEvent>().Publish(new RedactionCommandEventArgs() { UniCode = App.mainWindowViewModel.SelectedItem.Unicode, Sender = sender, args = e });
  969. }
  970. else
  971. {
  972. if (e.AnnotEventArgsList.Count == 1)
  973. {
  974. var selectedAnnot = e.AnnotEventArgsList[0];
  975. PopMenuCheckedLineDash(selectedAnnot);
  976. PopMenuCheckedFontFamily(selectedAnnot);
  977. PopMenuCheckedTextAglin(selectedAnnot);
  978. switch (selectedAnnot.EventType)
  979. {
  980. case AnnotArgsType.AnnotHighlight:
  981. case AnnotArgsType.AnnotUnderline:
  982. case AnnotArgsType.AnnotStrikeout:
  983. case AnnotArgsType.AnnotSquiggly:
  984. if (selectedAnnot.EventType == AnnotArgsType.AnnotHighlight)
  985. {
  986. colorContent.ItemSource = AnnotColorList.GetColorList(ColorSelectorType.Highlight);
  987. }
  988. else
  989. {
  990. colorContent.ItemSource = AnnotColorList.GetColorList(ColorSelectorType.Border);
  991. }
  992. e.PopupMenu = HightAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  993. break;
  994. case AnnotArgsType.AnnotFreehand:
  995. e.PopupMenu = FreeHandAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  996. break;
  997. case AnnotArgsType.AnnotFreeText:
  998. e.PopupMenu = FreeTextAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  999. break;
  1000. case AnnotArgsType.AnnotSticky:
  1001. e.PopupMenu = StrickNoteAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  1002. break;
  1003. case AnnotArgsType.AnnotSquare:
  1004. case AnnotArgsType.AnnotCircle:
  1005. ShapeAnnotPopMenu.SetVisual("ShapeDirect", false);
  1006. ShapeAnnotPopMenu.SetVisual("ShapeFillColor", true);
  1007. e.PopupMenu = ShapeAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  1008. break;
  1009. case AnnotArgsType.AnnotLine:
  1010. ShapeAnnotPopMenu.SetVisual("ShapeFillColor", false);
  1011. ShapeAnnotPopMenu.SetVisual("ShapeDirect", true);
  1012. e.PopupMenu = ShapeAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  1013. break;
  1014. case AnnotArgsType.AnnotLink:
  1015. e.PopupMenu = LinkAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  1016. break;
  1017. case AnnotArgsType.AnnotStamp:
  1018. e.PopupMenu = StampAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  1019. break;
  1020. }
  1021. }
  1022. else
  1023. {
  1024. bool isHigh = true;//是否为高亮
  1025. foreach (var item in e.AnnotEventArgsList)
  1026. {
  1027. if (AnnotTransfer.IsHightAnnot(item) == false)
  1028. {
  1029. isHigh = false;
  1030. break;
  1031. }
  1032. }
  1033. MultiAnnotPopMenu.SetVisual("MultiCopy", !isHigh);
  1034. MultiAnnotPopMenu.SetVisual("MultiCut", !isHigh);
  1035. e.PopupMenu = MultiAnnotPopMenu.OpenMenu(e.AnnotEventArgsList, sender);
  1036. }
  1037. }
  1038. if (e.PopupMenu != null)
  1039. {
  1040. e.Handle = true;
  1041. }
  1042. }
  1043. else
  1044. {
  1045. if (e.PressOnSelectedText || e.CommandTarget == TargetType.ImageSelection)
  1046. {
  1047. //右键添加注释,形状注释添加之后会选中
  1048. ViewContentViewModel.mainViewModel.AnnotMouseLeftButtonDown = true;
  1049. e.PopupMenu = SelectedTextOrImageContextMenu(sender, e);
  1050. if (e.PopupMenu != null)
  1051. {
  1052. e.Handle = true;
  1053. }
  1054. }
  1055. else
  1056. {
  1057. e.PopupMenu = ViewerContextMenu(sender);
  1058. if (e.PopupMenu != null)
  1059. {
  1060. e.Handle = true;
  1061. }
  1062. }
  1063. }
  1064. break;
  1065. default:
  1066. e?.DoCommand();
  1067. break;
  1068. }
  1069. }
  1070. private void PreviewExcute(object sender, ExecutedRoutedEventArgs e)
  1071. {
  1072. if (e.Command == ApplicationCommands.Copy || e.Command == ApplicationCommands.Cut)
  1073. {
  1074. if (!ViewContentViewModel.CheckPermissionBeforeOption())
  1075. {
  1076. //没有权限,或者权限解密不成功时,拦截该命令
  1077. e.Handled = true;
  1078. }
  1079. }
  1080. }
  1081. /// <summary>
  1082. /// 右键菜单,选中字体样式按钮状态
  1083. /// </summary>
  1084. /// <param name="annot"></param>
  1085. private void PopMenuCheckedFontFamily(AnnotHandlerEventArgs annot)
  1086. {
  1087. if (annot != null)
  1088. {
  1089. if (annot.EventType == AnnotArgsType.AnnotFreeText)
  1090. {
  1091. var freeText = annot as FreeTextAnnotArgs;
  1092. string fontFamily = freeText.FontName;
  1093. if (fontFamily == "Arial")
  1094. {
  1095. fontFamily = "Helvetica";
  1096. }
  1097. if (fontFamily == "Courier New")
  1098. {
  1099. fontFamily = "Courier";
  1100. }
  1101. if (fontFamily == "Times New Roman")
  1102. {
  1103. fontFamily = "Times";
  1104. }
  1105. FreeTextAnnotPopMenu.SetIsChecked(fontFamily, true);
  1106. }
  1107. }
  1108. }
  1109. /// <summary>
  1110. /// 右键菜单,选中文本内容对齐按钮状态
  1111. /// </summary>
  1112. /// <param name="annot"></param>
  1113. private void PopMenuCheckedTextAglin(AnnotHandlerEventArgs annot)
  1114. {
  1115. if (annot != null)
  1116. {
  1117. if (annot.EventType == AnnotArgsType.AnnotFreeText)
  1118. {
  1119. var freeText = annot as FreeTextAnnotArgs;
  1120. switch (freeText.Align)
  1121. {
  1122. case TextAlignment.Left:
  1123. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinLeft", true);
  1124. break;
  1125. case TextAlignment.Center:
  1126. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinCenter", true);
  1127. break;
  1128. case TextAlignment.Right:
  1129. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinRight", true);
  1130. break;
  1131. case TextAlignment.Justify:
  1132. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinJustify", true);
  1133. break;
  1134. default:
  1135. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinLeft", false);
  1136. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinCenter", false);
  1137. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinRight", false);
  1138. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinJustify", false);
  1139. break;
  1140. }
  1141. }
  1142. }
  1143. }
  1144. //右键菜单,选中虚实线按钮状态
  1145. private void PopMenuCheckedLineDash(AnnotHandlerEventArgs annot)
  1146. {
  1147. if (annot != null)
  1148. {
  1149. bool isSolidLineDash = true;
  1150. if (annot.EventType == AnnotArgsType.AnnotFreehand)
  1151. {
  1152. var freeHand = annot as FreehandAnnotArgs;
  1153. isSolidLineDash = AnnotTransfer.IsSolidStyle(freeHand.LineDash);
  1154. FreeHandAnnotPopMenu.SetIsChecked(isSolidLineDash ? "FreeHandSolid" : "FreeHandDash", true);
  1155. }
  1156. else if (annot.EventType == AnnotArgsType.AnnotSquare)
  1157. {
  1158. var square = annot as SquareAnnotArgs;
  1159. isSolidLineDash = AnnotTransfer.IsSolidStyle(square.LineDash);
  1160. ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
  1161. }
  1162. else if (annot.EventType == AnnotArgsType.AnnotCircle)
  1163. {
  1164. var circle = annot as CircleAnnotArgs;
  1165. isSolidLineDash = AnnotTransfer.IsSolidStyle(circle.LineDash);
  1166. ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
  1167. }
  1168. else if (annot.EventType == AnnotArgsType.AnnotLine)
  1169. {
  1170. var line = annot as LineAnnotArgs;
  1171. isSolidLineDash = AnnotTransfer.IsSolidStyle(line.LineDash);
  1172. ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
  1173. }
  1174. }
  1175. }
  1176. /// <summary>
  1177. /// 内容选择工具
  1178. /// </summary>
  1179. /// <param name="sender"></param>
  1180. /// <param name="e"></param>
  1181. private void PDFViewer_SnapshotCommandHandler(object sender, SnapshotCommandArgs e)
  1182. {
  1183. SnapshotEditToolArgs snapToolArgs = new SnapshotEditToolArgs();
  1184. if (PDFViewer.ToolManager.CurrentAnnotArgs is SnapshotEditToolArgs)
  1185. {
  1186. snapToolArgs = (SnapshotEditToolArgs)PDFViewer.ToolManager.CurrentAnnotArgs;
  1187. SnapshotEditMenuViewModel.SnapToolArgs = snapToolArgs;
  1188. SnapshotEditMenuViewModel.PDFViewer = PDFViewer;
  1189. SnapshotEditMenuViewModel.areaCropPageUndoManager = new AreaCropPageUndoManager(PDFViewer);
  1190. SnapshotEditMenuViewModel.SnapToolEvent -= SnapshotEditMenuViewModel_SnapToolEvent; ;
  1191. SnapshotEditMenuViewModel.SnapToolEvent += SnapshotEditMenuViewModel_SnapToolEvent;
  1192. var popMenu = App.Current.FindResource("SnapshotContextMenu") as ContextMenu;
  1193. if (e.HitSnapshotTool && e.SnapshotRect.Width > 0 && e.SnapshotRect.Height > 0)
  1194. {
  1195. e.PopupMenu = popMenu;
  1196. e.Handle = true;
  1197. if (popMenu != null && popMenu.Items.Count == 5)
  1198. {
  1199. //复制
  1200. MenuItem menuItem = popMenu.Items[0] as MenuItem;
  1201. menuItem.CommandTarget = PDFViewer;
  1202. menuItem.Command = SnapshotEditMenuViewModel.SnapCopyCommand;
  1203. //导出
  1204. menuItem = popMenu.Items[1] as MenuItem;
  1205. menuItem.CommandTarget = PDFViewer;
  1206. if (menuItem.Items.Count == 3)
  1207. {
  1208. MenuItem menuItem1 = menuItem.Items[0] as MenuItem;
  1209. menuItem1.CommandTarget = PDFViewer;
  1210. menuItem1.Command = SnapshotEditMenuViewModel.ExportPNGCommand;
  1211. menuItem1 = menuItem.Items[1] as MenuItem;
  1212. menuItem1.CommandTarget = PDFViewer;
  1213. menuItem1.Command = SnapshotEditMenuViewModel.ExportJPGCommand;
  1214. menuItem1 = menuItem.Items[2] as MenuItem;
  1215. menuItem1.CommandTarget = PDFViewer;
  1216. menuItem1.Command = SnapshotEditMenuViewModel.ExportPDFCommand;
  1217. }
  1218. //裁剪
  1219. menuItem = popMenu.Items[2] as MenuItem;
  1220. menuItem.CommandTarget = PDFViewer;
  1221. menuItem.Command = SnapshotEditMenuViewModel.CroppingCommand;
  1222. //缩放至所选区域
  1223. menuItem = popMenu.Items[3] as MenuItem;
  1224. menuItem.CommandTarget = PDFViewer;
  1225. menuItem.Visibility = Visibility.Collapsed;
  1226. //menuItem.Command = snapshotEditMenuViewModel.CroppingCommand;
  1227. //打印
  1228. menuItem = popMenu.Items[4] as MenuItem;
  1229. menuItem.CommandTarget = PDFViewer;
  1230. menuItem.Command = SnapshotEditMenuViewModel.PrintCommand;
  1231. }
  1232. //解决内容选择器 右键菜单闪现消失的问题,sdk库有更新,需要确认哪边提交
  1233. System.Threading.Tasks.Task.Factory.StartNew(() =>
  1234. {
  1235. System.Threading.Thread.Sleep(200);
  1236. PDFViewer.Dispatcher.Invoke(() =>
  1237. {
  1238. popMenu.IsOpen = true;
  1239. popMenu.StaysOpen = true;
  1240. });
  1241. });
  1242. }
  1243. }
  1244. }
  1245. private void SnapshotEditMenuViewModel_SnapToolEvent(object sender, KeyValuePair<string, object> e)
  1246. {
  1247. switch (e.Key)
  1248. {
  1249. case "CloseSnap":
  1250. {
  1251. #region to do
  1252. //var item = PDFViewerTab.SelectedItem as TabItem;
  1253. //if (item == null)
  1254. //{
  1255. // ClearSelectedToolPanel();
  1256. // return;
  1257. //}
  1258. //Grid grid = item.Content as Grid;
  1259. //if (grid == null || grid.Children.Count == 0)
  1260. //{
  1261. // ClearSelectedToolPanel();
  1262. // return;
  1263. //}
  1264. //PDFViewerCtrl pdfViewer = grid.Children[0] as PDFViewerCtrl;
  1265. //if (pdfViewer == null)
  1266. //{
  1267. // ClearSelectedToolPanel();
  1268. // return;
  1269. //}
  1270. #endregion to do
  1271. switch (PDFViewer.MouseMode)
  1272. {
  1273. case MouseModes.SelectTextTool:
  1274. break;
  1275. default:
  1276. BtnSelecttoolIsChecked = false;
  1277. //BtnHandIsChecked = true;
  1278. PDFViewer.EnableZoom(true);
  1279. PDFViewer.EnableScroll(true);
  1280. PDFViewer.SetMouseMode(MouseModes.PanTool);
  1281. HandToolIsCheckedEvent(false);
  1282. break;
  1283. }
  1284. }
  1285. break;
  1286. default:
  1287. break;
  1288. }
  1289. }
  1290. private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
  1291. {
  1292. bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  1293. AnnotationContentViewModel viewModel = null;
  1294. AnnotationContent annotation = null;
  1295. //OpenBOTA关闭时也要进入
  1296. //if (viewContentViewModel.OpenBOTA == false)
  1297. //{
  1298. viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out annotation);
  1299. //}
  1300. bool isMultiple = false;
  1301. Dictionary<int, List<int>> selectAnnotDicts = new Dictionary<int, List<int>>();
  1302. Dictionary<int, List<int>> selectFreehandDicts = new Dictionary<int, List<int>>();
  1303. if (e != null && e.Count > 0)
  1304. {
  1305. for (int i = 0; i < e.Count; i++)
  1306. {
  1307. AnnotEditEvent editEvent = e[i];
  1308. bool isVisible = PDFViewer.CheckAnnotVisible(editEvent.PageIndex, editEvent.AnnotIndex);
  1309. var annot = editEvent.EditAnnotArgs;
  1310. switch (editEvent.EditAction)
  1311. {
  1312. case ActionType.Add:
  1313. #region 区分复制填写签名图形
  1314. if (IsPasteShape)
  1315. {
  1316. if (editEvent.EditAnnotArgs.EventType == AnnotArgsType.AnnotFreehand)
  1317. {
  1318. if (ShapeNames.Count != 0 && ShapeNames[i] != "Annot")
  1319. {
  1320. try
  1321. {
  1322. ViewContentViewModel.FillAndSign.Add(new FillAndSignIsShape(editEvent.PageIndex, editEvent.AnnotIndex, ShapeNames[i]));
  1323. }
  1324. catch { }
  1325. }
  1326. }
  1327. }
  1328. #endregion 区分复制填写签名图形
  1329. if (ViewContentViewModel.CurrentBar != "TabItemAnnotation")
  1330. {
  1331. //填写与签名在此区域不选中,不添加selectAnnotDicts词典当中
  1332. }
  1333. else
  1334. {
  1335. if (PropertyPanel.IsMultiSelected)
  1336. {
  1337. if (selectAnnotDicts.ContainsKey(editEvent.PageIndex) == false)
  1338. {
  1339. selectAnnotDicts.Add(editEvent.PageIndex, new List<int>());
  1340. selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1341. }
  1342. else
  1343. {
  1344. selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1345. }
  1346. isMultiple = true;
  1347. }
  1348. else
  1349. {
  1350. if (
  1351. annot.EventType == AnnotArgsType.AnnotSquare || annot.EventType == AnnotArgsType.AnnotCircle ||
  1352. annot.EventType == AnnotArgsType.AnnotLine || annot.EventType == AnnotArgsType.AnnotStamp
  1353. /*|| annot.EventType == AnnotArgsType.AnnotSticky ||annot.EventType == AnnotArgsType.AnnotFreeText */)
  1354. {
  1355. if (selectAnnotDicts.ContainsKey(editEvent.PageIndex) == false)
  1356. {
  1357. selectAnnotDicts.Add(editEvent.PageIndex, new List<int>());
  1358. selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1359. }
  1360. else
  1361. {
  1362. selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1363. }
  1364. isMultiple = true;
  1365. }
  1366. //添加后不选中的注释,需要额外处理
  1367. if (annot.EventType == AnnotArgsType.AnnotFreehand || annot.EventType == AnnotArgsType.AnnotSticky || annot.EventType == AnnotArgsType.AnnotFreeText)
  1368. {
  1369. if (selectFreehandDicts.ContainsKey(editEvent.PageIndex) == false)
  1370. {
  1371. selectFreehandDicts.Add(editEvent.PageIndex, new List<int>());
  1372. selectFreehandDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1373. }
  1374. else
  1375. {
  1376. selectFreehandDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
  1377. }
  1378. isMultiple = true;
  1379. }
  1380. //复制后 粘贴选中
  1381. if (annot.EventType == AnnotArgsType.AnnotLink)
  1382. {
  1383. PDFViewer.SelectAnnotation(annot.PageIndex, annot.AnnotIndex);
  1384. }
  1385. }
  1386. }
  1387. if (viewModel != null)
  1388. {
  1389. int pageindex = editEvent.PageIndex;
  1390. int annotindex = editEvent.AnnotIndex;
  1391. viewModel.UpdateAddedAnnot(bOTAContent, pageindex, annotindex);
  1392. }
  1393. //添加签名注释,用于未保存前跟图章手绘注释的区分
  1394. if (StrAnnotToolChecked == "Signature")
  1395. {
  1396. AddAnnotSignature(editEvent.EditAnnotArgs);
  1397. }
  1398. //if (editEvent.EditAnnotArgs.EventType == AnnotArgsType.AnnotFreeText)
  1399. //{
  1400. // (editEvent.EditAnnotArgs as FreeTextAnnotArgs).LineWidth = 0;
  1401. //}
  1402. break;
  1403. case ActionType.Modify:
  1404. //undo/redo,字体大小联动,刷新属性面板数据
  1405. if (string.IsNullOrEmpty(StrAnnotToolChecked) == false)
  1406. {
  1407. List<AnnotHandlerEventArgs> selectedArgs = new List<AnnotHandlerEventArgs>() { annot };
  1408. switch (annot.EventType)
  1409. {
  1410. case AnnotArgsType.AnnotFreeText://文本
  1411. GetFreetext(selectedArgs);
  1412. break;
  1413. }
  1414. }
  1415. if (viewModel != null)
  1416. {
  1417. int pageindex = editEvent.PageIndex;
  1418. int annotindex = editEvent.AnnotIndex;
  1419. viewModel.UpdateModifiedAnnot(pageindex, annotindex);
  1420. }
  1421. break;
  1422. case ActionType.Del:
  1423. //isTabItemAnnotation = IsBOTATabItemShow(out bOTAContentViewModel, out bOTAContent, "TabItemAnnotation");
  1424. //if (viewContentViewModel.OpenBOTA == true && bOTAContent.TabItemAnnotation.IsSelected)
  1425. //{
  1426. // AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
  1427. #region//填写与签名 删除缓存信息列表
  1428. //if (Shape != "None")
  1429. //{
  1430. for (int j = 0; j < ViewContentViewModel.FillAndSign.Count; j++)
  1431. {
  1432. if (ViewContentViewModel.FillAndSign[j].PageIndex == editEvent.PageIndex && ViewContentViewModel.FillAndSign[j].AnnotIndex == editEvent.AnnotIndex)
  1433. {
  1434. ViewContentViewModel.FillAndSign.Remove(ViewContentViewModel.FillAndSign[j]);
  1435. }
  1436. }
  1437. for (int j = 0; j < ViewContentViewModel.AnnotSignatures.Count; j++)
  1438. {
  1439. if (ViewContentViewModel.AnnotSignatures[j].Item1 == editEvent.PageIndex && ViewContentViewModel.AnnotSignatures[j].Item2 == editEvent.AnnotIndex)
  1440. {
  1441. ViewContentViewModel.AnnotSignatures.Remove(ViewContentViewModel.AnnotSignatures[j]);
  1442. }
  1443. }
  1444. //}
  1445. #endregion PDFViewer事件
  1446. if (viewModel != null)
  1447. {
  1448. int pageindex = editEvent.PageIndex;
  1449. int annotindex = editEvent.AnnotIndex;
  1450. viewModel.DeleteModifiedAnnot(pageindex, annotindex);
  1451. }
  1452. if (string.IsNullOrEmpty(StrAnnotToolChecked))
  1453. {
  1454. if (ViewContentViewModel.CurrentBar != "TabItemAnnotation")
  1455. {
  1456. //填写与签名在此区域不选中,不添加selectAnnotDicts词典当中
  1457. }
  1458. else
  1459. {
  1460. ExitAnnotationTool();
  1461. ViewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  1462. }
  1463. }
  1464. else
  1465. {
  1466. switch (StrAnnotToolChecked)
  1467. {
  1468. case "Link":
  1469. PropertyPanel.IsAddLink = true;
  1470. GetLink();
  1471. events.GetEvent<LinkAnnotTipCloseEvent>().Publish(new LinkAnnotTipCloseArgs() { UniCode = App.mainWindowViewModel.SelectedItem.Unicode });
  1472. break;
  1473. }
  1474. }
  1475. break;
  1476. case ActionType.TextEdit:
  1477. break;
  1478. default:
  1479. break;
  1480. }
  1481. }
  1482. IsPasteShape = false;
  1483. SetMultipleAnnot(isMultiple, selectAnnotDicts, selectFreehandDicts);
  1484. //MultipleSelectionAnnot(e);
  1485. //空白处 右键菜单 添加注释 为单次添加,不连续添加
  1486. if (IsNoSelectMenu && PropertyPanel.IsAddLink == false)
  1487. {
  1488. ViewContentViewModel.ReadModeIsShowProperty = false;
  1489. IsNoSelectMenu = false;
  1490. ExitAnnotationTool();
  1491. }
  1492. if (ViewContentViewModel.IsRightMenuSelectedTextAddLink == false)
  1493. {
  1494. ViewContentViewModel.ReadModeIsShowProperty = false;
  1495. }
  1496. }
  1497. }
  1498. /// <summary>
  1499. /// 设置多选注释
  1500. /// </summary>
  1501. /// <param name="isMultiple"></param>
  1502. /// <param name="selectAnnotDicts">添加后选中的注释</param>
  1503. /// <param name="selectFreehandDicts">添加后不选中的注释,需要额外处理</param>
  1504. private void SetMultipleAnnot(bool isMultiple, Dictionary<int, List<int>> selectAnnotDicts, Dictionary<int, List<int>> selectFreehandDicts)
  1505. {
  1506. if (isMultiple)
  1507. {
  1508. Dictionary<int, List<int>> dict = new Dictionary<int, List<int>>();
  1509. //阅读页多选注释,只能在当前页多选,不可以跨页多选
  1510. if (selectAnnotDicts.Count >= 1)
  1511. {
  1512. PDFViewer.ClearSelectAnnots();
  1513. //if (StrAnnotToolChecked != "Signature")
  1514. //{
  1515. PDFViewer.SelectAnnotation(selectAnnotDicts);
  1516. if (selectFreehandDicts.Count >= 1)
  1517. {
  1518. if (selectFreehandDicts.FirstOrDefault().Value.Count > 1)
  1519. {
  1520. //先把键都合并到dict中,值都是新创建的
  1521. foreach (var key in selectAnnotDicts.Keys)
  1522. {
  1523. if (!dict.ContainsKey(key))
  1524. {
  1525. dict.Add(key, new List<int>());
  1526. }
  1527. }
  1528. foreach (var key in selectFreehandDicts.Keys)
  1529. {
  1530. if (!dict.ContainsKey(key))
  1531. {
  1532. dict.Add(key, new List<int>());
  1533. }
  1534. }
  1535. //分别将值添加进去
  1536. foreach (var ele in selectAnnotDicts)
  1537. {
  1538. dict[ele.Key].AddRange(ele.Value);
  1539. }
  1540. foreach (var ele in selectFreehandDicts)
  1541. {
  1542. dict[ele.Key].AddRange(ele.Value);
  1543. }
  1544. //Dictionary<int, List<int>> items2 = selectAnnotDicts.Union(selectFreehandDicts).ToDictionary(k => k.Key, v => v.Value);
  1545. PDFViewer.ClearSelectAnnots();
  1546. PDFViewer.SelectAnnotation(dict);
  1547. }
  1548. //}
  1549. }
  1550. }
  1551. else
  1552. {
  1553. if (selectFreehandDicts.Count >= 1)
  1554. {
  1555. if (selectFreehandDicts.FirstOrDefault().Value.Count > 1)
  1556. {
  1557. PDFViewer.ClearSelectAnnots();
  1558. PDFViewer.SelectAnnotation(selectFreehandDicts);
  1559. }
  1560. }
  1561. }
  1562. }
  1563. #region 之前版本
  1564. //if (isMultiple && selectAnnotDicts.Count >= 1)
  1565. //{
  1566. // //PDFViewer.DisableClearSelectAnnot(false);
  1567. // PDFViewer.ClearSelectAnnots();
  1568. // if (StrAnnotToolChecked != "Signature")
  1569. // {
  1570. // //PDFViewer.DisableClearSelectAnnot(true);
  1571. // PDFViewer.SelectAnnotation(selectAnnotDicts);
  1572. // //禁止取消选中注释
  1573. // //PDFViewer.DisableClearSelectAnnot(false);
  1574. // }
  1575. //}
  1576. //if (isMultiple && selectFreehandDicts.Count >= 1)
  1577. //{
  1578. // PDFViewer.ClearSelectAnnots();
  1579. // if (selectFreehandDicts.FirstOrDefault().Value.Count >= 1)
  1580. // {
  1581. // PDFViewer.SelectAnnotation(selectFreehandDicts);
  1582. // }
  1583. //}
  1584. #endregion 之前版本
  1585. }
  1586. //复制多个注释,粘贴后,默认注释未选中状态
  1587. private void MultipleSelectionAnnot(List<AnnotEditEvent> e)
  1588. {
  1589. bool isAdd = false;
  1590. Dictionary<int, List<int>> selectAnnotDicts = new Dictionary<int, List<int>>();
  1591. foreach (var item in e)
  1592. {
  1593. if (item.EditAction == ActionType.Add || item.EditAction == ActionType.Modify)
  1594. {
  1595. var annot = item.EditAnnotArgs;
  1596. if (annot.EventType == AnnotArgsType.AnnotSquare || annot.EventType == AnnotArgsType.AnnotCircle ||
  1597. annot.EventType == AnnotArgsType.AnnotLine || annot.EventType == AnnotArgsType.AnnotStamp || annot.EventType == AnnotArgsType.AnnotFreeText || annot.EventType == AnnotArgsType.AnnotFreehand)
  1598. {
  1599. if (selectAnnotDicts.ContainsKey(item.PageIndex) == false)
  1600. {
  1601. selectAnnotDicts.Add(item.PageIndex, new List<int>());
  1602. selectAnnotDicts[item.PageIndex].Add(item.AnnotIndex);
  1603. }
  1604. else
  1605. {
  1606. selectAnnotDicts[item.PageIndex].Add(item.AnnotIndex);
  1607. }
  1608. isAdd = true;
  1609. }
  1610. }
  1611. }
  1612. if (isAdd && selectAnnotDicts.Count >= 1)
  1613. {
  1614. PDFViewer.ClearSelectAnnots();
  1615. if (StrAnnotToolChecked != "Signature")
  1616. {
  1617. PDFViewer.SelectAnnotation(selectAnnotDicts);
  1618. }
  1619. }
  1620. }
  1621. //阅读页悬浮相应
  1622. /// <summary>
  1623. /// 阅读页鼠标悬浮在注释上的虚线
  1624. /// </summary>
  1625. /// <param name="sender"></param>
  1626. /// <param name="e"></param>
  1627. private void PDFViewer_AnnotHoverHandler(object sender, AnnotHoverData e)
  1628. {
  1629. if (e != null && e.DrawContext != null)
  1630. {
  1631. //if (StrAnnotToolChecked == "Freetext")
  1632. //{
  1633. // if ((e.Annot is CPDFFreeTextAnnotation annotation) == false)
  1634. // {
  1635. // isDown = false;
  1636. // Trace.WriteLine(isDown);
  1637. // return;
  1638. // }
  1639. // else
  1640. // {
  1641. // isDown=true;
  1642. // Trace.WriteLine(isDown);
  1643. // }
  1644. //}
  1645. if (StrAnnotToolChecked != "Link")
  1646. {
  1647. if (e.Annot is CPDFLinkAnnotation linkAnnotation)
  1648. {
  1649. return;
  1650. }
  1651. }
  1652. if (StrAnnotToolChecked == "Freehand" || (IsNoSelectMenu && isRightMenuAddAnnot))
  1653. {
  1654. return;
  1655. }
  1656. Rect hoverRect = new Rect(
  1657. e.PaintRect.Left - 2,
  1658. e.PaintRect.Top - 2,
  1659. e.PaintRect.Width + 4,
  1660. e.PaintRect.Height + 4);
  1661. if (e.Annot is CPDFTextAnnotation sticky)
  1662. {
  1663. hoverRect = new Rect(
  1664. e.PaintRect.Left - 2,
  1665. e.PaintRect.Top + 2,
  1666. e.PaintRect.Width + 5,
  1667. e.PaintRect.Height + 2);
  1668. }
  1669. Pen hoverPen = new Pen(new SolidColorBrush(Color.FromArgb(0xff, 0x11, 0x8A, 0xff)), 1);
  1670. hoverPen.DashStyle = DashStyles.Dash;
  1671. e.DrawContext?.DrawRectangle(null, hoverPen, hoverRect);
  1672. //便签,显示ToolTip内容
  1673. if (e.Annot != null && e.Annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_TEXT)
  1674. {
  1675. PopAnnotToolTip(e.Annot.GetRect(), hoverRect, e.Annot.GetContent());
  1676. return;
  1677. }
  1678. }
  1679. CloseAnnotToolTip();
  1680. }
  1681. private void PDFViewer_MouseMove(object sender, MouseEventArgs e)
  1682. {
  1683. if (sender != null && PDFViewer.ToolTip != null && PDFViewer.Parent != null)
  1684. {
  1685. //鼠标移到注释之外,关闭ToolTip浮窗
  1686. var newPoint = e.GetPosition(PDFViewer.Parent as ContentControl);
  1687. var isOutw = newPoint.X > (oldRect.X + oldRect.Width + 4);
  1688. var isOuth = newPoint.Y > (oldRect.Y + oldRect.Height + 4);
  1689. if (newPoint.X < oldRect.X || newPoint.Y < oldRect.Y || isOutw || isOuth)
  1690. {
  1691. CloseAnnotToolTip();
  1692. }
  1693. }
  1694. }
  1695. private Rect oldRect = new Rect(0, 0, 0, 0);
  1696. private void PopAnnotToolTip(CRect placementRect, Rect hoverRect, string content)
  1697. {
  1698. //便签,显示ToolTip内容
  1699. if (PDFViewer.ToolTip == null)
  1700. {
  1701. if (string.IsNullOrEmpty(content) == false)
  1702. {
  1703. ToolTip TipChild = new ToolTip();
  1704. TipChild.Style = App.Current.Resources["FlowToolTip"] as Style;
  1705. TipChild.MaxWidth = 246;
  1706. TipChild.Content = content;
  1707. TipChild.Visibility = Visibility.Visible;
  1708. TipChild.IsOpen = true;
  1709. TipChild.Placement = PlacementMode.Right;
  1710. TipChild.PlacementRectangle = new Rect(placementRect.left, placementRect.top, placementRect.right, placementRect.bottom);
  1711. TipChild.PlacementTarget = PDFViewer.Parent as ContentControl;
  1712. TipChild.Placement = PlacementMode.MousePoint;
  1713. PDFViewer.ToolTip = TipChild;
  1714. oldRect = hoverRect;
  1715. PDFViewer.MouseMove -= PDFViewer_MouseMove;
  1716. PDFViewer.MouseMove += PDFViewer_MouseMove;
  1717. }
  1718. }
  1719. }
  1720. //关闭ToolTip
  1721. private void CloseAnnotToolTip()
  1722. {
  1723. if (PDFViewer.ToolTip != null && PDFViewer.ToolTip is ToolTip)
  1724. {
  1725. ToolTip oldTips = (ToolTip)PDFViewer.ToolTip;
  1726. oldTips.IsOpen = false;
  1727. oldTips.Visibility = Visibility.Collapsed;
  1728. PDFViewer.ToolTip = null;
  1729. PDFViewer.MouseMove -= PDFViewer_MouseMove;
  1730. oldRect = new Rect(0, 0, 0, 0);
  1731. }
  1732. }
  1733. #endregion PDFViewer事件
  1734. #region BindingEvent事件
  1735. //同一属性面板,不同的注释类型
  1736. private void AnnotPropertyPanel_AnnotTypeChanged(object sender, Dictionary<AnnotArgsType, object> e)
  1737. {
  1738. if (e != null && sender is SharpsAnnotPropertyViewModel sharpsAnnot)
  1739. {
  1740. AnnotHandlerEventArgs annotArgs = null;
  1741. //PropertyPanel.SaveLastAnnot();
  1742. List<AnnotHandlerEventArgs> annots = new List<AnnotHandlerEventArgs>();
  1743. foreach (AnnotArgsType argsType in e.Keys)
  1744. {
  1745. if (PropertyPanel.annot != null)
  1746. {
  1747. if (PropertyPanel.annot.EventType != argsType)
  1748. {
  1749. PDFViewer.DisableClearSelectAnnot(false);
  1750. PDFViewer.ClearSelectAnnots();
  1751. PDFViewer.SetMouseMode(MouseModes.PanTool);
  1752. CurrentSelectedAnnot = null;
  1753. }
  1754. }
  1755. switch (argsType)
  1756. {
  1757. case AnnotArgsType.AnnotSquare:
  1758. #region TO DO
  1759. //选择一个形状注释A,在选择B(非多选),修改属性成功,以下操作的操作可以解决,
  1760. //可能会出现选择注释A,鼠标直接点击属性面板,注释A取消选中,但还可以对注释A更改属性的BUG
  1761. if (CurrentSelectedAnnot != null)
  1762. {
  1763. if (CurrentSelectedAnnot.EventType == AnnotArgsType.AnnotSquare)
  1764. {
  1765. //CurrentSelectedAnnot.PageIndex = -1;
  1766. //CurrentSelectedAnnot.AnnotIndex = -1;
  1767. CurrentSelectedAnnot.ClientRect = Rect.Empty;
  1768. annots.Add(CurrentSelectedAnnot);
  1769. }
  1770. }
  1771. if (annots.Count > 0)
  1772. {
  1773. annotArgs = GetRect(annots);
  1774. }
  1775. else
  1776. {
  1777. annotArgs = GetRect();
  1778. }
  1779. #endregion TO DO
  1780. //annotArgs = GetRect();
  1781. break;
  1782. case AnnotArgsType.AnnotCircle:
  1783. #region TO DO
  1784. if (CurrentSelectedAnnot != null)
  1785. {
  1786. if (CurrentSelectedAnnot.EventType == AnnotArgsType.AnnotCircle)
  1787. {
  1788. //CurrentSelectedAnnot.PageIndex = -1;
  1789. //CurrentSelectedAnnot.AnnotIndex = -1;
  1790. CurrentSelectedAnnot.ClientRect = Rect.Empty;
  1791. annots.Add(CurrentSelectedAnnot);
  1792. }
  1793. }
  1794. if (annots.Count > 0)
  1795. {
  1796. annotArgs = GetCircle(annots);
  1797. }
  1798. else
  1799. {
  1800. annotArgs = GetCircle();
  1801. }
  1802. #endregion TO DO
  1803. //annotArgs = GetCircle();
  1804. break;
  1805. case AnnotArgsType.AnnotLine:
  1806. var LineTag = e[argsType] as string;
  1807. #region TO DO
  1808. if (CurrentSelectedAnnot != null)
  1809. {
  1810. if (CurrentSelectedAnnot.EventType == AnnotArgsType.AnnotLine)
  1811. {
  1812. //CurrentSelectedAnnot.PageIndex = -1;
  1813. //CurrentSelectedAnnot.AnnotIndex = -1;
  1814. CurrentSelectedAnnot.ClientRect = Rect.Empty;
  1815. if (CurrentSelectedAnnot is LineAnnotArgs lineAnnotArgs)
  1816. {
  1817. if (lineAnnotArgs.HeadLineType >= (C_LINE_TYPE)1 || lineAnnotArgs.TailLineType >= (C_LINE_TYPE)1)
  1818. {
  1819. if (LineTag == "Arrow")
  1820. {
  1821. annots.Add(CurrentSelectedAnnot);
  1822. }
  1823. }
  1824. else
  1825. {
  1826. if (LineTag == "Line")
  1827. {
  1828. annots.Add(CurrentSelectedAnnot);
  1829. }
  1830. }
  1831. }
  1832. }
  1833. }
  1834. if (annots.Count > 0)
  1835. {
  1836. annotArgs = GetArrowLine(LineTag, annots);
  1837. }
  1838. else
  1839. {
  1840. annotArgs = GetArrowLine(LineTag);
  1841. }
  1842. #endregion TO DO
  1843. //annotArgs = GetArrowLine(LineTag);
  1844. break;
  1845. }
  1846. ShowPropertyPanel();
  1847. if (string.IsNullOrEmpty(StrAnnotToolChecked) || StrAnnotToolChecked != "Rect")
  1848. {
  1849. //PDFViewer.SetMouseMode(MouseModes.PanTool);
  1850. return;
  1851. }
  1852. if (annotArgs != null)
  1853. {
  1854. annotArgs.Author = Settings.Default.AppProperties.Description.Author;
  1855. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  1856. PDFViewer.SetToolParam(annotArgs);
  1857. }
  1858. }
  1859. }
  1860. }
  1861. //来自属性面板的事件,更改颜色等属性而触发
  1862. private void AnnotPropertyPanel_DataChanged(object sender, Dictionary<AnnotArgsType, object> e)
  1863. {
  1864. if (e != null)
  1865. {
  1866. PropertyPanel.annot.Author = Settings.Default.AppProperties.Description.Author;
  1867. foreach (AnnotArgsType argsType in e.Keys)
  1868. {
  1869. var key = ToolExpandDict.FirstOrDefault(q => q.Value == argsType);
  1870. switch (argsType)
  1871. {
  1872. case AnnotArgsType.AnnotHighlight:
  1873. if (e[argsType] is Color)
  1874. {
  1875. HighLightColor = new SolidColorBrush((Color)e[argsType]);
  1876. }
  1877. if (e[argsType] is double)
  1878. {
  1879. HighLightOpacity = (double)e[argsType];
  1880. }
  1881. //创建注释后,修改注释属性,可用于下次创建的注释
  1882. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1883. {
  1884. if (StrAnnotToolChecked == key.Key)
  1885. {
  1886. PDFViewer.SetToolParam(PropertyPanel.annot);
  1887. }
  1888. }
  1889. break;
  1890. case AnnotArgsType.AnnotUnderline:
  1891. if (e[argsType] is Color)
  1892. {
  1893. UnderLineColor = new SolidColorBrush((Color)e[argsType]);
  1894. }
  1895. if (e[argsType] is double)
  1896. {
  1897. UnderLineOpacity = (double)e[argsType];
  1898. }
  1899. //创建注释后,修改注释属性,可用于下次创建的注释
  1900. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1901. {
  1902. if (StrAnnotToolChecked == key.Key)
  1903. {
  1904. PDFViewer.SetToolParam(PropertyPanel.annot);
  1905. }
  1906. }
  1907. break;
  1908. case AnnotArgsType.AnnotSquiggly:
  1909. if (e[argsType] is Color)
  1910. {
  1911. SquigglyColor = new SolidColorBrush((Color)e[argsType]);
  1912. }
  1913. if (e[argsType] is double)
  1914. {
  1915. SquigglyOpacity = (double)e[argsType];
  1916. }
  1917. //创建注释后,修改注释属性,可用于下次创建的注释
  1918. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1919. {
  1920. if (StrAnnotToolChecked == key.Key)
  1921. {
  1922. PDFViewer.SetToolParam(PropertyPanel.annot);
  1923. }
  1924. }
  1925. break;
  1926. case AnnotArgsType.AnnotStrikeout:
  1927. if (e[argsType] is Color)
  1928. {
  1929. StrikeoutColor = new SolidColorBrush((Color)e[argsType]);
  1930. }
  1931. if (e[argsType] is double)
  1932. {
  1933. StrikeoutOpacity = (double)e[argsType];
  1934. }
  1935. //创建注释后,修改注释属性,可用于下次创建的注释
  1936. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1937. {
  1938. if (StrAnnotToolChecked == key.Key)
  1939. {
  1940. PDFViewer.SetToolParam(PropertyPanel.annot);
  1941. }
  1942. }
  1943. break;
  1944. case AnnotArgsType.AnnotFreehand:
  1945. if (e[argsType] is FreehandAnnotArgs)
  1946. {
  1947. var annot = e[argsType] as FreehandAnnotArgs;
  1948. if (annot != null)
  1949. {
  1950. if (PropertyPanel != null)
  1951. {
  1952. //属性面板,切换橡皮擦后,再回到画笔时,需要恢复最近画笔的属性值
  1953. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib(), PDFViewer);
  1954. PropertyPanel.AnnotEvent = AnnotEvent;
  1955. var AnnotEvents = new List<AnnotAttribEvent>();
  1956. AnnotEvents.Add(AnnotEvent);
  1957. PropertyPanel.AnnotEvents = AnnotEvents;
  1958. PropertyPanel.annot = annot;
  1959. //手绘注释工具按钮的属性
  1960. // FreehandPath.Opacity = annot.Transparency;
  1961. // FreehandPath.Fill = new SolidColorBrush(annot.InkColor);
  1962. }
  1963. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1964. {
  1965. if (StrAnnotToolChecked == key.Key)
  1966. {
  1967. PDFViewer.SetToolParam(PropertyPanel.annot);
  1968. }
  1969. }
  1970. }
  1971. }
  1972. break;
  1973. case AnnotArgsType.AnnotErase:
  1974. if (e[argsType] is ToggleButton)
  1975. {
  1976. ToggleButton clickBtn = e[argsType] as ToggleButton;
  1977. if (clickBtn.IsChecked == true)
  1978. {
  1979. if (clickBtn.Tag.ToString() != "PenBtn")
  1980. {
  1981. CustomIconToggleBtn btn = new CustomIconToggleBtn();
  1982. btn.Tag = "Freehand";
  1983. btn.IsChecked = true;
  1984. BtnMyTools_Click(btn);
  1985. break;
  1986. }
  1987. else
  1988. {
  1989. CreateEraseArgs();
  1990. }
  1991. }
  1992. }
  1993. break;
  1994. case AnnotArgsType.AnnotSquare:
  1995. case AnnotArgsType.AnnotCircle:
  1996. case AnnotArgsType.AnnotLine:
  1997. //创建注释后,修改注释属性,可用于下次创建的注释
  1998. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1999. {
  2000. if (StrAnnotToolChecked == "Rect")
  2001. {
  2002. if (PropertyPanel.SharpsAnnot == key.Key || (PropertyPanel.SharpsAnnot != key.Key && key.Key == "Arrow"))
  2003. {
  2004. PDFViewer.SetToolParam(PropertyPanel.annot);
  2005. }
  2006. PropertyPanel.SaveLastAnnot();
  2007. }
  2008. }
  2009. break;
  2010. //预设 重新定义后 会将文本内容 带上
  2011. case AnnotArgsType.AnnotFreeText:
  2012. if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  2013. {
  2014. if (StrAnnotToolChecked == key.Key)
  2015. {
  2016. if (PropertyPanel.annot is FreeTextAnnotArgs defaultAnnot)
  2017. {
  2018. FreeTextAnnotArgs freetextArgs = new FreeTextAnnotArgs();
  2019. freetextArgs.FontColor = defaultAnnot.FontColor;
  2020. freetextArgs.LineColor = defaultAnnot.LineColor;
  2021. freetextArgs.BgColor = defaultAnnot.BgColor;
  2022. freetextArgs.Transparency = defaultAnnot.Transparency;
  2023. freetextArgs.FontName = defaultAnnot.FontName;
  2024. freetextArgs.FontSize = defaultAnnot.FontSize;
  2025. freetextArgs.IsBold = defaultAnnot.IsBold;
  2026. freetextArgs.IsItalic = defaultAnnot.IsItalic;
  2027. freetextArgs.LineWidth = defaultAnnot.LineWidth;
  2028. freetextArgs.Align = defaultAnnot.Align;
  2029. PDFViewer.SetToolParam(freetextArgs);
  2030. }
  2031. }
  2032. }
  2033. break;
  2034. }
  2035. }
  2036. }
  2037. }
  2038. private void CreateEraseArgs()
  2039. {
  2040. EraseArgs eraseArgs = new EraseArgs();
  2041. eraseArgs.UIBorderColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
  2042. eraseArgs.UIFillColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
  2043. eraseArgs.Thickness = 10;
  2044. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotErase);
  2045. if (annotProperty != null)
  2046. {
  2047. eraseArgs.Thickness = annotProperty.Thickness;
  2048. }
  2049. PDFViewer.ClearSelectAnnots(false);
  2050. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  2051. PDFViewer.SetToolParam(eraseArgs);
  2052. List<AnnotHandlerEventArgs> eraseArgsList = new List<AnnotHandlerEventArgs>();
  2053. if (eraseArgs != null)
  2054. eraseArgsList.Add(eraseArgs);
  2055. AddToPropertyPanel("FreehandAnnotProperty", "Freehand", eraseArgsList);
  2056. }
  2057. #endregion BindingEvent事件
  2058. }
  2059. }