AnnotationControl.xaml.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  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. UndoBtn.ToolTip = LanguageHelper.CommonManager.GetString("Tooltip_Undo");
  92. RedoBtn.ToolTip = LanguageHelper.CommonManager.GetString("Tooltip_Redo");
  93. }
  94. #region Init PDFViewer
  95. public void InitWithPDFViewer(PDFViewControl pdfViewer)
  96. {
  97. PDFViewControl = pdfViewer;
  98. PDFGrid.Child = PDFViewControl;
  99. FloatPageTool.InitWithPDFViewer(PDFViewControl);
  100. InitialPDFViewControl(PDFViewControl);
  101. }
  102. #endregion
  103. #region Public Method
  104. public void ClearViewerControl()
  105. {
  106. PDFGrid.Child = null;
  107. BotaContainer.Child = null;
  108. PropertyContainer.Child = null;
  109. displaySettingsControl = null;
  110. PDFViewControl?.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_NONE);
  111. }
  112. public void SetBOTAContainer(CPDFBOTABarControl botaControl)
  113. {
  114. this.BotaContainer.Child = botaControl;
  115. }
  116. public void SetDisplaySettingsControl(CPDFDisplaySettingsControl displaySettingsControl)
  117. {
  118. this.displaySettingsControl = displaySettingsControl;
  119. }
  120. public void SetPropertyContainer(UIElement uiElement)
  121. {
  122. PropertyContainer.Child = uiElement;
  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 PDFToolManager_MouseLeftButtonDownHandler(object sender, MouseEventObject e)
  141. {
  142. if (e.annotType == C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET)
  143. {
  144. BaseWidget baseWidget = PDFViewControl.GetCacheHitTestWidget();
  145. if (baseWidget != null)
  146. {
  147. AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam(
  148. PDFViewControl.PDFViewTool.GetCPDFViewer().GetDocument(),
  149. baseWidget.GetAnnotData().PageIndex,
  150. baseWidget.GetAnnotData().Annot);
  151. if ((annotParam as WidgetParm).WidgetType == C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS)
  152. {
  153. CPDFSignatureUI signatureProperty = new CPDFSignatureUI();
  154. signatureProperty.SetFormProperty(annotParam, PDFViewControl, baseWidget.GetAnnotData().Annot);
  155. PropertyContainer.Child = signatureProperty;
  156. }
  157. }
  158. }
  159. }
  160. private void UserControl_Unloaded(object sender, RoutedEventArgs e)
  161. {
  162. PDFViewControl.MouseRightButtonDownHandler -= PDFViewControl_MouseRightButtonDownHandler;
  163. }
  164. private void AnnotationBarControl_Loaded(object sender, RoutedEventArgs e)
  165. {
  166. AnnotationBarControl.AnnotationPropertyChanged -= AnnotationBarControl_AnnotationPropertyChanged;
  167. AnnotationBarControl.AnnotationCancel -= AnnotationBarControl_AnnotationCancel;
  168. AnnotationBarControl.AnnotationPropertyChanged += AnnotationBarControl_AnnotationPropertyChanged;
  169. AnnotationBarControl.AnnotationCancel += AnnotationBarControl_AnnotationCancel;
  170. }
  171. private void AnnotationBarControl_Unloaded(object sender, RoutedEventArgs e)
  172. {
  173. AnnotationBarControl.AnnotationPropertyChanged -= AnnotationBarControl_AnnotationPropertyChanged;
  174. AnnotationBarControl.AnnotationCancel -= AnnotationBarControl_AnnotationCancel;
  175. }
  176. #endregion
  177. #region Annotation
  178. public void InitialPDFViewControl(PDFViewControl newPDFViewer)
  179. {
  180. PDFAnnotationControl.SetPDFViewer(newPDFViewer);
  181. PDFAnnotationControl.AnnotationCancel();
  182. AnnotationBarControl.ClearAllToolState();
  183. ExpandRightPropertyPanel(null, Visibility.Collapsed);
  184. PDFAnnotationControl.ClearAnnotationBar -= PdfAnnotationControl_ClearAnnotationBar;
  185. PDFAnnotationControl.ClearAnnotationBar += PdfAnnotationControl_ClearAnnotationBar;
  186. panelState.PropertyChanged -= PanelState_PropertyChanged;
  187. panelState.PropertyChanged += PanelState_PropertyChanged;
  188. PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.PropertyChanged -= UndoManager_PropertyChanged;
  189. PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.PropertyChanged += UndoManager_PropertyChanged;
  190. PDFAnnotationControl.ClearAnnotationBar -= PdfAnnotationControl_ClearAnnotationBar;
  191. PDFViewControl.MouseLeftButtonUpHandler += PDFToolManager_MouseLeftButtonUpHandler;
  192. }
  193. private void PDFToolManager_MouseLeftButtonUpHandler(object sender, MouseEventObject e)
  194. {
  195. if (e.IsCreate)
  196. {
  197. OnAnnotEditHandler?.Invoke(this, EventArgs.Empty);
  198. }
  199. }
  200. private void PDFViewControl_MouseRightButtonDownHandler(object sender, ComPDFKit.Tool.MouseEventObject e)
  201. {
  202. ContextMenu ContextMenu = PDFViewControl.GetRightMenu();
  203. if (ContextMenu == null)
  204. {
  205. ContextMenu = new ContextMenu();
  206. }
  207. switch (e.hitTestType)
  208. {
  209. case MouseHitTestType.Annot:
  210. case MouseHitTestType.SelectRect:
  211. CreateAnnotContextMenu(sender, ref ContextMenu, e.annotType);
  212. break;
  213. case MouseHitTestType.Text:
  214. CreateSelectTextContextMenu(sender, ref ContextMenu);
  215. break;
  216. case MouseHitTestType.ImageSelect:
  217. CreateSelectImageContextMenu(sender, ref ContextMenu);
  218. break;
  219. default:
  220. ContextMenu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
  221. PDFViewControl.CreateViewerMenu(sender, ref ContextMenu);
  222. break;
  223. }
  224. PDFViewControl.SetRightMenu(ContextMenu);
  225. }
  226. private void CreateSelectTextContextMenu(object sender, ref ContextMenu menu)
  227. {
  228. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
  229. }
  230. private void CreateAnnotContextMenu(object sender, ref ContextMenu menu, C_ANNOTATION_TYPE annotType)
  231. {
  232. switch (annotType)
  233. {
  234. case C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET:
  235. break;
  236. case C_ANNOTATION_TYPE.C_ANNOTATION_SOUND:
  237. case C_ANNOTATION_TYPE.C_ANNOTATION_MOVIE:
  238. case C_ANNOTATION_TYPE.C_ANNOTATION_RICHMEDIA:
  239. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Delete"), Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
  240. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Play"), Command = MediaCommands.Play, CommandTarget = (UIElement)sender, CommandParameter = (sender as CPDFViewerTool).GetCacheHitTestAnnot() });
  241. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Cut"), Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
  242. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
  243. break;
  244. default:
  245. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Delete"), Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
  246. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
  247. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Cut"), Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
  248. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
  249. break;
  250. }
  251. }
  252. private void CreateSelectImageContextMenu(object sender, ref ContextMenu menu)
  253. {
  254. if (menu == null)
  255. {
  256. menu = new ContextMenu();
  257. }
  258. MenuItem copyImage = new MenuItem();
  259. copyImage.Header = "Copy Image";
  260. copyImage.Click += CopyImage_Click;
  261. menu.Items.Add(copyImage);
  262. MenuItem extractImage = new MenuItem();
  263. extractImage.Header = "Extract Image";
  264. extractImage.Click += ExtractImage_Click;
  265. menu.Items.Add(extractImage);
  266. }
  267. private void ExtractImage_Click(object sender, RoutedEventArgs e)
  268. {
  269. System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog();
  270. if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  271. {
  272. var image = PDFViewControl.FocusPDFViewTool.GetSelectImage();
  273. if (image == null)
  274. {
  275. return;
  276. }
  277. CPDFPage page = PDFViewControl.PDFToolManager.GetDocument().PageAtIndex(image.PageIndex);
  278. string savePath = Path.Combine(folderDialog.SelectedPath, Guid.NewGuid() + ".jpg");
  279. string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".jpg");
  280. page.GetImgSelection().GetImgBitmap(image.ImageIndex, tempPath);
  281. Bitmap bitmap = new Bitmap(tempPath);
  282. bitmap.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
  283. Process.Start("explorer", "/select,\"" + savePath + "\"");
  284. }
  285. }
  286. private void CopyImage_Click(object sender, RoutedEventArgs e)
  287. {
  288. var image = PDFViewControl.FocusPDFViewTool.GetSelectImage();
  289. if (image == null)
  290. {
  291. return;
  292. }
  293. CPDFPage page = PDFViewControl.PDFToolManager.GetDocument().PageAtIndex(image.PageIndex);
  294. string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".jpg");
  295. page.GetImgSelection().GetImgBitmap(image.ImageIndex, tempPath);
  296. Bitmap bitmap = new Bitmap(tempPath);
  297. BitmapImage imageData;
  298. using (MemoryStream ms = new MemoryStream())
  299. {
  300. bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
  301. imageData = new BitmapImage();
  302. imageData.BeginInit();
  303. imageData.StreamSource = ms;
  304. imageData.CacheOption = BitmapCacheOption.OnLoad;
  305. imageData.EndInit();
  306. imageData.Freeze();
  307. Clipboard.SetImage(imageData);
  308. bitmap.Dispose();
  309. File.Delete(tempPath);
  310. }
  311. }
  312. public void UnloadEvent()
  313. {
  314. panelState.PropertyChanged -= PanelState_PropertyChanged;
  315. PDFAnnotationControl.ClearAnnotationBar -= PdfAnnotationControl_ClearAnnotationBar;
  316. PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.PropertyChanged -= UndoManager_PropertyChanged;
  317. PDFViewControl.MouseRightButtonDownHandler -= PDFViewControl_MouseRightButtonDownHandler;
  318. PDFAnnotationControl.UnLoadPDFViewHandler();
  319. }
  320. private void PdfAnnotationControl_ClearAnnotationBar(object sender, EventArgs e)
  321. {
  322. AnnotationBarControl.ClearAllToolState();
  323. }
  324. public void SetViewSettings(Visibility visibility, CPDFDisplaySettingsControl displaySettingsControl = null)
  325. {
  326. this.PropertyContainer.Child = displaySettingsControl;
  327. this.PropertyContainer.Visibility = visibility;
  328. }
  329. #endregion
  330. #region Expand and collapse Panel
  331. public void ExpandRightPropertyPanel(UIElement propertytPanel, Visibility visible)
  332. {
  333. PropertyContainer.Width = 260;
  334. PropertyContainer.Child = propertytPanel;
  335. PropertyContainer.Visibility = visible;
  336. }
  337. public void ExpandLeftPanel(bool isExpand)
  338. {
  339. BotaContainer.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
  340. Splitter.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
  341. if (isExpand)
  342. {
  343. BodyGrid.ColumnDefinitions[0].Width = new GridLength(320);
  344. BodyGrid.ColumnDefinitions[1].Width = new GridLength(15);
  345. }
  346. else
  347. {
  348. BodyGrid.ColumnDefinitions[0].Width = new GridLength(0);
  349. BodyGrid.ColumnDefinitions[1].Width = new GridLength(0);
  350. }
  351. }
  352. #endregion
  353. #region UI
  354. private double CheckZoomLevel(double zoom, bool IsGrowth)
  355. {
  356. double standardZoom = 100;
  357. if (zoom <= 0.01)
  358. {
  359. return 0.01;
  360. }
  361. if (zoom >= 10)
  362. {
  363. return 10;
  364. }
  365. zoom *= 100;
  366. for (int i = 0; i < zoomLevelList.Length - 1; i++)
  367. {
  368. if (zoom > zoomLevelList[i] && zoom <= zoomLevelList[i + 1] && IsGrowth)
  369. {
  370. standardZoom = zoomLevelList[i + 1];
  371. break;
  372. }
  373. if (zoom >= zoomLevelList[i] && zoom < zoomLevelList[i + 1] && !IsGrowth)
  374. {
  375. standardZoom = zoomLevelList[i];
  376. break;
  377. }
  378. }
  379. return standardZoom / 100;
  380. }
  381. private void ToolExpand_Click(object sender, RoutedEventArgs e)
  382. {
  383. ToggleButton expandBtn = sender as ToggleButton;
  384. if (expandBtn != null)
  385. {
  386. bool isExpand = expandBtn.IsChecked == true;
  387. ExpandLeftPanel(isExpand);
  388. }
  389. }
  390. private void EditLink_Click(object sender, RoutedEventArgs e)
  391. {
  392. PropertyContainer.Visibility = Visibility.Visible;
  393. }
  394. private void UndoButton_Click(object sender, RoutedEventArgs e)
  395. {
  396. if (PDFViewControl != null && PDFViewControl.PDFViewTool.GetCPDFViewer() != null)
  397. {
  398. PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager?.Undo();
  399. PDFViewControl.PDFToolManager.ClearSelect();
  400. PDFViewControl.PDFViewTool.GetCPDFViewer().UpdateAnnotFrame();
  401. }
  402. }
  403. private void RedoButton_Click(object sender, RoutedEventArgs e)
  404. {
  405. if (PDFViewControl != null && PDFViewControl.PDFViewTool.GetCPDFViewer() != null)
  406. {
  407. PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager?.Redo();
  408. PDFViewControl.PDFToolManager.ClearSelect();
  409. PDFViewControl.PDFViewTool.GetCPDFViewer().UpdateAnnotFrame();
  410. }
  411. }
  412. #endregion
  413. #region Property changed
  414. protected void OnPropertyChanged([CallerMemberName] string name = null)
  415. {
  416. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
  417. }
  418. private void UndoManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
  419. {
  420. OnPropertyChanged(e.PropertyName);
  421. if (e.PropertyName == "CanUndo" || e.PropertyName == "CanRedo")
  422. {
  423. OnCanSaveChanged?.Invoke(this, CanSave);
  424. }
  425. }
  426. private void PanelState_PropertyChanged(object sender, PropertyChangedEventArgs e)
  427. {
  428. if (e.PropertyName == nameof(PanelState.IsLeftPanelExpand))
  429. {
  430. ExpandLeftPanel(panelState.IsLeftPanelExpand);
  431. }
  432. else if (e.PropertyName == nameof(PanelState.RightPanel))
  433. {
  434. if (panelState.RightPanel == PanelState.RightPanelState.PropertyPanel)
  435. {
  436. ExpandRightPropertyPanel(PDFAnnotationControl, Visibility.Visible);
  437. }
  438. else if (panelState.RightPanel == PanelState.RightPanelState.ViewSettings)
  439. {
  440. ExpandRightPropertyPanel(displaySettingsControl, Visibility.Visible);
  441. }
  442. else
  443. {
  444. ExpandRightPropertyPanel(null, Visibility.Collapsed);
  445. }
  446. }
  447. }
  448. #endregion
  449. #region Event handle
  450. private void AnnotationBarControl_AnnotationCancel(object sender, EventArgs e)
  451. {
  452. PDFAnnotationControl.AnnotationCancel();
  453. if (panelState.RightPanel == PanelState.RightPanelState.PropertyPanel)
  454. {
  455. panelState.RightPanel = PanelState.RightPanelState.None;
  456. }
  457. }
  458. private void AnnotationBarControl_AnnotationPropertyChanged(object sender, CPDFAnnotationType e)
  459. {
  460. PDFAnnotationControl.LoadAnnotationPanel(e);
  461. if (e != CPDFAnnotationType.Audio && e != CPDFAnnotationType.Image)
  462. {
  463. panelState.RightPanel = PanelState.RightPanelState.PropertyPanel;
  464. }
  465. if (e == CPDFAnnotationType.Link)
  466. {
  467. PDFViewControl.PDFViewTool.GetCPDFViewer().SetLinkHighlight(true);
  468. }
  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. }