AnnotationControl.xaml.cs 23 KB

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