AnnotToolContentViewModel.Command.cs 80 KB

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