AnnotationControl.xaml.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. using System.Windows.Controls;
  2. using Compdfkit_Tools.Data;
  3. using ComPDFKitViewer;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Diagnostics;
  8. using System.Drawing;
  9. using System.IO;
  10. using System.Runtime.CompilerServices;
  11. using System.Windows;
  12. using System.Windows.Controls.Primitives;
  13. using System.Windows.Input;
  14. using System.Windows.Media.Imaging;
  15. using Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI;
  16. using Compdfkit_Tools.Helper;
  17. using ComPDFKit.DigitalSign;
  18. using ComPDFKit.PDFAnnotation.Form;
  19. using ComPDFKit.PDFAnnotation;
  20. using ComPDFKit.Tool;
  21. using PasswordBoxPlus.Helper;
  22. using ComPDFKit.NativeMethod;
  23. using ComPDFKit.PDFPage;
  24. namespace Compdfkit_Tools.PDFControl
  25. {
  26. public partial class AnnotationControl : UserControl, INotifyPropertyChanged
  27. {
  28. #region Property
  29. private bool isFirstLoad = true;
  30. public PDFViewControl PDFViewControl;
  31. public CPDFAnnotationControl PDFAnnotationControl = null;
  32. private CPDFDisplaySettingsControl displaySettingsControl = null;
  33. private PanelState panelState = PanelState.GetInstance();
  34. private double[] zoomLevelList = { 1f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
  35. public event PropertyChangedEventHandler PropertyChanged;
  36. public ICommand CloseTabCommand;
  37. public ICommand ExpandPropertyPanelCommand;
  38. public bool CanUndo
  39. {
  40. get
  41. {
  42. if (PDFViewControl != null && PDFViewControl.PDFViewTool.GetCPDFViewer() != null)
  43. {
  44. return PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.CanUndo;
  45. }
  46. return false;
  47. }
  48. }
  49. public bool CanRedo
  50. {
  51. get
  52. {
  53. if (PDFViewControl != null && PDFViewControl.PDFViewTool.GetCPDFViewer() != null)
  54. {
  55. return PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.CanRedo;
  56. }
  57. return false;
  58. }
  59. }
  60. private bool CanSave
  61. {
  62. get
  63. {
  64. if (PDFViewControl != null && PDFViewControl.PDFViewTool.GetCPDFViewer() != null)
  65. {
  66. if (PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.CanRedo ||
  67. PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.CanUndo)
  68. {
  69. return true;
  70. }
  71. }
  72. return false;
  73. }
  74. }
  75. public event EventHandler<bool> OnCanSaveChanged;
  76. public event EventHandler OnAnnotEditHandler;
  77. #endregion
  78. public AnnotationControl()
  79. {
  80. InitializeComponent();
  81. DataContext = this;
  82. PDFAnnotationControl = new CPDFAnnotationControl();
  83. CPDFAnnotationType[] annotationProperties =
  84. {
  85. CPDFAnnotationType.Highlight, CPDFAnnotationType.Underline, CPDFAnnotationType.Strikeout,
  86. CPDFAnnotationType.Squiggly, CPDFAnnotationType.Freehand, CPDFAnnotationType.FreeText,
  87. CPDFAnnotationType.Note, CPDFAnnotationType.Circle, CPDFAnnotationType.Square,
  88. CPDFAnnotationType.Arrow, CPDFAnnotationType.Line, CPDFAnnotationType.Image,
  89. CPDFAnnotationType.Stamp, CPDFAnnotationType.Signature, CPDFAnnotationType.Link,
  90. CPDFAnnotationType.Audio
  91. };
  92. AnnotationBarControl.InitAnnotationBar(annotationProperties);
  93. panelState.PropertyChanged -= PanelState_PropertyChanged;
  94. panelState.PropertyChanged += PanelState_PropertyChanged;
  95. UndoBtn.ToolTip = LanguageHelper.CommonManager.GetString("Tooltip_Undo");
  96. RedoBtn.ToolTip = LanguageHelper.CommonManager.GetString("Tooltip_Redo");
  97. }
  98. #region Init PDFViewer
  99. public void InitWithPDFViewer(PDFViewControl pdfViewer)
  100. {
  101. PDFViewControl = pdfViewer;
  102. PDFGrid.Child = PDFViewControl;
  103. FloatPageTool.InitWithPDFViewer(PDFViewControl);
  104. InitialPDFViewControl(PDFViewControl);
  105. }
  106. #endregion
  107. #region Public Method
  108. public void ClearViewerControl()
  109. {
  110. PDFGrid.Child = null;
  111. BotaContainer.Child = null;
  112. PropertyContainer.Child = null;
  113. displaySettingsControl = null;
  114. PDFViewControl?.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_NONE);
  115. }
  116. public void SetBOTAContainer(CPDFBOTABarControl botaControl)
  117. {
  118. this.BotaContainer.Child = botaControl;
  119. }
  120. public void SetDisplaySettingsControl(CPDFDisplaySettingsControl displaySettingsControl)
  121. {
  122. this.displaySettingsControl = displaySettingsControl;
  123. }
  124. public void ClearAllToolState()
  125. {
  126. this.AnnotationBarControl.ClearAllToolState();
  127. }
  128. public void SetToolBarContainerVisibility(Visibility visibility)
  129. {
  130. this.ToolBarContainer.Visibility = visibility;
  131. }
  132. #endregion
  133. #region Load Unload custom control
  134. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  135. {
  136. PDFViewControl.MouseRightButtonDownHandler -= PDFViewControl_MouseRightButtonDownHandler;
  137. PDFViewControl.MouseRightButtonDownHandler += PDFViewControl_MouseRightButtonDownHandler;
  138. InitialPDFViewControl(PDFViewControl);
  139. }
  140. private void UserControl_Unloaded(object sender, RoutedEventArgs e)
  141. {
  142. PDFViewControl.MouseRightButtonDownHandler -= PDFViewControl_MouseRightButtonDownHandler;
  143. }
  144. private void AnnotationBarControl_Loaded(object sender, RoutedEventArgs e)
  145. {
  146. AnnotationBarControl.AnnotationPropertyChanged -= AnnotationBarControl_AnnotationPropertyChanged;
  147. AnnotationBarControl.AnnotationCancel -= AnnotationBarControl_AnnotationCancel;
  148. AnnotationBarControl.AnnotationPropertyChanged += AnnotationBarControl_AnnotationPropertyChanged;
  149. AnnotationBarControl.AnnotationCancel += AnnotationBarControl_AnnotationCancel;
  150. }
  151. private void AnnotationBarControl_Unloaded(object sender, RoutedEventArgs e)
  152. {
  153. AnnotationBarControl.AnnotationPropertyChanged -= AnnotationBarControl_AnnotationPropertyChanged;
  154. AnnotationBarControl.AnnotationCancel -= AnnotationBarControl_AnnotationCancel;
  155. }
  156. #endregion
  157. #region Annotation
  158. public void InitialPDFViewControl(PDFViewControl newPDFViewer)
  159. {
  160. PDFAnnotationControl.SetPDFViewer(newPDFViewer);
  161. PDFAnnotationControl.AnnotationCancel();
  162. AnnotationBarControl.ClearAllToolState();
  163. ExpandRightPropertyPanel(null, Visibility.Collapsed);
  164. PDFAnnotationControl.ClearAnnotationBar -= PdfAnnotationControl_ClearAnnotationBar;
  165. PDFAnnotationControl.ClearAnnotationBar += PdfAnnotationControl_ClearAnnotationBar;
  166. //PDFViewControl.PDFView.AnnotEditHandler -= PDFView_AnnotEditHandler;
  167. //PDFViewControl.PDFView.AnnotEditHandler += PDFView_AnnotEditHandler;
  168. PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.PropertyChanged -= UndoManager_PropertyChanged;
  169. PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.PropertyChanged += UndoManager_PropertyChanged;
  170. //PDFViewControl.PDFView.AnnotActiveHandler -= PDFView_AnnotActiveHandler;
  171. //PDFViewControl.PDFView.AnnotActiveHandler += PDFView_AnnotActiveHandler;
  172. //PDFViewControl.PDFView.AnnotCommandHandler += PDFView_AnnotCommandHandler;
  173. //PDFViewControl.PDFView.WidgetClickHandler += PDFView_WidgetClickHandler;
  174. }
  175. private void PDFViewControl_MouseRightButtonDownHandler(object sender, ComPDFKit.Tool.MouseEventObject e)
  176. {
  177. ContextMenu ContextMenu = PDFViewControl.GetRightMenu();
  178. if (ContextMenu == null)
  179. {
  180. ContextMenu = new ContextMenu();
  181. }
  182. switch (e.hitTestType)
  183. {
  184. case MouseHitTestType.Annot:
  185. case MouseHitTestType.SelectRect:
  186. CreateAnnotContextMenu(sender, ref ContextMenu, e.annotType);
  187. break;
  188. case MouseHitTestType.Text:
  189. CreateSelectTextContextMenu(sender, ref ContextMenu);
  190. break;
  191. case MouseHitTestType.ImageSelect:
  192. CreateSelectImageContextMenu(sender, ref ContextMenu);
  193. break;
  194. default:
  195. ContextMenu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
  196. PDFViewControl.CreateViewerMenu(sender, ref ContextMenu);
  197. break;
  198. }
  199. PDFViewControl.SetRightMenu(ContextMenu);
  200. }
  201. private void CreateSelectTextContextMenu(object sender, ref ContextMenu menu)
  202. {
  203. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
  204. }
  205. private void CreateAnnotContextMenu(object sender, ref ContextMenu menu, C_ANNOTATION_TYPE annotType)
  206. {
  207. switch (annotType)
  208. {
  209. case C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET:
  210. break;
  211. case C_ANNOTATION_TYPE.C_ANNOTATION_SOUND:
  212. case C_ANNOTATION_TYPE.C_ANNOTATION_MOVIE:
  213. case C_ANNOTATION_TYPE.C_ANNOTATION_RICHMEDIA:
  214. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Delete"), Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
  215. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Play"), Command = MediaCommands.Play, CommandTarget = (UIElement)sender, CommandParameter = (sender as CPDFViewerTool).GetCacheHitTestAnnot() });
  216. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Cut"), Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
  217. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
  218. break;
  219. default:
  220. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Delete"), Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
  221. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
  222. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Cut"), Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
  223. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
  224. break;
  225. }
  226. }
  227. private void CreateSelectImageContextMenu(object sender, ref ContextMenu menu)
  228. {
  229. if (menu == null)
  230. {
  231. menu = new ContextMenu();
  232. }
  233. MenuItem copyImage = new MenuItem();
  234. copyImage.Header = "Copy Image";
  235. copyImage.Click += CopyImage_Click;
  236. menu.Items.Add(copyImage);
  237. MenuItem extractImage = new MenuItem();
  238. extractImage.Header = "Extract Image";
  239. extractImage.Click += ExtractImage_Click;
  240. menu.Items.Add(extractImage);
  241. }
  242. private void ExtractImage_Click(object sender, RoutedEventArgs e)
  243. {
  244. System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog();
  245. if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  246. {
  247. var image = PDFViewControl.FocusPDFViewTool.GetSelectImage();
  248. if(image == null)
  249. {
  250. return;
  251. }
  252. CPDFPage page = PDFViewControl.PDFToolManager.GetDocument().PageAtIndex(image.PageIndex);
  253. string savePath = Path.Combine(folderDialog.SelectedPath, Guid.NewGuid() + ".jpg");
  254. string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".jpg");
  255. page.GetImgSelection().GetImgBitmap(image.ImageIndex, tempPath);
  256. Bitmap bitmap = new Bitmap(tempPath);
  257. bitmap.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
  258. Process.Start("explorer", "/select,\"" + savePath + "\"");
  259. }
  260. }
  261. private void CopyImage_Click(object sender, RoutedEventArgs e)
  262. {
  263. var image = PDFViewControl.FocusPDFViewTool.GetSelectImage();
  264. if(image == null)
  265. {
  266. return;
  267. }
  268. CPDFPage page = PDFViewControl.PDFToolManager.GetDocument().PageAtIndex(image.PageIndex);
  269. string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".jpg");
  270. page.GetImgSelection().GetImgBitmap(image.ImageIndex, tempPath);
  271. Bitmap bitmap = new Bitmap(tempPath);
  272. BitmapImage imageData;
  273. using (MemoryStream ms = new MemoryStream())
  274. {
  275. bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
  276. imageData = new BitmapImage();
  277. imageData.BeginInit();
  278. imageData.StreamSource = ms;
  279. imageData.CacheOption = BitmapCacheOption.OnLoad;
  280. imageData.EndInit();
  281. imageData.Freeze();
  282. Clipboard.SetImage(imageData);
  283. bitmap.Dispose();
  284. File.Delete(tempPath);
  285. }
  286. }
  287. public void UnloadEvent()
  288. {
  289. //PDFViewControl.PDFView.AnnotEditHandler -= PDFView_AnnotEditHandler;
  290. //PDFViewControl.PDFView.AnnotActiveHandler -= PDFView_AnnotActiveHandler;
  291. //panelState.PropertyChanged -= PanelState_PropertyChanged;
  292. }
  293. private void PdfAnnotationControl_ClearAnnotationBar(object sender, EventArgs e)
  294. {
  295. AnnotationBarControl.ClearAllToolState();
  296. }
  297. public void SetViewSettings(Visibility visibility, CPDFDisplaySettingsControl displaySettingsControl = null)
  298. {
  299. this.PropertyContainer.Child = displaySettingsControl;
  300. this.PropertyContainer.Visibility = visibility;
  301. }
  302. #endregion
  303. #region Expand and collapse Panel
  304. public void ExpandRightPropertyPanel(UIElement propertytPanel, Visibility visible)
  305. {
  306. PropertyContainer.Width = 260;
  307. PropertyContainer.Child = propertytPanel;
  308. PropertyContainer.Visibility = visible;
  309. }
  310. public void ExpandLeftPanel(bool isExpand)
  311. {
  312. BotaContainer.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
  313. Splitter.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
  314. if (isExpand)
  315. {
  316. BodyGrid.ColumnDefinitions[0].Width = new GridLength(320);
  317. BodyGrid.ColumnDefinitions[1].Width = new GridLength(15);
  318. }
  319. else
  320. {
  321. BodyGrid.ColumnDefinitions[0].Width = new GridLength(0);
  322. BodyGrid.ColumnDefinitions[1].Width = new GridLength(0);
  323. }
  324. }
  325. #endregion
  326. #region UI
  327. private double CheckZoomLevel(double zoom, bool IsGrowth)
  328. {
  329. double standardZoom = 100;
  330. if (zoom <= 0.01)
  331. {
  332. return 0.01;
  333. }
  334. if (zoom >= 10)
  335. {
  336. return 10;
  337. }
  338. zoom *= 100;
  339. for (int i = 0; i < zoomLevelList.Length - 1; i++)
  340. {
  341. if (zoom > zoomLevelList[i] && zoom <= zoomLevelList[i + 1] && IsGrowth)
  342. {
  343. standardZoom = zoomLevelList[i + 1];
  344. break;
  345. }
  346. if (zoom >= zoomLevelList[i] && zoom < zoomLevelList[i + 1] && !IsGrowth)
  347. {
  348. standardZoom = zoomLevelList[i];
  349. break;
  350. }
  351. }
  352. return standardZoom / 100;
  353. }
  354. private void ToolExpand_Click(object sender, RoutedEventArgs e)
  355. {
  356. ToggleButton expandBtn = sender as ToggleButton;
  357. if (expandBtn != null)
  358. {
  359. bool isExpand = expandBtn.IsChecked == true;
  360. ExpandLeftPanel(isExpand);
  361. }
  362. }
  363. private void EditLink_Click(object sender, RoutedEventArgs e)
  364. {
  365. PropertyContainer.Visibility = Visibility.Visible;
  366. }
  367. private void UndoButton_Click(object sender, RoutedEventArgs e)
  368. {
  369. if (PDFViewControl != null && PDFViewControl.PDFViewTool.GetCPDFViewer() != null)
  370. {
  371. PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager?.Undo();
  372. PDFViewControl.PDFToolManager.ClearSelect();
  373. PDFViewControl.PDFViewTool.GetCPDFViewer().UpdateAnnotFrame();
  374. }
  375. }
  376. private void RedoButton_Click(object sender, RoutedEventArgs e)
  377. {
  378. if (PDFViewControl != null && PDFViewControl.PDFViewTool.GetCPDFViewer() != null)
  379. {
  380. PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager?.Redo();
  381. PDFViewControl.PDFToolManager.ClearSelect();
  382. PDFViewControl.PDFViewTool.GetCPDFViewer().UpdateAnnotFrame();
  383. }
  384. }
  385. #endregion
  386. #region Property changed
  387. protected void OnPropertyChanged([CallerMemberName] string name = null)
  388. {
  389. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
  390. }
  391. private void UndoManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
  392. {
  393. OnPropertyChanged(e.PropertyName);
  394. if (e.PropertyName == "CanUndo" || e.PropertyName == "CanRedo")
  395. {
  396. OnCanSaveChanged?.Invoke(this, CanSave);
  397. }
  398. }
  399. private void PanelState_PropertyChanged(object sender, PropertyChangedEventArgs e)
  400. {
  401. if (e.PropertyName == nameof(PanelState.IsLeftPanelExpand))
  402. {
  403. ExpandLeftPanel(panelState.IsLeftPanelExpand);
  404. }
  405. else if (e.PropertyName == nameof(PanelState.RightPanel))
  406. {
  407. if (panelState.RightPanel == PanelState.RightPanelState.PropertyPanel)
  408. {
  409. ExpandRightPropertyPanel(PDFAnnotationControl, Visibility.Visible);
  410. }
  411. else if (panelState.RightPanel == PanelState.RightPanelState.ViewSettings)
  412. {
  413. ExpandRightPropertyPanel(displaySettingsControl, Visibility.Visible);
  414. }
  415. else
  416. {
  417. ExpandRightPropertyPanel(null, Visibility.Collapsed);
  418. }
  419. }
  420. }
  421. #endregion
  422. #region Event handle
  423. private void AnnotationBarControl_AnnotationCancel(object sender, EventArgs e)
  424. {
  425. PDFAnnotationControl.AnnotationCancel();
  426. if (panelState.RightPanel == PanelState.RightPanelState.PropertyPanel)
  427. {
  428. panelState.RightPanel = PanelState.RightPanelState.None;
  429. }
  430. }
  431. private void AnnotationBarControl_AnnotationPropertyChanged(object sender, CPDFAnnotationType e)
  432. {
  433. PDFAnnotationControl.LoadAnnotationPanel(e);
  434. if (e != CPDFAnnotationType.Audio && e != CPDFAnnotationType.Image)
  435. {
  436. panelState.RightPanel = PanelState.RightPanelState.PropertyPanel;
  437. }
  438. }
  439. //private void PDFView_AnnotActiveHandler(object sender, AnnotAttribEvent e)
  440. //{
  441. // PropertyContainer.Child = PDFAnnotationControl;
  442. // PDFAnnotationControl.SetAnnotEventData(e);
  443. //}
  444. //private void PDFView_WidgetClickHandler(object sender, WidgetArgs e)
  445. //{
  446. // if ((e is WidgetSignArgs args))
  447. // {
  448. // var signatureWidget = args.Sign;
  449. // if(signatureWidget != null)
  450. // {
  451. // CPDFSignature sig = signatureWidget.GetSignature(PDFViewControl.PDFView.Document);
  452. // if (signatureWidget.IsSigned() && sig!=null && sig?.SignerList.Count > 0)
  453. // {
  454. // return;
  455. // }
  456. // }
  457. // if (args.WidgetType == C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS)
  458. // {
  459. // panelState.RightPanel = PanelState.RightPanelState.PropertyPanel;
  460. // CPDFSignatureUI signatureProperty = new CPDFSignatureUI();
  461. // signatureProperty.SetFormProperty(args, PDFViewControl.PDFView);
  462. // PropertyContainer.Child = signatureProperty;
  463. // }
  464. // }
  465. //}
  466. //private void PDFView_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
  467. //{
  468. // OnAnnotEditHandler.Invoke(this, null);
  469. //}
  470. private void CommandBinding_Executed_Undo(object sender, ExecutedRoutedEventArgs e)
  471. {
  472. if (PDFViewControl != null && PDFViewControl.PDFViewTool.GetCPDFViewer() != null && CanUndo)
  473. {
  474. PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager?.Undo();
  475. }
  476. }
  477. private void CommandBinding_Executed_Redo(object sender, ExecutedRoutedEventArgs e)
  478. {
  479. if (PDFViewControl != null && PDFViewControl.PDFViewTool.GetCPDFViewer() != null && CanRedo)
  480. {
  481. PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager?.Redo();
  482. }
  483. }
  484. private void CommandBinding_Executed_Highlight(object sender, ExecutedRoutedEventArgs e)
  485. {
  486. AnnotationBarControl.SetAnnotationType(CPDFAnnotationType.Highlight);
  487. }
  488. private void CommandBinding_Executed_Underline(object sender, ExecutedRoutedEventArgs e)
  489. {
  490. AnnotationBarControl.SetAnnotationType(CPDFAnnotationType.Underline);
  491. }
  492. private void CommandBinding_Executed_Strikeout(object sender, ExecutedRoutedEventArgs e)
  493. {
  494. AnnotationBarControl.SetAnnotationType(CPDFAnnotationType.Strikeout);
  495. }
  496. private void CommandBinding_Executed_Squiggly(object sender, ExecutedRoutedEventArgs e)
  497. {
  498. AnnotationBarControl.SetAnnotationType(CPDFAnnotationType.Squiggly);
  499. }
  500. #endregion
  501. }
  502. }