CPDFViewerTool.xaml.cs 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304
  1. using ComPDFKit.Import;
  2. using ComPDFKit.PDFAnnotation;
  3. using ComPDFKit.PDFDocument;
  4. using ComPDFKit.PDFDocument.Action;
  5. using ComPDFKit.PDFPage;
  6. using ComPDFKit.Tool.DrawTool;
  7. using ComPDFKit.Tool.FillTool;
  8. using ComPDFKit.Tool.Help;
  9. using ComPDFKit.Tool.SettingParam;
  10. using ComPDFKit.Viewer.Helper;
  11. using ComPDFKit.Viewer.Layer;
  12. using ComPDFKitViewer;
  13. using ComPDFKitViewer.Annot;
  14. using ComPDFKitViewer.BaseObject;
  15. using ComPDFKitViewer.Helper;
  16. using ComPDFKitViewer.Layer;
  17. using ComPDFKitViewer.Widget;
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Diagnostics;
  21. using System.Windows;
  22. using System.Windows.Controls;
  23. using System.Windows.Input;
  24. using System.Windows.Media;
  25. using UndoAction = ComPDFKitViewer.Helper.UndoAction;
  26. namespace ComPDFKit.Tool
  27. {
  28. public struct MouseEventObject
  29. {
  30. public MouseEventArgs mouseButtonEventArgs;
  31. public MouseHitTestType hitTestType;
  32. public C_ANNOTATION_TYPE annotType;
  33. /// <summary>
  34. /// Identifies whether the object is created
  35. /// </summary>
  36. public bool IsCreate;
  37. public bool IsDrawing;
  38. public bool IsMersured;
  39. public object Data;
  40. }
  41. public enum MouseHitTestType
  42. {
  43. Unknown,
  44. Text,
  45. Annot,
  46. SelectRect,
  47. Widget,
  48. TextEdit,
  49. ImageEdit,
  50. ImageSelect,
  51. MultiTextEdit,
  52. SelectedPageRect,
  53. MultiSelector
  54. }
  55. public enum ToolType
  56. {
  57. None = -1,
  58. Viewer,
  59. Pan,
  60. CreateAnnot,
  61. WidgetEdit,
  62. ContentEdit,
  63. Customize,
  64. SelectedPage,
  65. /// <summary>
  66. /// Scroller Tool
  67. /// </summary>
  68. ViewerScroller
  69. }
  70. public partial class CPDFViewerTool : UserControl
  71. {
  72. public bool IsDocumentModified
  73. {
  74. get => isDocumentModified;
  75. set
  76. {
  77. isDocumentModified = value;
  78. DocumentModifiedChanged?.Invoke(this, EventArgs.Empty);
  79. }
  80. }
  81. public CPDFViewerTool()
  82. {
  83. InitializeComponent();
  84. BindCommand();
  85. Application.Current.Exit += Current_Exit;
  86. InsertSelectImageView();
  87. InsertAnnotView();
  88. InsertAnnotEditView();
  89. InsertWidgetView();
  90. InsertSelectedRectView();
  91. InsertMultiSelectedRectView();
  92. InsertCustomizeToolView();
  93. InsertSelectTextView();
  94. //Frame Select
  95. InsertFrameSelectToolView();
  96. InsertTextEditView();
  97. InsertPageSelectedRectView();
  98. AnnotSelectInsert();
  99. FillManager = new FillManager(this);
  100. }
  101. internal void InvokeMouseLeftDown(MouseEventObject e)
  102. {
  103. MouseLeftButtonDownHandler?.Invoke(this, e);
  104. }
  105. private void Current_Exit(object sender, ExitEventArgs e)
  106. {
  107. GetCPDFViewer().Dispose();
  108. }
  109. protected override Visual GetVisualChild(int index)
  110. {
  111. return base.GetVisualChild(index);
  112. }
  113. protected override int VisualChildrenCount => base.VisualChildrenCount;
  114. public event EventHandler<MouseEventObject> MouseLeftButtonDownHandler;
  115. public event EventHandler<MouseEventObject> MouseLeftButtonUpHandler;
  116. public event EventHandler<MouseEventObject> MouseMoveHandler;
  117. public event EventHandler<MouseEventObject> MouseRightButtonDownHandler;
  118. public event EventHandler<ScrollChangedEventArgs> ScrollChangedHandler;
  119. public event EventHandler DrawChanged;
  120. public event EventHandler DocumentModifiedChanged;
  121. private ToolType currentModel = ToolType.Viewer;
  122. DefaultSettingParam defaultSettingParam = new DefaultSettingParam();
  123. DefaultDrawParam defaultDrawParam = new DefaultDrawParam();
  124. MeasureSetting measureSetting = new MeasureSetting();
  125. Point Point = new Point();
  126. Point CachePoint = new Point();
  127. private bool isMultiSelected;
  128. private bool isDocumentModified = false;
  129. public FillManager FillManager { get; private set; }
  130. public bool CanAddTextEdit = true;
  131. protected bool isContinueCreateTextEdit = false;
  132. public bool GetIsMultiSelected()
  133. {
  134. return isMultiSelected;
  135. }
  136. /// <summary>
  137. /// Set whether continuous text editing is required
  138. /// </summary>
  139. /// <param name="isContinueCreateTextEdit"></param>
  140. public void SetContinueCreateTextEdit(bool isContinueCreateTextEdit)
  141. {
  142. this.isContinueCreateTextEdit = isContinueCreateTextEdit;
  143. CanAddTextEdit = true;
  144. }
  145. /// <summary>
  146. /// Does it support multiple selection
  147. /// </summary>
  148. /// <param name="isMulti">true Can MultiSelected</param>
  149. public void SetIsMultiSelected(bool isMulti)
  150. {
  151. isMultiSelected = isMulti;
  152. }
  153. public DefaultSettingParam GetDefaultSettingParam()
  154. {
  155. return defaultSettingParam;
  156. }
  157. public DefaultDrawParam GetDefaultDrawParam()
  158. {
  159. return defaultDrawParam;
  160. }
  161. /// <summary>
  162. /// Set default painting parameters
  163. /// </summary>
  164. /// <param name="defaultDrawParam"></param>
  165. public void SetDefaultDrawParam(DefaultDrawParam defaultDrawParam = null)
  166. {
  167. if (defaultDrawParam == null)
  168. {
  169. this.defaultDrawParam = new DefaultDrawParam();
  170. }
  171. else
  172. {
  173. this.defaultDrawParam = defaultDrawParam;
  174. }
  175. }
  176. public MeasureSetting GetMeasureSetting()
  177. {
  178. return measureSetting;
  179. }
  180. public bool IsSelectRectMousePoint()
  181. {
  182. if (DrawSelectRectDownEvent() && cacheHitTestAnnot != null)
  183. {
  184. return true;
  185. }
  186. return false;
  187. }
  188. private void LinkAnnotAction(BaseAnnot annot)
  189. {
  190. AnnotData data = annot.GetAnnotData();
  191. CPDFLinkAnnotation linkAnnot = data.Annot as CPDFLinkAnnotation;
  192. CPDFAction action = linkAnnot.GetLinkAction();
  193. if (action != null)
  194. {
  195. ActionProcess(action);
  196. }
  197. else
  198. {
  199. CPDFDestination dest = linkAnnot.GetDestination(PDFViewer.GetDocument());
  200. if (dest != null)
  201. {
  202. CPDFGoToAction gotoAction = new CPDFGoToAction();
  203. gotoAction.SetDestination(PDFViewer.GetDocument(), dest);
  204. ActionProcess(gotoAction);
  205. }
  206. }
  207. }
  208. public void ActionProcess(CPDFAction action)
  209. {
  210. if (action == null)
  211. {
  212. return;
  213. }
  214. switch (action.ActionType)
  215. {
  216. case C_ACTION_TYPE.ACTION_TYPE_NAMED:
  217. {
  218. CPDFNamedAction namedAction = action as CPDFNamedAction;
  219. string namedStr = namedAction.GetName();
  220. switch (namedStr)
  221. {
  222. case "FirstPage":
  223. {
  224. PDFViewer?.GoToPage(0, new Point(0, 0));
  225. break;
  226. }
  227. case "LastPage":
  228. {
  229. PDFViewer?.GoToPage(PDFViewer.GetDocument().PageCount - 1, new Point(0, 0));
  230. break;
  231. }
  232. case "NextPage":
  233. if (PDFViewer != null)
  234. {
  235. int nextIndex = PDFViewer.CurrentRenderFrame.PageIndex + 1;
  236. if (nextIndex < PDFViewer.GetDocument().PageCount)
  237. {
  238. PDFViewer.GoToPage(nextIndex, new Point(0, 0));
  239. }
  240. }
  241. break;
  242. case "PrevPage":
  243. if (PDFViewer != null)
  244. {
  245. int prevIndex = PDFViewer.CurrentRenderFrame.PageIndex - 1;
  246. if (prevIndex >= 0)
  247. {
  248. PDFViewer.GoToPage(prevIndex, new Point(0, 0));
  249. }
  250. }
  251. break;
  252. default:
  253. break;
  254. }
  255. break;
  256. }
  257. case C_ACTION_TYPE.ACTION_TYPE_GOTO:
  258. if (PDFViewer != null)
  259. {
  260. CPDFGoToAction gotoAction = action as CPDFGoToAction;
  261. CPDFDestination dest = gotoAction.GetDestination(PDFViewer.GetDocument());
  262. if (dest != null)
  263. {
  264. Size pageSize = DataConversionForWPF.CSizeConversionForSize(PDFViewer.GetDocument().GetPageSize(dest.PageIndex));
  265. PDFViewer.GoToPage(dest.PageIndex, new Point(dest.Position_X, pageSize.Height - dest.Position_Y));
  266. }
  267. }
  268. break;
  269. case C_ACTION_TYPE.ACTION_TYPE_GOTOR:
  270. if (PDFViewer != null)
  271. {
  272. CPDFGoToRAction gotorAction = action as CPDFGoToRAction;
  273. CPDFDestination dest = gotorAction.GetDestination(PDFViewer.GetDocument());
  274. if (dest != null)
  275. {
  276. Size pageSize = DataConversionForWPF.CSizeConversionForSize(PDFViewer.GetDocument().GetPageSize(dest.PageIndex));
  277. PDFViewer.GoToPage(dest.PageIndex, new Point(dest.Position_X, pageSize.Height - dest.Position_Y));
  278. }
  279. }
  280. break;
  281. case C_ACTION_TYPE.ACTION_TYPE_URI:
  282. {
  283. CPDFUriAction uriAction = action as CPDFUriAction;
  284. string uri = uriAction.GetUri();
  285. try
  286. {
  287. if (!string.IsNullOrEmpty(uri))
  288. {
  289. Process.Start(uri);
  290. }
  291. }
  292. catch (Exception ex)
  293. {
  294. }
  295. }
  296. break;
  297. default:
  298. break;
  299. }
  300. }
  301. protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
  302. {
  303. if (isContinueCreateTextEdit)
  304. {
  305. if (lastSelectedRect != null)
  306. {
  307. CanAddTextEdit = false;
  308. }
  309. else
  310. {
  311. CanAddTextEdit = true;
  312. }
  313. }
  314. if (PDFViewer == null || PDFViewer.CurrentRenderFrame == null)
  315. {
  316. return;
  317. }
  318. if (!HitTestBorder())
  319. {
  320. RemovePopTextUI();
  321. }
  322. Focus();
  323. if (FillManager?.MouseDownHandle(e) == true)
  324. {
  325. return;
  326. }
  327. Mouse.Capture(this, CaptureMode.SubTree);
  328. MouseEventObject mouseEventObject = new MouseEventObject
  329. {
  330. mouseButtonEventArgs = e,
  331. hitTestType = MouseHitTestType.Unknown,
  332. annotType = C_ANNOTATION_TYPE.C_ANNOTATION_NONE,
  333. IsCreate = false
  334. };
  335. if (currentModel == ToolType.ViewerScroller)
  336. {
  337. // Scroller Tool Only Scrolle
  338. MouseLeftButtonDownHandler?.Invoke(this, mouseEventObject);
  339. return;
  340. }
  341. AnnotData beforeSelectAnnotData = GetSelectAnnotData();
  342. if (isDrawSelectRect)
  343. {
  344. if (e.ClickCount == 2)
  345. {
  346. // Refresh the currently selected annotation object to ensure it is the latest
  347. AnnotHitTest();
  348. if (cacheHitTestAnnot is FreeTextAnnot)
  349. {
  350. BuildPopTextUI(cacheHitTestAnnot);
  351. isDrawSelectRect = false;
  352. mouseEventObject.annotType = cacheHitTestAnnot.GetAnnotData().AnnotType;
  353. mouseEventObject.IsMersured = cacheHitTestAnnot.GetAnnotData().Annot.IsMeasured();
  354. MouseLeftButtonDownHandler?.Invoke(this, mouseEventObject);
  355. return;
  356. }
  357. if (cacheHitTestAnnot is StickyNoteAnnot)
  358. {
  359. (cacheHitTestAnnot as StickyNoteAnnot).PopStickyNote();
  360. }
  361. }
  362. // Click inside the selected rectangle area
  363. if (DrawSelectRectDownEvent() && cacheHitTestAnnot != null)
  364. {
  365. mouseEventObject.hitTestType = MouseHitTestType.SelectRect;
  366. mouseEventObject.annotType = cacheHitTestAnnot.GetAnnotData().AnnotType;
  367. mouseEventObject.IsMersured = cacheHitTestAnnot.GetAnnotData().Annot.IsMeasured();
  368. MouseLeftButtonDownHandler?.Invoke(this, mouseEventObject);
  369. return;
  370. }
  371. else
  372. {
  373. CleanSelectedRect();
  374. }
  375. }
  376. if (IsDrawEditAnnot)
  377. {
  378. // Click inside the selected rectangle area
  379. if (DrawEditAnnotDownEvent() && cacheHitTestAnnot != null)
  380. {
  381. mouseEventObject.hitTestType = MouseHitTestType.SelectRect;
  382. mouseEventObject.annotType = cacheHitTestAnnot.GetAnnotData().AnnotType;
  383. mouseEventObject.IsMersured = cacheHitTestAnnot.GetAnnotData().Annot.IsMeasured();
  384. MouseLeftButtonDownHandler?.Invoke(this, mouseEventObject);
  385. return;
  386. }
  387. }
  388. Point = e.GetPosition(this);
  389. // Annotation selection effect
  390. if ((currentModel == ToolType.Pan
  391. || currentModel == ToolType.CreateAnnot)
  392. && AnnotHitTest()
  393. && IsCanSave()
  394. && !PDFViewer.GetIsShowStampMouse()
  395. )
  396. {
  397. //if (!IsCacheRedaction)
  398. {
  399. if (cacheHitTestAnnot?.CurrentType == C_ANNOTATION_TYPE.C_ANNOTATION_LINK && currentModel != ToolType.CreateAnnot)
  400. {
  401. LinkAnnotAction(cacheHitTestAnnot);
  402. }
  403. else
  404. {
  405. List<C_ANNOTATION_TYPE> list = new List<C_ANNOTATION_TYPE>()
  406. {
  407. C_ANNOTATION_TYPE.C_ANNOTATION_LINE,
  408. C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE,
  409. C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON,
  410. };
  411. if (cacheHitTestAnnot != null && list.Contains(cacheHitTestAnnot.CurrentType))
  412. {
  413. mouseEventObject.IsMersured = cacheHitTestAnnot.GetAnnotData().Annot.IsMeasured();
  414. SetEditAnnotObject();
  415. }
  416. else
  417. {
  418. if (AllowMultiSelect &&
  419. (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
  420. {
  421. if (!AnnotSelectAreaHitTest())
  422. {
  423. if (AnnotMoveHitTest())
  424. {
  425. BaseAnnot hitAnnot = PDFViewer?.AnnotHitTest() as BaseAnnot;
  426. if (beforeSelectAnnotData != null)
  427. {
  428. AnnotSelectAddItem(beforeSelectAnnotData);
  429. }
  430. if (AnnotSelectGetCount() == 0 && hitAnnot != null)
  431. {
  432. AnnotSelectAddItem(hitAnnot.GetAnnotData());
  433. }
  434. mouseEventObject.hitTestType = MouseHitTestType.Annot;
  435. mouseEventObject.annotType = cacheHitTestAnnot.GetAnnotData().AnnotType;
  436. }
  437. else
  438. {
  439. AnnotSelectAreaHit();
  440. }
  441. }
  442. AnnotSelectMoveHit();
  443. }
  444. else
  445. {
  446. SelectedAnnot();
  447. }
  448. }
  449. isDrawSelectRect = true;
  450. }
  451. }
  452. mouseEventObject.hitTestType = MouseHitTestType.Annot;
  453. if (cacheHitTestAnnot != null)
  454. {
  455. mouseEventObject.annotType = cacheHitTestAnnot.GetAnnotData().AnnotType;
  456. }
  457. else
  458. {
  459. mouseEventObject.annotType = C_ANNOTATION_TYPE.C_ANNOTATION_NONE;
  460. }
  461. }
  462. // Form selected effect
  463. else if ((currentModel == ToolType.Pan || currentModel == ToolType.Viewer) && AnnotWidgetHitTest())
  464. {
  465. mouseEventObject.hitTestType = MouseHitTestType.Widget;
  466. mouseEventObject.annotType = cacheMoveWidget.GetAnnotData().AnnotType;
  467. FormClickProcess();
  468. }
  469. else if ((currentModel == ToolType.Pan || currentModel == ToolType.Viewer))
  470. {
  471. if (!IsText() && DrawDownSelectImage(true))
  472. {
  473. mouseEventObject.hitTestType = MouseHitTestType.ImageSelect;
  474. }
  475. else
  476. {
  477. if (!AnnotSelectAreaHitTest())
  478. {
  479. AnnotSelectAreaHit();
  480. }
  481. ReDrawSelectImage();
  482. }
  483. }
  484. // Form creation mode
  485. else if (currentModel == ToolType.WidgetEdit)
  486. {
  487. if (!AnnotSelectAreaHitTest())
  488. {
  489. if (AnnotWidgetHitTest())
  490. {
  491. BaseWidget hitWidget = PDFViewer?.AnnotHitTest() as BaseWidget;
  492. cacheHitTestAnnot = null;
  493. if (AnnotSelectGetCount() == 0 && hitWidget != null)
  494. {
  495. AnnotSelectAddItem(hitWidget.GetAnnotData());
  496. cacheHitTestAnnot = hitWidget;
  497. SelectedAnnot();
  498. }
  499. mouseEventObject.hitTestType = MouseHitTestType.Annot;
  500. mouseEventObject.annotType = cacheMoveWidget.GetAnnotData().AnnotType;
  501. }
  502. else
  503. {
  504. AnnotSelectAreaHit();
  505. }
  506. }
  507. AnnotSelectMoveHit();
  508. }
  509. // Content editing mode
  510. else if (currentModel == ToolType.ContentEdit)
  511. {
  512. OpenSelectedMulti(isMultiSelected);
  513. if (!PDFViewer.GetIsShowStampMouse())
  514. {
  515. DrawTextEditDownEvent(true);
  516. }
  517. if (lastSelectedRect != null)
  518. {
  519. //Multi selection processing optimization, other click effects
  520. DrawEndFrameSelect();
  521. if (!Keyboard.IsKeyDown(multiKey) || !isMultiSelected)
  522. {
  523. CleanSelectedMultiRect();
  524. OpenSelectedMulti(false);
  525. if (PDFViewer.CurrentRenderFrame != null)
  526. {
  527. currentZoom = PDFViewer.CurrentRenderFrame.ZoomFactor;
  528. if (PDFViewer.CurrentRenderFrame.IsCacheEditPage == true && currentModel == ToolType.ContentEdit)
  529. {
  530. SetEditTextRect(PDFViewer.CurrentRenderFrame);
  531. if (selectedEditPageIndex != -1 && selectedEditAreaIndex != -1)
  532. {
  533. DrawSelectedEditAreaForIndex();
  534. }
  535. }
  536. }
  537. ReDrawSelectedMultiRect();
  538. }
  539. if (lastSelectedRect == null)
  540. {
  541. return;
  542. }
  543. SelectedMultiRect(lastSelectedRect.GetRect(), lastSelectedRect.GetMaxRect(), SelectedType.PDFEdit);
  544. HideDrawSelectedMultiRect();
  545. lastSelectedRect.DataChanged -= SelectedRect_DataChanged;
  546. lastSelectedRect.DataChanged += SelectedRect_DataChanged;
  547. }
  548. else
  549. {
  550. if (Keyboard.IsKeyDown(multiKey) && isMultiSelected)
  551. {
  552. DelMultiSelectRect();
  553. }
  554. if (HitTestMultiSelectedRect())
  555. {
  556. mouseEventObject.hitTestType = MouseHitTestType.MultiTextEdit;
  557. }
  558. else
  559. {
  560. //Clear the currently selected object
  561. startSelectedRect = null;
  562. startSelectedIndex = -1;
  563. startSelectedPageIndex = -1;
  564. startSelectedEditAreaObject = null;
  565. CleanSelectedMultiRect();
  566. OpenSelectedMulti(false);
  567. if (PDFViewer.CurrentRenderFrame != null)
  568. {
  569. currentZoom = PDFViewer.CurrentRenderFrame.ZoomFactor;
  570. if (PDFViewer.CurrentRenderFrame.IsCacheEditPage == true && currentModel == ToolType.ContentEdit)
  571. {
  572. SetEditTextRect(PDFViewer.CurrentRenderFrame);
  573. if (selectedEditPageIndex != -1 && selectedEditAreaIndex != -1)
  574. {
  575. DrawSelectedEditAreaForIndex();
  576. }
  577. }
  578. }
  579. ReDrawSelectedMultiRect();
  580. }
  581. }
  582. }
  583. else if (currentModel == ToolType.SelectedPage)
  584. {
  585. if (HitTestPageSelectedRect())
  586. {
  587. }
  588. else
  589. {
  590. CleanPageSelectedRect();
  591. CreatePageSelectdRect();
  592. }
  593. mouseEventObject.hitTestType = MouseHitTestType.SelectedPageRect;
  594. }
  595. MouseLeftButtonDownHandler?.Invoke(this, mouseEventObject);
  596. }
  597. protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
  598. {
  599. if (PDFViewer == null || PDFViewer.CurrentRenderFrame == null)
  600. {
  601. return;
  602. }
  603. if (FillManager?.MouseUpHandle(e) == true)
  604. {
  605. return;
  606. }
  607. if (currentModel == ToolType.Pan || currentModel == ToolType.CreateAnnot)
  608. {
  609. bool areaSelectAdd = AnnotSelectAreaSelect(false, true);
  610. if (AnnotMoveHitTest())
  611. {
  612. BaseAnnot checkItem = PDFViewer?.AnnotHitTest();
  613. AnnotSelectAddItem(checkItem?.GetAnnotData(), !AnnotSelectAreaHitTest());
  614. }
  615. if (AnnotSelectGetCount() > 0)
  616. {
  617. CleanSelectedRect();
  618. }
  619. if (IsMoved == false && AnnotSelectAreaHitTest() == false && AnnotMoveHitTest() == false)
  620. {
  621. AnnotSelectClean();
  622. }
  623. if (AnnotSelectGetCount() == 1)
  624. {
  625. cacheHitTestAnnot = AnnotSelectGetAnnot();
  626. if (cacheHitTestAnnot != null)
  627. {
  628. BaseLayer baseLayer = PDFViewer.GetViewForTag(selectedRectViewTag);
  629. SelectedRect selectedRect = CommonHelper.FindVisualChild<SelectedRect>(baseLayer as CustomizeLayer);
  630. if (selectedRect != null)
  631. {
  632. if (IsMoved && areaSelectAdd == false)
  633. {
  634. selectedRect.UpdateAnnotData(cacheHitTestAnnot.GetAnnotData());
  635. }
  636. else
  637. {
  638. selectedRect.SetAnnotData(cacheHitTestAnnot.GetAnnotData());
  639. }
  640. selectedRect.Draw();
  641. }
  642. isDrawSelectRect = true;
  643. }
  644. }
  645. }
  646. if (currentModel == ToolType.WidgetEdit)
  647. {
  648. bool areaSelectAdd = AnnotSelectAreaSelect(true);
  649. if (AnnotWidgetHitTest())
  650. {
  651. BaseWidget checkItem = PDFViewer?.AnnotHitTest() as BaseWidget;
  652. AnnotSelectAddItem(checkItem?.GetAnnotData(), !AnnotSelectAreaHitTest());
  653. }
  654. if (AnnotSelectGetCount() > 1)
  655. {
  656. CleanSelectedRect();
  657. }
  658. if (IsMoved == false && AnnotSelectAreaHitTest() == false && AnnotWidgetHitTest() == false)
  659. {
  660. AnnotSelectClean();
  661. }
  662. if (AnnotSelectGetCount() == 1)
  663. {
  664. cacheHitTestAnnot = AnnotSelectGetAnnot();
  665. if (cacheHitTestAnnot != null)
  666. {
  667. BaseLayer baseLayer = PDFViewer.GetViewForTag(selectedRectViewTag);
  668. SelectedRect selectedRect = CommonHelper.FindVisualChild<SelectedRect>(baseLayer as CustomizeLayer);
  669. if (selectedRect != null)
  670. {
  671. if (IsMoved && areaSelectAdd == false)
  672. {
  673. selectedRect.UpdateAnnotData(cacheHitTestAnnot.GetAnnotData());
  674. }
  675. else
  676. {
  677. selectedRect.SetAnnotData(cacheHitTestAnnot.GetAnnotData());
  678. }
  679. selectedRect.Draw();
  680. }
  681. isDrawSelectRect = true;
  682. }
  683. }
  684. }
  685. MouseEventObject mouseEventObject = new MouseEventObject
  686. {
  687. mouseButtonEventArgs = e,
  688. hitTestType = MouseHitTestType.Unknown,
  689. annotType = C_ANNOTATION_TYPE.C_ANNOTATION_NONE,
  690. IsCreate = false
  691. };
  692. if (isDrawSelectRect || IsDrawEditAnnot)
  693. {
  694. mouseEventObject.hitTestType = MouseHitTestType.SelectRect;
  695. if (cacheHitTestAnnot != null)
  696. {
  697. mouseEventObject.annotType = cacheHitTestAnnot.GetAnnotData().AnnotType;
  698. }
  699. else
  700. {
  701. mouseEventObject.annotType = C_ANNOTATION_TYPE.C_ANNOTATION_NONE;
  702. }
  703. }
  704. MouseLeftButtonUpHandler?.Invoke(this, mouseEventObject);
  705. ReleaseMouseCapture();
  706. if (currentModel == ToolType.WidgetEdit || currentModel == ToolType.Pan || currentModel == ToolType.CreateAnnot)
  707. {
  708. AnnotSelectUpdate();
  709. AnnotSelectDraw();
  710. AnnotSelectSave();
  711. AreaMoveData = new AnnotSelectAreaData();
  712. }
  713. IsMoved = false;
  714. }
  715. protected override void OnMouseMove(MouseEventArgs e)
  716. {
  717. IsMoved = e.LeftButton == MouseButtonState.Pressed;
  718. if (PDFViewer == null || PDFViewer.CurrentRenderFrame == null)
  719. {
  720. return;
  721. }
  722. if (FillManager?.MouseMoveHandle(e) == true)
  723. {
  724. return;
  725. }
  726. Cursor oldCursor = this.Cursor;
  727. Cursor newCursor = this.Cursor;
  728. MouseEventObject mouseEventObject = new MouseEventObject
  729. {
  730. mouseButtonEventArgs = e,
  731. hitTestType = MouseHitTestType.Unknown,
  732. annotType = C_ANNOTATION_TYPE.C_ANNOTATION_NONE,
  733. IsCreate = false
  734. };
  735. if (currentModel == ToolType.ViewerScroller)
  736. {
  737. // Scroller Tool Only Scrolle
  738. MouseLeftButtonDownHandler?.Invoke(this, mouseEventObject);
  739. return;
  740. }
  741. if (Mouse.LeftButton != MouseButtonState.Pressed)
  742. {
  743. List<ToolType> allowModeList = new List<ToolType>()
  744. {
  745. ToolType.Pan,
  746. ToolType.Viewer
  747. };
  748. if (allowModeList.Contains(currentModel))
  749. {
  750. newCursor = Cursors.Arrow;
  751. if (caheMoveAnnot is BaseWidget)
  752. {
  753. BaseWidget widget = (BaseWidget)caheMoveAnnot;
  754. if (widget.GetFormType() == PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_PUSHBUTTON && PDFViewer != null)
  755. {
  756. newCursor = Cursors.Hand;
  757. }
  758. }
  759. if (caheMoveAnnot is LinkAnnot)
  760. {
  761. newCursor = Cursors.Hand;
  762. }
  763. }
  764. }
  765. if (!isDrawSelectRect && !IsDrawEditAnnot)
  766. {
  767. if (AnnotMoveHitTest())
  768. {
  769. if (isCacheRedaction)
  770. {
  771. (caheMoveAnnot as RedactionAnnot).SetIsMouseHover(true);
  772. (caheMoveAnnot as RedactionAnnot).Draw();
  773. }
  774. mouseEventObject.annotType = caheMoveAnnot.GetAnnotData().AnnotType;
  775. mouseEventObject.IsMersured = caheMoveAnnot.GetAnnotData().Annot.IsMeasured();
  776. }
  777. else
  778. {
  779. if (isCacheRedaction)
  780. {
  781. isCacheRedaction = false;
  782. (caheMoveAnnot as RedactionAnnot).SetIsMouseHover(false);
  783. (caheMoveAnnot as RedactionAnnot).Draw();
  784. }
  785. caheMoveAnnot = null;
  786. if ((currentModel == ToolType.Pan || currentModel == ToolType.Viewer))
  787. {
  788. if (GetTextSelectInfo() == null)
  789. {
  790. DrawMoveSelectImage();
  791. }
  792. }
  793. }
  794. }
  795. else
  796. {
  797. if (AnnotMoveHitTest())
  798. {
  799. if (DrawSelectRectDownEvent() == false && Mouse.LeftButton != MouseButtonState.Pressed)
  800. {
  801. mouseEventObject.annotType = caheMoveAnnot.GetAnnotData().AnnotType;
  802. }
  803. if (isCacheRedaction)
  804. {
  805. (caheMoveAnnot as RedactionAnnot)?.SetIsMouseHover(true);
  806. (caheMoveAnnot as RedactionAnnot)?.Draw();
  807. }
  808. }
  809. else
  810. {
  811. if (isCacheRedaction)
  812. {
  813. (caheMoveAnnot as RedactionAnnot)?.SetIsMouseHover(false);
  814. (caheMoveAnnot as RedactionAnnot)?.Draw();
  815. }
  816. }
  817. if (mouseEventObject.annotType == C_ANNOTATION_TYPE.C_ANNOTATION_NONE)
  818. {
  819. mouseEventObject.hitTestType = MouseHitTestType.SelectRect;
  820. if (cacheHitTestAnnot != null)
  821. {
  822. mouseEventObject.annotType = cacheHitTestAnnot.GetAnnotData().AnnotType;
  823. mouseEventObject.IsMersured = cacheHitTestAnnot.GetAnnotData().Annot.IsMeasured();
  824. }
  825. else
  826. {
  827. mouseEventObject.annotType = C_ANNOTATION_TYPE.C_ANNOTATION_NONE;
  828. }
  829. }
  830. }
  831. if (currentModel == ToolType.WidgetEdit)
  832. {
  833. AnnotSelectAreaDraw();
  834. if (!AnnotSelectMoveDraw())
  835. {
  836. AnnotSelectAreaHover();
  837. }
  838. }
  839. if (currentModel == ToolType.Pan && !IsText() && IsSelectText())
  840. {
  841. AnnotSelectAreaDraw();
  842. if (!AnnotSelectMoveDraw())
  843. {
  844. AnnotSelectAreaHover();
  845. }
  846. }
  847. MouseMoveHandler?.Invoke(this, mouseEventObject);
  848. PDFViewer.SetCustomMousePoint(Mouse.GetPosition(this).Y, Mouse.GetPosition(this).X);
  849. if (oldCursor != newCursor)
  850. {
  851. this.Cursor = newCursor;
  852. }
  853. }
  854. protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
  855. {
  856. MouseEventObject mouseEventObject = new MouseEventObject
  857. {
  858. mouseButtonEventArgs = e,
  859. hitTestType = MouseHitTestType.Unknown,
  860. annotType = C_ANNOTATION_TYPE.C_ANNOTATION_NONE,
  861. IsCreate = false
  862. };
  863. if (currentModel == ToolType.Pan || currentModel == ToolType.Viewer)
  864. {
  865. if (GetMousePointToTextSelectInfo())
  866. {
  867. mouseEventObject.hitTestType = MouseHitTestType.Text;
  868. }
  869. }
  870. if (isDrawSelectRect)
  871. {
  872. // Click inside the selected rectangle area
  873. if (DrawSelectRectDownEvent() && cacheHitTestAnnot != null)
  874. {
  875. mouseEventObject.hitTestType = MouseHitTestType.SelectRect;
  876. mouseEventObject.annotType = cacheHitTestAnnot.GetAnnotData().AnnotType;
  877. MouseRightButtonDownHandler?.Invoke(this, mouseEventObject);
  878. return;
  879. }
  880. }
  881. if (IsDrawEditAnnot)
  882. {
  883. // Click inside the selected rectangle area
  884. if (DrawEditAnnotDownEvent() && cacheHitTestAnnot != null)
  885. {
  886. mouseEventObject.hitTestType = MouseHitTestType.SelectRect;
  887. mouseEventObject.annotType = cacheHitTestAnnot.GetAnnotData().AnnotType;
  888. MouseRightButtonDownHandler?.Invoke(this, mouseEventObject);
  889. return;
  890. }
  891. }
  892. Point = e.GetPosition(this);
  893. // Annotation selection effect
  894. if ((currentModel == ToolType.Pan || currentModel == ToolType.CreateAnnot))
  895. {
  896. if (AnnotHitTest())
  897. {
  898. if (!isCacheRedaction)
  899. {
  900. if (cacheHitTestAnnot?.CurrentType == C_ANNOTATION_TYPE.C_ANNOTATION_LINK && currentModel != ToolType.CreateAnnot)
  901. {
  902. LinkAnnotAction(cacheHitTestAnnot);
  903. }
  904. else
  905. {
  906. List<C_ANNOTATION_TYPE> list = new List<C_ANNOTATION_TYPE>()
  907. {
  908. C_ANNOTATION_TYPE.C_ANNOTATION_LINE,
  909. C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE,
  910. C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON,
  911. };
  912. if (cacheHitTestAnnot != null && list.Contains(cacheHitTestAnnot.CurrentType))
  913. {
  914. SetEditAnnotObject();
  915. DrawEditAnnotLayer();
  916. }
  917. else
  918. {
  919. SelectedAnnot();
  920. DrawSelectedLayer();
  921. }
  922. isDrawSelectRect = true;
  923. }
  924. }
  925. mouseEventObject.hitTestType = MouseHitTestType.Annot;
  926. if (cacheHitTestAnnot != null)
  927. {
  928. mouseEventObject.annotType = cacheHitTestAnnot.GetAnnotData().AnnotType;
  929. }
  930. else
  931. {
  932. mouseEventObject.annotType = C_ANNOTATION_TYPE.C_ANNOTATION_NONE;
  933. }
  934. }
  935. else
  936. {
  937. CleanSelectedRect();
  938. }
  939. }
  940. // Form selection effect
  941. if ((currentModel == ToolType.Pan || currentModel == ToolType.Viewer) && AnnotWidgetHitTest())
  942. {
  943. mouseEventObject.hitTestType = MouseHitTestType.Widget;
  944. mouseEventObject.annotType = cacheMoveWidget.GetAnnotData().AnnotType;
  945. FormClickProcess();
  946. }
  947. // Form creation mode
  948. if (currentModel == ToolType.WidgetEdit)
  949. {
  950. if (!AnnotSelectAreaHitTest())
  951. {
  952. if (AnnotWidgetHitTest())
  953. {
  954. cacheHitTestAnnot = PDFViewer?.AnnotHitTest() as BaseWidget;
  955. SelectedAnnot();
  956. DrawSelectedLayer();
  957. mouseEventObject.hitTestType = MouseHitTestType.Annot;
  958. mouseEventObject.annotType = cacheMoveWidget.GetAnnotData().AnnotType;
  959. AnnotSelectClean();
  960. AnnotSelectAddItem(cacheHitTestAnnot?.GetAnnotData());
  961. }
  962. else
  963. {
  964. CleanSelectedRect();
  965. }
  966. }
  967. else
  968. {
  969. mouseEventObject.hitTestType = MouseHitTestType.MultiSelector;
  970. }
  971. }
  972. // Content editing mode
  973. if (currentModel == ToolType.ContentEdit)
  974. {
  975. if (e.ClickCount == 1)
  976. {
  977. DrawTextEditDownEvent(false);
  978. if (GetLastSelectedRect() != null)
  979. {
  980. EditAreaObject editAreaObject = GetEditAreaObjectForRect(lastSelectedRect);
  981. switch (editAreaObject.cPDFEditArea.Type)
  982. {
  983. case CPDFEditType.EditText:
  984. mouseEventObject.hitTestType = MouseHitTestType.TextEdit;
  985. break;
  986. case CPDFEditType.EditImage:
  987. mouseEventObject.hitTestType = MouseHitTestType.ImageEdit;
  988. break;
  989. default:
  990. break;
  991. }
  992. }
  993. }
  994. }
  995. else
  996. {
  997. if ((currentModel == ToolType.Viewer || currentModel == ToolType.Pan) && mouseEventObject.hitTestType == MouseHitTestType.Unknown && DrawDownSelectImage(false))
  998. {
  999. mouseEventObject.hitTestType = MouseHitTestType.ImageSelect;
  1000. }
  1001. }
  1002. if (currentModel == ToolType.SelectedPage)
  1003. {
  1004. if (HitTestPageSelectedRect())
  1005. {
  1006. mouseEventObject.hitTestType = MouseHitTestType.SelectedPageRect;
  1007. }
  1008. }
  1009. MouseRightButtonDownHandler?.Invoke(this, mouseEventObject);
  1010. }
  1011. public bool GetIsCropMode()
  1012. {
  1013. if (lastSelectedRect != null)
  1014. {
  1015. return lastSelectedRect.GetCurrentDrawPointType() == DrawPointType.Crop;
  1016. }
  1017. return false;
  1018. }
  1019. public void SetCropMode(bool crop)
  1020. {
  1021. if (lastSelectedRect != null)
  1022. {
  1023. List<PointControlType> ignoreList = new List<PointControlType>();
  1024. if (crop)
  1025. {
  1026. lastSelectedRect.SetCurrentDrawPointType(DrawPointType.Crop);
  1027. ignoreList.Add(PointControlType.Body);
  1028. // Initialize ClipRect
  1029. ClipThickness = new Thickness(0, 0, 0, 0);
  1030. if (editArea.TryGetValue(lastSelectedRect, out EditAreaObject editAreaObject))
  1031. {
  1032. cropIndex = editAreaObject.EditAreaIndex;
  1033. }
  1034. lastSelectedRect.DataChanged -= LastSelectedRect_DataChanged;
  1035. }
  1036. else
  1037. {
  1038. lastSelectedRect.SetCurrentDrawPointType(DrawPointType.Square);
  1039. cropIndex = -1;
  1040. lastSelectedRect.DataChanged += LastSelectedRect_DataChanged;
  1041. }
  1042. lastSelectedRect.SetIgnorePoints(ignoreList);
  1043. lastSelectedRect.Draw();
  1044. }
  1045. }
  1046. internal void SetToolType(ToolType model)
  1047. {
  1048. currentModel = model;
  1049. CPDFViewer pdfViewer = GetCPDFViewer();
  1050. if (pdfViewer != null)
  1051. {
  1052. if (currentModel == ToolType.WidgetEdit)
  1053. {
  1054. pdfViewer.IsHideFormShow = true;
  1055. }
  1056. else
  1057. {
  1058. pdfViewer.IsHideFormShow = false;
  1059. }
  1060. }
  1061. }
  1062. public ToolType GetToolType()
  1063. {
  1064. return currentModel;
  1065. }
  1066. public void SavePoint()
  1067. {
  1068. CachePoint = Point;
  1069. }
  1070. public void CleanPoint()
  1071. {
  1072. CachePoint = new Point();
  1073. }
  1074. private void CPDFViewerTool_Loaded(object sender, RoutedEventArgs e)
  1075. {
  1076. PDFViewer.DrawChanged += PDFViewer_DrawChanged;
  1077. PDFViewer.UndoManager.HistoryChanged += UndoManager_HistoryChanged;
  1078. PDFViewer.MouseEnter += PDFViewer_MouseEnter;
  1079. PDFViewer.MouseLeave += PDFViewer_MouseLeave;
  1080. }
  1081. private void PDFViewer_MouseLeave(object sender, MouseEventArgs e)
  1082. {
  1083. PDFViewer.IsVisibilityMouse(false);
  1084. }
  1085. private void PDFViewer_MouseEnter(object sender, MouseEventArgs e)
  1086. {
  1087. PDFViewer.IsVisibilityMouse(true);
  1088. }
  1089. private void UndoManager_HistoryChanged(object sender, KeyValuePair<UndoAction, IHistory> data)
  1090. {
  1091. IsDocumentModified = true;
  1092. }
  1093. private void CPDFViewerTool_Unloaded(object sender, RoutedEventArgs e)
  1094. {
  1095. PDFViewer.DrawChanged -= PDFViewer_DrawChanged;
  1096. }
  1097. private void PDFViewer_DrawChanged(object sender, EventArgs e)
  1098. {
  1099. SizeChangeds();
  1100. AnnotSelectUpdate();
  1101. AnnotSelectDraw();
  1102. DrawChanged?.Invoke(this, e);
  1103. }
  1104. public void SizeChangeds()
  1105. {
  1106. if (IsLoaded)
  1107. {
  1108. if (cacheHitTestAnnot != null)
  1109. {
  1110. BaseLayer baseLayer1 = PDFViewer.GetViewForTag(PDFViewer.GetAnnotViewTag());
  1111. bool Update = (baseLayer1 as AnnotLayer).GetUpdate(ref cacheHitTestAnnot);
  1112. if (Update)
  1113. {
  1114. if (IsDrawEditAnnot)
  1115. {
  1116. SetEditAnnotObject();
  1117. DrawEditAnnotLayer();
  1118. }
  1119. if (isDrawSelectRect)
  1120. {
  1121. List<C_ANNOTATION_TYPE> list = new List<C_ANNOTATION_TYPE>()
  1122. {
  1123. C_ANNOTATION_TYPE.C_ANNOTATION_LINE,
  1124. C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE,
  1125. C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON,
  1126. };
  1127. if (cacheHitTestAnnot != null && list.Contains(cacheHitTestAnnot.CurrentType))
  1128. {
  1129. SetEditAnnotObject();
  1130. DrawEditAnnotLayer();
  1131. }
  1132. else
  1133. {
  1134. SelectedAnnot();
  1135. }
  1136. DrawSelectedLayer();
  1137. }
  1138. }
  1139. else
  1140. {
  1141. SelectedAnnot(null);
  1142. }
  1143. }
  1144. else if (selectedPageIndex != -1 && selectedAnnotIndex != -1)
  1145. {
  1146. BaseLayer baseLayer1 = PDFViewer.GetViewForTag(PDFViewer.GetAnnotViewTag());
  1147. cacheHitTestAnnot = (baseLayer1 as AnnotLayer).GetSelectedAnnot(ref selectedPageIndex, ref selectedAnnotIndex);
  1148. if (cacheHitTestAnnot != null)
  1149. {
  1150. List<C_ANNOTATION_TYPE> list = new List<C_ANNOTATION_TYPE>()
  1151. {
  1152. C_ANNOTATION_TYPE.C_ANNOTATION_LINE,
  1153. C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE,
  1154. C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON,
  1155. };
  1156. if (cacheHitTestAnnot != null && list.Contains(cacheHitTestAnnot.CurrentType))
  1157. {
  1158. SetEditAnnotObject();
  1159. DrawEditAnnotLayer();
  1160. }
  1161. else
  1162. {
  1163. SelectedAnnot();
  1164. }
  1165. DrawSelectedLayer();
  1166. isDrawSelectRect = true;
  1167. }
  1168. }
  1169. if (PDFViewer.CurrentRenderFrame != null)
  1170. {
  1171. currentZoom = PDFViewer.CurrentRenderFrame.ZoomFactor;
  1172. if (PDFViewer.CurrentRenderFrame.IsCacheEditPage == true && currentModel == ToolType.ContentEdit)
  1173. {
  1174. SetEditTextRect(PDFViewer.CurrentRenderFrame);
  1175. if (selectedEditPageIndex != -1 && selectedEditAreaIndex != -1)
  1176. {
  1177. DrawSelectedEditAreaForIndex();
  1178. }
  1179. }
  1180. }
  1181. ReDrawSelectedMultiRect();
  1182. ReDrawWidget();
  1183. ReDrawSelectText();
  1184. ReDrawSelectImage();
  1185. UpdateFormHitPop();
  1186. UpdateTextPop();
  1187. }
  1188. }
  1189. private void ScrollViewer_MouseUp(object sender, MouseButtonEventArgs e)
  1190. {
  1191. }
  1192. private void ScrollViewer_MouseDown(object sender, MouseButtonEventArgs e)
  1193. {
  1194. }
  1195. private void ScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e)
  1196. {
  1197. ScrollChangedHandler?.Invoke(this, e);
  1198. }
  1199. }
  1200. }