AnnotToolContentViewModel.Command.cs 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183
  1. using ComPDFKit.PDFAnnotation;
  2. using ComPDFKit.PDFDocument.Action;
  3. using ComPDFKit.PDFDocument;
  4. using ComPDFKitViewer;
  5. using ComPDFKitViewer.AnnotEvent;
  6. using ComPDFKitViewer.PdfViewer;
  7. using PDF_Office.CustomControl;
  8. using PDF_Office.EventAggregators;
  9. using PDF_Office.Helper;
  10. using PDF_Office.Properties;
  11. using PDF_Office.ViewModels.BOTA;
  12. using PDF_Office.Views.BOTA;
  13. using PDFSettings;
  14. using Prism.Mvvm;
  15. using Prism.Regions;
  16. using System;
  17. using System.Collections.Generic;
  18. using System.Linq;
  19. using System.Text;
  20. using System.Threading.Tasks;
  21. using System.Windows;
  22. using System.Windows.Controls;
  23. using System.Windows.Controls.Primitives;
  24. using System.Windows.Media;
  25. using System.Diagnostics;
  26. using PDF_Office.Model.AnnotPanel;
  27. using System.Windows.Input;
  28. using PDF_Office.ViewModels.Tools.AnnotManager;
  29. namespace PDF_Office.ViewModels.Tools
  30. {
  31. public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
  32. {
  33. #region 事件绑定和解绑
  34. private void BindingEvent()
  35. {
  36. //属性面板与注释工具栏绑定:属性面板的属性变化,会同步注释工具栏的属性值
  37. //比如在属性面板里更改注释颜色,会同时更新工具栏对应的工具颜色
  38. propertyPanel.DataChanged -= AnnotPropertyPanel_DataChanged;
  39. propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
  40. propertyPanel.DefaultStored -= AnnotProperty_DefaultStored;
  41. propertyPanel.DefaultStored += AnnotProperty_DefaultStored;
  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.DefaultStored -= AnnotProperty_DefaultStored;
  52. propertyPanel.AnnotTypeChanged -= AnnotPropertyPanel_AnnotTypeChanged;
  53. //快捷盘解绑
  54. KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
  55. }
  56. private void BindingPDFViewerHandler()
  57. {
  58. //来自PDFViewer的响应事件
  59. if (PDFViewer != null)
  60. {
  61. PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
  62. PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
  63. PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
  64. PDFViewer.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
  65. PDFViewer.AnnotCommandHandler -= PDFViewer_AnnotCommandHandler;
  66. PDFViewer.AnnotCommandHandler += PDFViewer_AnnotCommandHandler;
  67. PDFViewer.WidgetClickHander -= PDFViewer_WidgetClickHander;
  68. PDFViewer.WidgetClickHander += PDFViewer_WidgetClickHander;
  69. PDFViewer.SnapshotCommandHandler -= PDFViewer_SnapshotCommandHandler;
  70. PDFViewer.SnapshotCommandHandler += PDFViewer_SnapshotCommandHandler;
  71. PDFViewer.PDFActionHandler -= PDFViewer_PDFActionHandler;
  72. PDFViewer.PDFActionHandler += PDFViewer_PDFActionHandler;
  73. PDFViewer.AnnotHoverHandler -= PDFViewer_AnnotHoverHandler;
  74. PDFViewer.AnnotHoverHandler += PDFViewer_AnnotHoverHandler;
  75. PDFViewer.PreviewMouseLeftButtonDown -= PDFViewer_PreviewMouseLeftButtonDown;
  76. PDFViewer.PreviewMouseLeftButtonDown += PDFViewer_PreviewMouseLeftButtonDown;
  77. }
  78. }
  79. private void PDFViewer_PDFActionHandler(object sender, ComPDFKit.PDFDocument.Action.CPDFAction action)
  80. {
  81. if (action == null)
  82. {
  83. return;
  84. }
  85. switch (action.ActionType)
  86. {
  87. case C_ACTION_TYPE.ACTION_TYPE_GOTO:
  88. if (PDFViewer != null)
  89. {
  90. CPDFGoToAction gotoAction = action as CPDFGoToAction;
  91. CPDFDestination dest = gotoAction.GetDestination(PDFViewer.Document);
  92. if (dest != null)
  93. {
  94. PDFViewer.GoToPage(dest.PageIndex, new System.Windows.Point(0, 0));
  95. }
  96. }
  97. break;
  98. case C_ACTION_TYPE.ACTION_TYPE_URI:
  99. {
  100. CPDFUriAction uriAction = action as CPDFUriAction;
  101. string uri = uriAction.GetUri();
  102. try
  103. {
  104. if (!string.IsNullOrEmpty(uri))
  105. {
  106. Process.Start(uri);
  107. }
  108. }
  109. catch (Exception ex)
  110. {
  111. }
  112. }
  113. break;
  114. }
  115. }
  116. private void UnBindingPDFViewerHandler()
  117. {
  118. if (PDFViewer != null)
  119. {
  120. PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
  121. PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
  122. PDFViewer.AnnotCommandHandler -= PDFViewer_AnnotCommandHandler;
  123. PDFViewer.WidgetClickHander -= PDFViewer_WidgetClickHander;
  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 == 2)
  136. {
  137. if (CurrentSelectedAnnot != null)
  138. {
  139. var type = CurrentSelectedAnnot.EventType;
  140. if (type != AnnotArgsType.AnnotSticky && type != AnnotArgsType.AnnotFreeText &&
  141. type != AnnotArgsType.AnnotHighlight && type != AnnotArgsType.AnnotUnderline && type != AnnotArgsType.AnnotStrikeout)
  142. {
  143. var rect = CurrentSelectedAnnot.ClientRect;
  144. var ui = PDFViewer.Parent as ContentControl;
  145. if (ui != null)
  146. {
  147. var point = e.GetPosition(ui);
  148. if (rect.Left < point.X && rect.Top < point.Y && (rect.Width + rect.X) >= point.X && (rect.Height + rect.Y) >= point.Y)
  149. {
  150. PopAnnotNoteText(CurrentSelectedAnnot);
  151. }
  152. }
  153. }
  154. }
  155. }
  156. }
  157. //是否为形状注释
  158. private bool isShapAnnot(AnnotHandlerEventArgs annot)
  159. {
  160. if (annot.EventType == AnnotArgsType.AnnotCircle ||
  161. annot.EventType == AnnotArgsType.AnnotSquare ||
  162. annot.EventType == AnnotArgsType.AnnotLine
  163. )
  164. {
  165. return true;
  166. }
  167. else
  168. {
  169. return false;
  170. }
  171. }
  172. //是否为高亮注释
  173. private bool isHightAnnot(AnnotHandlerEventArgs annot)
  174. {
  175. if (annot.EventType == AnnotArgsType.AnnotUnderline ||
  176. annot.EventType == AnnotArgsType.AnnotSquiggly ||
  177. annot.EventType == AnnotArgsType.AnnotHighlight ||
  178. annot.EventType == AnnotArgsType.AnnotStrikeout
  179. )
  180. {
  181. return true;
  182. }
  183. else
  184. {
  185. return false;
  186. }
  187. }
  188. private void GetSelectedAnnots(AnnotAttribEvent e)
  189. {
  190. var annot = e.AnnotItemsList[0];
  191. switch (annot.EventType)
  192. {
  193. case AnnotArgsType.AnnotHighlight:
  194. GetHighLight(e.AnnotItemsList);
  195. break;
  196. case AnnotArgsType.AnnotUnderline:
  197. GetUnderLine(e.AnnotItemsList);
  198. break;
  199. case AnnotArgsType.AnnotStrikeout:
  200. GetStrikeout(e.AnnotItemsList);
  201. break;
  202. case AnnotArgsType.AnnotSquiggly:
  203. GetSquiggly(e.AnnotItemsList);
  204. break;
  205. case AnnotArgsType.AnnotFreehand:
  206. GetFreehand(e.AnnotItemsList);
  207. break;
  208. case AnnotArgsType.AnnotFreeText:
  209. GetFreetext(e.AnnotItemsList);
  210. break;
  211. case AnnotArgsType.AnnotSquare:
  212. GetRect(e.AnnotItemsList);
  213. break;
  214. case AnnotArgsType.AnnotCircle:
  215. GetCircle(e.AnnotItemsList);
  216. break;
  217. case AnnotArgsType.AnnotLine:
  218. bool isLine = true;
  219. if (e.Attribs.ContainsKey(AnnotAttrib.LineStart))
  220. {
  221. 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)
  222. {
  223. isLine = false;
  224. }
  225. }
  226. if (e.Attribs.ContainsKey(AnnotAttrib.LineEnd))
  227. {
  228. 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)
  229. {
  230. isLine = false;
  231. }
  232. }
  233. if (isLine)
  234. GetArrowLine("Line", e.AnnotItemsList);
  235. else
  236. GetArrowLine("Arrow", e.AnnotItemsList);
  237. break;
  238. case AnnotArgsType.AnnotLink:
  239. //viewContentViewModel.IsCreateLink = false;
  240. //e.IsAnnotCreateReset= true;
  241. if (btnLinkIsChecked == false)
  242. {
  243. propertyPanel.IsAddLink = false;
  244. }
  245. GetLink(e.AnnotItemsList, e);
  246. break;
  247. case AnnotArgsType.AnnotSticky:
  248. GetStickyNote(e.AnnotItemsList);
  249. customStickyPopup.GetCurrentAnnot = e.AnnotItemsList[0] as StickyAnnotArgs;
  250. customStickyPopup.GetPDFViewer = PDFViewer;
  251. break;
  252. case AnnotArgsType.AnnotStamp:
  253. GetStamp();
  254. break;
  255. }
  256. }
  257. private void SelectedSignature(List<AnnotHandlerEventArgs> annotlist)
  258. {
  259. if (annotlist == null || annotlist.Count == 0)
  260. return;
  261. var annot = annotlist[0];
  262. if (annot.EventType != AnnotArgsType.AnnotStamp && annot.EventType != AnnotArgsType.AnnotFreehand)
  263. return;
  264. if (annot.PageIndex < 0 || annot.AnnotIndex < 0)
  265. return;
  266. var signAnnot = AnnotSignatures.FirstOrDefault(temp => temp.Item1 == annot.PageIndex && temp.Item2 == annot.AnnotIndex);
  267. if (signAnnot == null)
  268. {
  269. if (annot.EventType == AnnotArgsType.AnnotStamp)
  270. {
  271. StrAnnotToolChecked = "Stamp";
  272. }
  273. else
  274. {
  275. StrAnnotToolChecked = "";
  276. }
  277. }
  278. else
  279. {
  280. GetSignature();
  281. StrAnnotToolChecked = "Signature";
  282. }
  283. }
  284. private void AddAnnotSignature(AnnotHandlerEventArgs annot)
  285. {
  286. if ((annot.EventType != AnnotArgsType.AnnotStamp && annot.EventType != AnnotArgsType.AnnotFreehand) ||
  287. (annot.PageIndex < 0 || annot.AnnotIndex < 0)) return;
  288. if (StrAnnotToolChecked == "Signature")
  289. {
  290. if (AnnotSignatures == null)
  291. AnnotSignatures = new List<Tuple<int, int>>();
  292. var signAnnot = AnnotSignatures.FirstOrDefault(temp => temp.Item1 == annot.PageIndex && temp.Item2 == annot.AnnotIndex);
  293. if (signAnnot == null)
  294. {
  295. AnnotSignatures.Add(new Tuple<int, int>(annot.PageIndex, annot.AnnotIndex));
  296. }
  297. }
  298. }
  299. #endregion 与触发事件调用相关的函数
  300. #region PDFViewer事件
  301. private AnnotHandlerEventArgs CurrentSelectedAnnot = null;
  302. //选中和非选中注释
  303. private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
  304. {
  305. if (e != null)
  306. {
  307. var annot = e.AnnotItemsList[0];
  308. if (annot != null)
  309. {
  310. if (e.AnnotItemsList.Count == 1)
  311. {
  312. //IsAnnotCreateReset:是否为创建注释的状态
  313. if (e.IsAnnotCreateReset == false)
  314. {
  315. GetSelectedAnnots(e);
  316. SelectedSignature(e.AnnotItemsList);
  317. CurrentSelectedAnnot = annot;
  318. if (Settings.Default.AppProperties.InitialVIew.AutoExpandProperty)
  319. ShowPropertyPanel(true);
  320. }
  321. else
  322. {
  323. switch (annot.EventType)
  324. {
  325. case AnnotArgsType.AnnotLink:
  326. //viewContentViewModel.IsCreateLink = false;
  327. GetLink(e.AnnotItemsList, e);
  328. PDFViewer.SetToolParam(annot);
  329. break;
  330. }
  331. //TODO: 修改注释后,会作用到之后添加的注释中。因此先把此逻辑“创建注释后,会自动回到默认值”注释掉
  332. //注释代码原因:设计已经重新调整逻辑:所有注释创建后,编辑属性,所有属性会作用于下次创建的注释中。
  333. //if (annot.EventType != AnnotArgsType.AnnotStrikeout &&
  334. //annot.EventType != AnnotArgsType.AnnotUnderline &&
  335. //annot.EventType != AnnotArgsType.AnnotHighlight &&
  336. //annot.EventType != AnnotArgsType.AnnotSquiggly &&
  337. //annot.EventType != AnnotArgsType.AnnotLink &&
  338. //annot.EventType != AnnotArgsType.AnnotFreehand &&
  339. //annot.EventType != AnnotArgsType.AnnotSticky &&
  340. //)
  341. //{
  342. // if (ToolExpandDict.ContainsValue(e.AnnotItemsList[0].EventType))
  343. // {
  344. // var strLineAnnotTag = "";
  345. // if (e.AnnotItemsList[0] is LineAnnotArgs)
  346. // {
  347. // var lineAnnot = e.AnnotItemsList[0] as LineAnnotArgs;
  348. // if (lineAnnot.HeadLineType == C_LINE_TYPE.LINETYPE_NONE && lineAnnot.TailLineType == C_LINE_TYPE.LINETYPE_NONE)
  349. // {
  350. // strLineAnnotTag = "Line";
  351. // }
  352. // else
  353. // {
  354. // strLineAnnotTag = "Arrow";
  355. // }
  356. // }
  357. // foreach (var item in ToolExpandDict)
  358. // {
  359. // if (item.Value == e.AnnotItemsList[0].EventType)
  360. // {
  361. // annot = null;//新建注释时,回到默认值
  362. // if (string.IsNullOrEmpty(strLineAnnotTag))
  363. // {
  364. // FindAnnotTypeKey(item.Key, ref annot);
  365. // break;
  366. // }
  367. // else
  368. // {
  369. // if (strLineAnnotTag == item.Key)
  370. // {
  371. // FindAnnotTypeKey(item.Key, ref annot);
  372. // break;
  373. // }
  374. // }
  375. // }
  376. // }
  377. // PDFViewer.SetToolParam(annot);
  378. // }
  379. //}
  380. #region TO DO
  381. //设计重新调整,阅读页空白处,右键菜单,添加链接需要显示,其他和pro mac一样的效果,不显示属性栏
  382. //if (isRightMenuAddAnnot && annot.EventType!=AnnotArgsType.AnnotLink)
  383. //{
  384. // ShowPropertyPanel(false);
  385. //}
  386. //else
  387. //{
  388. // ShowPropertyPanel();
  389. //}
  390. #endregion TO DO
  391. }
  392. }
  393. else
  394. {
  395. bool isDifferentAnnotTyle = false;
  396. var lastAnnot = annot;
  397. foreach (var item in e.AnnotItemsList)
  398. {
  399. if (lastAnnot.EventType != item.EventType)
  400. {
  401. if ((isShapAnnot(annot) == true && isShapAnnot(item) == true) || (isHightAnnot(annot) == true && isHightAnnot(item) == true))
  402. {
  403. lastAnnot = item;
  404. continue;
  405. }
  406. lastAnnot = item;
  407. isDifferentAnnotTyle = true;
  408. break;
  409. }
  410. }
  411. if (isDifferentAnnotTyle)
  412. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  413. else
  414. GetSelectedAnnots(e);
  415. }
  416. }
  417. //注释列表同步选中
  418. var list = e.GetPageAnnotsIndex();
  419. bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  420. if (viewContentViewModel.OpenBOTA == true && isTabItemAnnotation == true && bOTAContent.TabItemAnnotation.IsSelected == true && list != null && list.Count > 0)
  421. {
  422. if (list.Keys.Count == 0)
  423. {
  424. return;
  425. }
  426. var pageindex = new List<int>(list.Keys);
  427. List<int> annotes = new List<int>();
  428. list.TryGetValue(pageindex[0], out annotes);
  429. int annoteindex = annotes[0];
  430. AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
  431. if (viewModel != null)
  432. {
  433. viewModel.ScrollToAnnot(pageindex[0], annoteindex, annotation.AnnotationList);
  434. }
  435. }
  436. }
  437. else
  438. {
  439. if (BtnLinkIsChecked == false)
  440. {
  441. if (PDFViewer.MouseMode != MouseModes.AnnotCreate)
  442. {
  443. if (PDFViewer.MouseMode == MouseModes.PanTool && propertyPanel.IsAddLink == false && propertyPanel.IsLocationLink == false)
  444. {
  445. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  446. }
  447. }
  448. }
  449. }
  450. }
  451. //在注释工具的状态下,右键菜单
  452. private void PDFViewer_AnnotCommandHandler(object sender, AnnotCommandArgs e)
  453. {
  454. if (e.AnnotEventArgsList == null || (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool))
  455. return;
  456. switch (e.CommandType)
  457. {
  458. case CommandType.Context:
  459. if (e.AnnotEventArgsList.Count > 0)
  460. {
  461. if (App.mainWindowViewModel.SelectedItem.IsInReadctonMode && e.AnnotEventArgsList[0].EventType == AnnotArgsType.AnnotRedaction)
  462. {
  463. //绑定标记密文处右键菜单
  464. events.GetEvent<RedactionCommandEvent>().Publish(new RedactionCommandEventArgs() { UniCode = App.mainWindowViewModel.SelectedItem.Unicode, Sender = sender, args = e });
  465. }
  466. else
  467. {
  468. if (e.AnnotEventArgsList.Count == 1)
  469. {
  470. var selectedAnnot = e.AnnotEventArgsList[0];
  471. PopMenuCheckedLineDash(selectedAnnot);
  472. PopMenuCheckedFontFamily(selectedAnnot);
  473. PopMenuCheckedTextAglin(selectedAnnot);
  474. switch (selectedAnnot.EventType)
  475. {
  476. case AnnotArgsType.AnnotHighlight:
  477. case AnnotArgsType.AnnotUnderline:
  478. case AnnotArgsType.AnnotStrikeout:
  479. case AnnotArgsType.AnnotSquiggly:
  480. if (selectedAnnot.EventType == AnnotArgsType.AnnotHighlight)
  481. {
  482. colorContent.ItemSource = AnnotColorList.GetColorList(ColorSelectorType.Highlight);
  483. }
  484. else
  485. {
  486. colorContent.ItemSource = AnnotColorList.GetColorList(ColorSelectorType.Border);
  487. }
  488. e.PopupMenu = HightAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  489. break;
  490. case AnnotArgsType.AnnotFreehand:
  491. e.PopupMenu = FreeHandAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  492. break;
  493. case AnnotArgsType.AnnotFreeText:
  494. e.PopupMenu = FreeTextAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  495. break;
  496. case AnnotArgsType.AnnotSticky:
  497. e.PopupMenu = StrickNoteAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  498. break;
  499. case AnnotArgsType.AnnotSquare:
  500. case AnnotArgsType.AnnotCircle:
  501. ShapeAnnotPopMenu.SetVisual("ShapeDirect", false);
  502. ShapeAnnotPopMenu.SetVisual("ShapeFillColor", true);
  503. e.PopupMenu = ShapeAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  504. break;
  505. case AnnotArgsType.AnnotLine:
  506. ShapeAnnotPopMenu.SetVisual("ShapeFillColor", false);
  507. ShapeAnnotPopMenu.SetVisual("ShapeDirect", true);
  508. e.PopupMenu = ShapeAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  509. break;
  510. case AnnotArgsType.AnnotLink:
  511. e.PopupMenu = LinkAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  512. break;
  513. case AnnotArgsType.AnnotStamp:
  514. e.PopupMenu = StampAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  515. break;
  516. }
  517. }
  518. else
  519. {
  520. bool isHigh = true;//是否为高亮
  521. foreach (var item in e.AnnotEventArgsList)
  522. {
  523. if (isHightAnnot(item) == false)
  524. {
  525. isHigh = false;
  526. break;
  527. }
  528. }
  529. MultiAnnotPopMenu.SetVisual("MultiCopy", !isHigh);
  530. MultiAnnotPopMenu.SetVisual("MultiCut", !isHigh);
  531. e.PopupMenu = MultiAnnotPopMenu.OpenMenu(e.AnnotEventArgsList, sender);//SelectMultiAnnotMenu(e.AnnotEventArgsList, isHigh);
  532. }
  533. }
  534. if (e.PopupMenu != null)
  535. {
  536. e.Handle = true;
  537. }
  538. }
  539. else
  540. {
  541. if (e.PressOnSelectedText || e.CommandTarget == TargetType.ImageSelection)
  542. {
  543. e.PopupMenu = SelectedTextOrImageContextMenu(sender, e);
  544. if (e.PopupMenu != null)
  545. {
  546. e.Handle = true;
  547. }
  548. }
  549. else
  550. {
  551. e.PopupMenu = ViewerContextMenu(sender);
  552. if (e.PopupMenu != null)
  553. {
  554. e.Handle = true;
  555. }
  556. }
  557. }
  558. break;
  559. }
  560. }
  561. //右键菜单,选中字体样式按钮状态
  562. private void PopMenuCheckedFontFamily(AnnotHandlerEventArgs annot)
  563. {
  564. if (annot != null)
  565. {
  566. if (annot.EventType == AnnotArgsType.AnnotFreeText)
  567. {
  568. var freeText = annot as FreeTextAnnotArgs;
  569. FreeTextAnnotPopMenu.SetIsChecked(freeText.FontFamily.ToString(), true);
  570. }
  571. }
  572. }
  573. //右键菜单,选中文本内容对齐按钮状态
  574. private void PopMenuCheckedTextAglin(AnnotHandlerEventArgs annot)
  575. {
  576. if (annot != null)
  577. {
  578. if (annot.EventType == AnnotArgsType.AnnotFreeText)
  579. {
  580. var freeText = annot as FreeTextAnnotArgs;
  581. switch (freeText.Align)
  582. {
  583. case TextAlignment.Left:
  584. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinLeft", true);
  585. break;
  586. case TextAlignment.Center:
  587. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinCenter", true);
  588. break;
  589. case TextAlignment.Right:
  590. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinRight", true);
  591. break;
  592. case TextAlignment.Justify:
  593. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinJustify", true);
  594. break;
  595. default:
  596. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinLeft", false);
  597. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinCenter", false);
  598. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinRight", false);
  599. FreeTextAnnotPopMenu.SetIsChecked("FreeTextAglinJustify", false);
  600. break;
  601. }
  602. }
  603. }
  604. }
  605. //右键菜单,选中虚实线按钮状态
  606. private void PopMenuCheckedLineDash(AnnotHandlerEventArgs annot)
  607. {
  608. if (annot != null)
  609. {
  610. bool isSolidLineDash = true;
  611. if (annot.EventType == AnnotArgsType.AnnotFreehand)
  612. {
  613. var freeHand = annot as FreehandAnnotArgs;
  614. isSolidLineDash = AnnotTransfer.IsSolidStyle(freeHand.LineDash);
  615. FreeHandAnnotPopMenu.SetIsChecked(isSolidLineDash ? "FreeHandSolid" : "FreeHandDash", true);
  616. }
  617. else if (annot.EventType == AnnotArgsType.AnnotSquare)
  618. {
  619. var square = annot as SquareAnnotArgs;
  620. isSolidLineDash = AnnotTransfer.IsSolidStyle(square.LineDash);
  621. ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
  622. }
  623. else if (annot.EventType == AnnotArgsType.AnnotCircle)
  624. {
  625. var circle = annot as CircleAnnotArgs;
  626. isSolidLineDash = AnnotTransfer.IsSolidStyle(circle.LineDash);
  627. ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
  628. }
  629. else if (annot.EventType == AnnotArgsType.AnnotLine)
  630. {
  631. var line = annot as LineAnnotArgs;
  632. isSolidLineDash = AnnotTransfer.IsSolidStyle(line.LineDash);
  633. ShapeAnnotPopMenu.SetIsChecked(isSolidLineDash ? "ShapeSolid" : "ShapeDash", true);
  634. }
  635. }
  636. }
  637. /// <summary>
  638. /// 内容选择工具
  639. /// </summary>
  640. /// <param name="sender"></param>
  641. /// <param name="e"></param>
  642. private void PDFViewer_SnapshotCommandHandler(object sender, SnapshotCommandArgs e)
  643. {
  644. SnapshotEditToolArgs snapToolArgs = (SnapshotEditToolArgs)PDFViewer.ToolManager.CurrentAnnotArgs;
  645. SnapshotEditMenuViewModel.SnapToolArgs = snapToolArgs;
  646. SnapshotEditMenuViewModel.PDFViewer = PDFViewer;
  647. SnapshotEditMenuViewModel.SnapToolEvent -= SnapshotEditMenuViewModel_SnapToolEvent; ;
  648. SnapshotEditMenuViewModel.SnapToolEvent += SnapshotEditMenuViewModel_SnapToolEvent;
  649. var popMenu = App.Current.FindResource("SnapshotContextMenu") as ContextMenu;
  650. if (e.HitSnapshotTool && e.SnapshotRect.Width > 0 && e.SnapshotRect.Height > 0)
  651. {
  652. e.PopupMenu = popMenu;
  653. e.Handle = true;
  654. if (popMenu != null && popMenu.Items.Count == 5)
  655. {
  656. //复制
  657. MenuItem menuItem = popMenu.Items[0] as MenuItem;
  658. menuItem.CommandTarget = PDFViewer;
  659. menuItem.Command = SnapshotEditMenuViewModel.SnapCopyCommand;
  660. //导出
  661. menuItem = popMenu.Items[1] as MenuItem;
  662. menuItem.CommandTarget = PDFViewer;
  663. if (menuItem.Items.Count == 3)
  664. {
  665. MenuItem menuItem1 = menuItem.Items[0] as MenuItem;
  666. menuItem1.CommandTarget = PDFViewer;
  667. menuItem1.Command = SnapshotEditMenuViewModel.ExportPNGCommand;
  668. menuItem1 = menuItem.Items[1] as MenuItem;
  669. menuItem1.CommandTarget = PDFViewer;
  670. menuItem1.Command = SnapshotEditMenuViewModel.ExportJPGCommand;
  671. menuItem1 = menuItem.Items[2] as MenuItem;
  672. menuItem1.CommandTarget = PDFViewer;
  673. menuItem1.Command = SnapshotEditMenuViewModel.ExportPDFCommand;
  674. }
  675. //裁剪
  676. menuItem = popMenu.Items[2] as MenuItem;
  677. menuItem.CommandTarget = PDFViewer;
  678. menuItem.Command = SnapshotEditMenuViewModel.CroppingCommand;
  679. //缩放至所选区域
  680. menuItem = popMenu.Items[3] as MenuItem;
  681. menuItem.CommandTarget = PDFViewer;
  682. menuItem.Visibility = Visibility.Collapsed;
  683. //menuItem.Command = snapshotEditMenuViewModel.CroppingCommand;
  684. //打印
  685. menuItem = popMenu.Items[4] as MenuItem;
  686. menuItem.CommandTarget = PDFViewer;
  687. menuItem.Command = SnapshotEditMenuViewModel.PrintCommand;
  688. }
  689. }
  690. }
  691. private void SnapshotEditMenuViewModel_SnapToolEvent(object sender, KeyValuePair<string, object> e)
  692. {
  693. switch (e.Key)
  694. {
  695. case "CloseSnap":
  696. {
  697. #region to do
  698. //var item = PDFViewerTab.SelectedItem as TabItem;
  699. //if (item == null)
  700. //{
  701. // ClearSelectedToolPanel();
  702. // return;
  703. //}
  704. //Grid grid = item.Content as Grid;
  705. //if (grid == null || grid.Children.Count == 0)
  706. //{
  707. // ClearSelectedToolPanel();
  708. // return;
  709. //}
  710. //PDFViewerCtrl pdfViewer = grid.Children[0] as PDFViewerCtrl;
  711. //if (pdfViewer == null)
  712. //{
  713. // ClearSelectedToolPanel();
  714. // return;
  715. //}
  716. #endregion to do
  717. switch (PDFViewer.MouseMode)
  718. {
  719. case MouseModes.SelectTextTool:
  720. break;
  721. default:
  722. BtnSelecttoolIsChecked = false;
  723. BtnHandIsChecked = true;
  724. PDFViewer.EnableZoom(true);
  725. PDFViewer.EnableScroll(true);
  726. break;
  727. }
  728. }
  729. break;
  730. default:
  731. break;
  732. }
  733. }
  734. private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
  735. {
  736. if (e != null && e.Count > 0)
  737. {
  738. for (int i = 0; i < e.Count; i++)
  739. {
  740. AnnotEditEvent editEvent = e[i];
  741. switch (editEvent.EditAction)
  742. {
  743. case ActionType.Add:
  744. bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  745. if (viewContentViewModel.OpenBOTA == true && isTabItemAnnotation == true)
  746. {
  747. AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
  748. if (viewModel != null)
  749. {
  750. int pageindex = editEvent.PageIndex;
  751. int annotindex = editEvent.AnnotIndex;
  752. viewModel.UpdateAddedAnnot(pageindex, annotindex);
  753. }
  754. }
  755. var annot = e[0].EditAnnotArgs;
  756. if (
  757. annot.EventType == AnnotArgsType.AnnotSquare ||
  758. annot.EventType == AnnotArgsType.AnnotCircle ||
  759. annot.EventType == AnnotArgsType.AnnotLine ||
  760. annot.EventType == AnnotArgsType.AnnotStamp
  761. )
  762. {
  763. PDFViewer.ClearSelectAnnots();
  764. if (StrAnnotToolChecked != "Signature")
  765. {
  766. PDFViewer.SelectAnnotation(annot.PageIndex, annot.AnnotIndex);
  767. }
  768. else
  769. {
  770. AddAnnotSignature(annot);
  771. PDFViewer.SelectAnnotation(annot.PageIndex, annot.AnnotIndex);
  772. }
  773. }
  774. break;
  775. case ActionType.Del:
  776. isTabItemAnnotation = IsBOTATabItemShow(out bOTAContentViewModel, out bOTAContent, "TabItemAnnotation");
  777. if (isTabItemAnnotation)
  778. {
  779. AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
  780. if (viewModel != null)
  781. {
  782. int pageindex = editEvent.PageIndex;
  783. int annotindex = editEvent.AnnotIndex;
  784. viewModel.UpdateModifiedAnnot(pageindex, annotindex, true);
  785. }
  786. }
  787. break;
  788. case ActionType.Modify:
  789. isTabItemAnnotation = IsBOTATabItemShow(out bOTAContentViewModel, out bOTAContent, "TabItemAnnotation");
  790. if (bOTAContent.TabItemAnnotation.IsSelected)
  791. {
  792. AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
  793. if (viewModel != null)
  794. {
  795. int pageindex = editEvent.PageIndex;
  796. int annotindex = editEvent.AnnotIndex;
  797. viewModel.UpdateModifiedAnnot(pageindex, annotindex, false);
  798. }
  799. }
  800. break;
  801. case ActionType.TextEdit:
  802. break;
  803. default:
  804. break;
  805. }
  806. }
  807. //空白处 右键菜单 添加注释 为单次添加,不连续添加
  808. if (IsNoSelectMenu)
  809. {
  810. IsNoSelectMenu = false;
  811. PDFViewer.SetMouseMode(MouseModes.PanTool);
  812. }
  813. }
  814. }
  815. private void PDFViewer_WidgetClickHander(object sender, WidgetArgs e)
  816. {
  817. }
  818. private void PDFViewer_AnnotHoverHandler(object sender, AnnotHoverData e)
  819. {
  820. if (e != null && e.DrawContext != null)
  821. {
  822. Rect hoverRect = new Rect(
  823. e.PaintRect.Left - 2,
  824. e.PaintRect.Top - 2,
  825. e.PaintRect.Width + 4,
  826. e.PaintRect.Height + 4);
  827. Pen hoverPen = new Pen(new SolidColorBrush(Color.FromArgb(0xff, 0x11, 0x8A, 0xff)), 1);
  828. hoverPen.DashStyle = DashStyles.Dash;
  829. e.DrawContext?.DrawRectangle(null, hoverPen, hoverRect);
  830. //便签,显示ToolTip内容
  831. if (e.Annot != null && e.Annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_TEXT)
  832. {
  833. if (PDFViewer.ToolTip == null)
  834. {
  835. var content = e.Annot.GetContent();
  836. if (string.IsNullOrEmpty(content) == false)
  837. {
  838. ToolTip TipChild = new ToolTip();
  839. TipChild.Style = App.Current.Resources["FlowToolTip"] as Style;
  840. TipChild.MaxWidth = 246;
  841. TipChild.Content = content;
  842. TipChild.Visibility = Visibility.Visible;
  843. TipChild.IsOpen = true;
  844. TipChild.Placement = PlacementMode.Right;
  845. var rec = e.Annot.GetRect();
  846. TipChild.PlacementRectangle = new Rect(rec.left, rec.top, rec.right, rec.bottom);
  847. TipChild.PlacementTarget = PDFViewer.Parent as ContentControl;
  848. TipChild.Placement = PlacementMode.MousePoint;
  849. PDFViewer.ToolTip = TipChild;
  850. oldRect = hoverRect;
  851. PDFViewer.MouseMove -= PDFViewer_MouseMove;
  852. PDFViewer.MouseMove += PDFViewer_MouseMove;
  853. return;
  854. }
  855. }
  856. }
  857. }
  858. CloseAnnotToolTip();
  859. }
  860. private Rect oldRect = new Rect(0, 0, 0, 0);
  861. private void CloseAnnotToolTip()
  862. {
  863. if (PDFViewer.ToolTip != null && PDFViewer.ToolTip is ToolTip)
  864. {
  865. ToolTip oldTips = (ToolTip)PDFViewer.ToolTip;
  866. oldTips.IsOpen = false;
  867. oldTips.Visibility = Visibility.Collapsed;
  868. PDFViewer.ToolTip = null;
  869. PDFViewer.MouseMove -= PDFViewer_MouseMove;
  870. oldRect = new Rect(0, 0, 0, 0);
  871. }
  872. }
  873. private void PDFViewer_MouseMove(object sender, MouseEventArgs e)
  874. {
  875. if (sender != null && PDFViewer.ToolTip != null && PDFViewer.Parent != null)
  876. {
  877. var newPoint = e.GetPosition(PDFViewer.Parent as ContentControl);
  878. var isOutw = newPoint.X > (oldRect.X + oldRect.Width + 4);
  879. var isOuth = newPoint.Y > (oldRect.Y + oldRect.Height + 4);
  880. if (newPoint.X < oldRect.X || newPoint.Y < oldRect.Y || isOutw || isOuth)
  881. {
  882. CloseAnnotToolTip();
  883. }
  884. }
  885. }
  886. #endregion PDFViewer事件
  887. #region BindingEvent事件
  888. private void AnnotProperty_DefaultStored(object sender, object e)
  889. {
  890. }
  891. //同一属性面板,不同的注释类型
  892. private void AnnotPropertyPanel_AnnotTypeChanged(object sender, Dictionary<AnnotArgsType, object> e)
  893. {
  894. if (e != null)
  895. {
  896. AnnotHandlerEventArgs annotArgs = null;
  897. foreach (AnnotArgsType argsType in e.Keys)
  898. {
  899. switch (argsType)
  900. {
  901. case AnnotArgsType.AnnotSquare:
  902. annotArgs = GetRect();
  903. break;
  904. case AnnotArgsType.AnnotCircle:
  905. annotArgs = GetCircle();
  906. break;
  907. case AnnotArgsType.AnnotLine:
  908. var LineTag = e[argsType] as string;
  909. annotArgs = GetArrowLine(LineTag);
  910. break;
  911. }
  912. if (annotArgs != null)
  913. {
  914. annotArgs.Author = Settings.Default.AppProperties.Description.Author;
  915. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  916. PDFViewer.SetToolParam(annotArgs);
  917. }
  918. ShowPropertyPanel();
  919. }
  920. }
  921. }
  922. private void AnnotPropertyPanel_DataChanged(object sender, Dictionary<AnnotArgsType, object> e)
  923. {
  924. if (e != null)
  925. {
  926. foreach (AnnotArgsType argsType in e.Keys)
  927. {
  928. switch (argsType)
  929. {
  930. case AnnotArgsType.AnnotHighlight:
  931. if (e[argsType] is Color)
  932. {
  933. HighLightColor = new SolidColorBrush((Color)e[argsType]);
  934. }
  935. if (e[argsType] is double)
  936. {
  937. HighLightOpacity = (double)e[argsType];
  938. }
  939. break;
  940. case AnnotArgsType.AnnotUnderline:
  941. if (e[argsType] is Color)
  942. {
  943. UnderLineColor = new SolidColorBrush((Color)e[argsType]);
  944. }
  945. if (e[argsType] is double)
  946. {
  947. underLineOpacity = (double)e[argsType];
  948. }
  949. break;
  950. case AnnotArgsType.AnnotSquiggly:
  951. if (e[argsType] is Color)
  952. {
  953. SquigglyColor = new SolidColorBrush((Color)e[argsType]);
  954. }
  955. if (e[argsType] is double)
  956. {
  957. SquigglyOpacity = (double)e[argsType];
  958. }
  959. break;
  960. case AnnotArgsType.AnnotStrikeout:
  961. if (e[argsType] is Color)
  962. {
  963. StrikeoutColor = new SolidColorBrush((Color)e[argsType]);
  964. }
  965. if (e[argsType] is double)
  966. {
  967. StrikeoutOpacity = (double)e[argsType];
  968. }
  969. break;
  970. case AnnotArgsType.AnnotFreehand:
  971. if (e[argsType] is FreehandAnnotArgs)
  972. {
  973. var annot = e[argsType] as FreehandAnnotArgs;
  974. if (annot != null)
  975. {
  976. if (propertyPanel != null)
  977. {
  978. //属性面板,切换橡皮擦后,再回到画笔时,需要恢复最近画笔的属性值
  979. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  980. propertyPanel.AnnotEvent = AnnotEvent;
  981. var AnnotEvents = new List<AnnotAttribEvent>();
  982. AnnotEvents.Add(AnnotEvent);
  983. propertyPanel.AnnotEvents = AnnotEvents;
  984. propertyPanel.annot = annot;
  985. //手绘注释工具按钮的属性
  986. // FreehandPath.Opacity = annot.Transparency;
  987. // FreehandPath.Fill = new SolidColorBrush(annot.InkColor);
  988. }
  989. PDFViewer.SetToolParam(annot);
  990. }
  991. }
  992. break;
  993. case AnnotArgsType.AnnotErase:
  994. if (e[argsType] is ToggleButton)
  995. {
  996. ToggleButton clickBtn = e[argsType] as ToggleButton;
  997. if (clickBtn.IsChecked == true)
  998. {
  999. if (clickBtn.Tag.ToString() == "PenBtn")
  1000. {
  1001. CustomIconToggleBtn btn = new CustomIconToggleBtn();
  1002. btn.Tag = "Freehand"; btn.IsChecked = true;
  1003. BtnMyTools_Click(btn);
  1004. break;
  1005. }
  1006. EraseArgs eraseArgs = new EraseArgs();
  1007. eraseArgs.UIBorderColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
  1008. eraseArgs.UIFillColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
  1009. eraseArgs.Thickness = 10;
  1010. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotErase);
  1011. if (annotProperty != null)
  1012. {
  1013. eraseArgs.Thickness = annotProperty.Thickness;
  1014. }
  1015. PDFViewer.ClearSelectAnnots(false);
  1016. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  1017. PDFViewer.SetToolParam(eraseArgs);
  1018. List<AnnotHandlerEventArgs> eraseArgsList = new List<AnnotHandlerEventArgs>();
  1019. if (eraseArgs != null)
  1020. eraseArgsList.Add(eraseArgs);
  1021. AddToPropertyPanel("FreehandAnnotProperty", "Freehand", eraseArgsList);
  1022. }
  1023. }
  1024. break;
  1025. case AnnotArgsType.AnnotSquare:
  1026. case AnnotArgsType.AnnotCircle:
  1027. case AnnotArgsType.AnnotLine:
  1028. case AnnotArgsType.AnnotFreeText:
  1029. //创建注释后,修改注释属性,可用于下次创建的注释
  1030. if (propertyPanel != null && propertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
  1031. {
  1032. PDFViewer.SetToolParam(propertyPanel.annot);
  1033. }
  1034. break;
  1035. }
  1036. }
  1037. }
  1038. }
  1039. #endregion BindingEvent事件
  1040. }
  1041. }