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. using ComPDFKitViewer.Widget;
  25. using ComPDFKit.Tool.Help;
  26. namespace Compdfkit_Tools.PDFControl
  27. {
  28. public partial class AnnotationControl : UserControl, INotifyPropertyChanged
  29. {
  30. #region Property
  31. private bool isFirstLoad = true;
  32. public PDFViewControl PDFViewControl;
  33. public CPDFAnnotationControl PDFAnnotationControl = null;
  34. private CPDFDisplaySettingsControl displaySettingsControl = null;
  35. public FromPropertyControl FromPropertyControl = new FromPropertyControl();
  36. private PanelState panelState = PanelState.GetInstance();
  37. private double[] zoomLevelList = { 1f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
  38. public event PropertyChangedEventHandler PropertyChanged;
  39. public ICommand CloseTabCommand;
  40. public ICommand ExpandPropertyPanelCommand;
  41. public bool CanUndo
  42. {
  43. get
  44. {
  45. if (PDFViewControl != null && PDFViewControl.PDFViewTool.GetCPDFViewer() != null)
  46. {
  47. return PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.CanUndo;
  48. }
  49. return false;
  50. }
  51. }
  52. public bool CanRedo
  53. {
  54. get
  55. {
  56. if (PDFViewControl != null && PDFViewControl.PDFViewTool.GetCPDFViewer() != null)
  57. {
  58. return PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.CanRedo;
  59. }
  60. return false;
  61. }
  62. }
  63. private bool CanSave
  64. {
  65. get
  66. {
  67. if (PDFViewControl != null && PDFViewControl.PDFViewTool.GetCPDFViewer() != null)
  68. {
  69. if (PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.CanRedo ||
  70. PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.CanUndo)
  71. {
  72. return true;
  73. }
  74. }
  75. return false;
  76. }
  77. }
  78. public event EventHandler<bool> OnCanSaveChanged;
  79. public event EventHandler OnAnnotEditHandler;
  80. #endregion
  81. public AnnotationControl()
  82. {
  83. InitializeComponent();
  84. DataContext = this;
  85. PDFAnnotationControl = new CPDFAnnotationControl();
  86. CPDFAnnotationType[] annotationProperties =
  87. {
  88. CPDFAnnotationType.Highlight, CPDFAnnotationType.Underline, CPDFAnnotationType.Strikeout,
  89. CPDFAnnotationType.Squiggly, CPDFAnnotationType.Freehand, CPDFAnnotationType.FreeText,
  90. CPDFAnnotationType.Note, CPDFAnnotationType.Circle, CPDFAnnotationType.Square,
  91. CPDFAnnotationType.Arrow, CPDFAnnotationType.Line, CPDFAnnotationType.Image,
  92. CPDFAnnotationType.Stamp, CPDFAnnotationType.Signature, CPDFAnnotationType.Link,
  93. CPDFAnnotationType.Audio
  94. };
  95. AnnotationBarControl.InitAnnotationBar(annotationProperties);
  96. panelState.PropertyChanged -= PanelState_PropertyChanged;
  97. panelState.PropertyChanged += PanelState_PropertyChanged;
  98. UndoBtn.ToolTip = LanguageHelper.CommonManager.GetString("Tooltip_Undo");
  99. RedoBtn.ToolTip = LanguageHelper.CommonManager.GetString("Tooltip_Redo");
  100. }
  101. #region Init PDFViewer
  102. public void InitWithPDFViewer(PDFViewControl pdfViewer)
  103. {
  104. PDFViewControl = pdfViewer;
  105. PDFGrid.Child = PDFViewControl;
  106. FloatPageTool.InitWithPDFViewer(PDFViewControl);
  107. InitialPDFViewControl(PDFViewControl);
  108. }
  109. #endregion
  110. #region Public Method
  111. public void ClearViewerControl()
  112. {
  113. PDFGrid.Child = null;
  114. BotaContainer.Child = null;
  115. PropertyContainer.Child = null;
  116. displaySettingsControl = null;
  117. PDFViewControl?.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_NONE);
  118. }
  119. public void SetBOTAContainer(CPDFBOTABarControl botaControl)
  120. {
  121. this.BotaContainer.Child = botaControl;
  122. }
  123. public void SetDisplaySettingsControl(CPDFDisplaySettingsControl displaySettingsControl)
  124. {
  125. this.displaySettingsControl = displaySettingsControl;
  126. }
  127. public void SetPropertyContainer(UIElement uiElement)
  128. {
  129. PropertyContainer.Child = uiElement;
  130. }
  131. public void ClearAllToolState()
  132. {
  133. this.AnnotationBarControl.ClearAllToolState();
  134. }
  135. public void SetToolBarContainerVisibility(Visibility visibility)
  136. {
  137. this.ToolBarContainer.Visibility = visibility;
  138. }
  139. #endregion
  140. #region Load Unload custom control
  141. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  142. {
  143. PDFViewControl.MouseRightButtonDownHandler -= PDFViewControl_MouseRightButtonDownHandler;
  144. PDFViewControl.MouseRightButtonDownHandler += PDFViewControl_MouseRightButtonDownHandler;
  145. InitialPDFViewControl(PDFViewControl);
  146. }
  147. private void PDFToolManager_MouseLeftButtonDownHandler(object sender, MouseEventObject e)
  148. {
  149. if (e.annotType == C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET)
  150. {
  151. BaseWidget baseWidget = PDFViewControl.GetCacheHitTestWidget();
  152. if (baseWidget != null)
  153. {
  154. AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam(
  155. PDFViewControl.PDFViewTool.GetCPDFViewer().GetDocument(),
  156. baseWidget.GetAnnotData().PageIndex,
  157. baseWidget.GetAnnotData().Annot);
  158. if ((annotParam as WidgetParm).WidgetType == C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS)
  159. {
  160. CPDFSignatureUI signatureProperty = new CPDFSignatureUI();
  161. signatureProperty.SetFormProperty(annotParam, PDFViewControl, baseWidget.GetAnnotData().Annot);
  162. PropertyContainer.Child = signatureProperty;
  163. }
  164. }
  165. }
  166. }
  167. private void UserControl_Unloaded(object sender, RoutedEventArgs e)
  168. {
  169. PDFViewControl.MouseRightButtonDownHandler -= PDFViewControl_MouseRightButtonDownHandler;
  170. }
  171. private void AnnotationBarControl_Loaded(object sender, RoutedEventArgs e)
  172. {
  173. AnnotationBarControl.AnnotationPropertyChanged -= AnnotationBarControl_AnnotationPropertyChanged;
  174. AnnotationBarControl.AnnotationCancel -= AnnotationBarControl_AnnotationCancel;
  175. AnnotationBarControl.AnnotationPropertyChanged += AnnotationBarControl_AnnotationPropertyChanged;
  176. AnnotationBarControl.AnnotationCancel += AnnotationBarControl_AnnotationCancel;
  177. }
  178. private void AnnotationBarControl_Unloaded(object sender, RoutedEventArgs e)
  179. {
  180. AnnotationBarControl.AnnotationPropertyChanged -= AnnotationBarControl_AnnotationPropertyChanged;
  181. AnnotationBarControl.AnnotationCancel -= AnnotationBarControl_AnnotationCancel;
  182. }
  183. #endregion
  184. #region Annotation
  185. public void InitialPDFViewControl(PDFViewControl newPDFViewer)
  186. {
  187. PDFAnnotationControl.SetPDFViewer(newPDFViewer);
  188. PDFAnnotationControl.AnnotationCancel();
  189. AnnotationBarControl.ClearAllToolState();
  190. ExpandRightPropertyPanel(null, Visibility.Collapsed);
  191. PDFAnnotationControl.ClearAnnotationBar -= PdfAnnotationControl_ClearAnnotationBar;
  192. PDFAnnotationControl.ClearAnnotationBar += PdfAnnotationControl_ClearAnnotationBar;
  193. //PDFViewControl.PDFView.AnnotEditHandler -= PDFView_AnnotEditHandler;
  194. //PDFViewControl.PDFView.AnnotEditHandler += PDFView_AnnotEditHandler;
  195. PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.PropertyChanged -= UndoManager_PropertyChanged;
  196. PDFViewControl.PDFViewTool.GetCPDFViewer().UndoManager.PropertyChanged += UndoManager_PropertyChanged;
  197. //PDFViewControl.PDFView.AnnotActiveHandler -= PDFView_AnnotActiveHandler;
  198. //PDFViewControl.PDFView.AnnotActiveHandler += PDFView_AnnotActiveHandler;
  199. //PDFViewControl.PDFView.AnnotCommandHandler += PDFView_AnnotCommandHandler;
  200. //PDFViewControl.PDFView.WidgetClickHandler += PDFView_WidgetClickHandler;
  201. }
  202. private void PDFViewControl_MouseRightButtonDownHandler(object sender, ComPDFKit.Tool.MouseEventObject e)
  203. {
  204. ContextMenu ContextMenu = PDFViewControl.GetRightMenu();
  205. if (ContextMenu == null)
  206. {
  207. ContextMenu = new ContextMenu();
  208. }
  209. switch (e.hitTestType)
  210. {
  211. case MouseHitTestType.Annot:
  212. case MouseHitTestType.SelectRect:
  213. CreateAnnotContextMenu(sender, ref ContextMenu, e.annotType);
  214. break;
  215. case MouseHitTestType.Text:
  216. CreateSelectTextContextMenu(sender, ref ContextMenu);
  217. break;
  218. case MouseHitTestType.ImageSelect:
  219. CreateSelectImageContextMenu(sender, ref ContextMenu);
  220. break;
  221. default:
  222. ContextMenu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
  223. PDFViewControl.CreateViewerMenu(sender, ref ContextMenu);
  224. break;
  225. }
  226. PDFViewControl.SetRightMenu(ContextMenu);
  227. }
  228. private void CreateSelectTextContextMenu(object sender, ref ContextMenu menu)
  229. {
  230. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
  231. }
  232. private void CreateAnnotContextMenu(object sender, ref ContextMenu menu, C_ANNOTATION_TYPE annotType)
  233. {
  234. switch (annotType)
  235. {
  236. case C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET:
  237. break;
  238. case C_ANNOTATION_TYPE.C_ANNOTATION_SOUND:
  239. case C_ANNOTATION_TYPE.C_ANNOTATION_MOVIE:
  240. case C_ANNOTATION_TYPE.C_ANNOTATION_RICHMEDIA:
  241. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Delete"), Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
  242. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Play"), Command = MediaCommands.Play, CommandTarget = (UIElement)sender, CommandParameter = (sender as CPDFViewerTool).GetCacheHitTestAnnot() });
  243. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Cut"), Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
  244. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
  245. break;
  246. default:
  247. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Delete"), Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
  248. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
  249. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Cut"), Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
  250. menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
  251. break;
  252. }
  253. }
  254. private void CreateSelectImageContextMenu(object sender, ref ContextMenu menu)
  255. {
  256. if (menu == null)
  257. {
  258. menu = new ContextMenu();
  259. }
  260. MenuItem copyImage = new MenuItem();
  261. copyImage.Header = "Copy Image";
  262. copyImage.Click += CopyImage_Click;
  263. menu.Items.Add(copyImage);
  264. MenuItem extractImage = new MenuItem();
  265. extractImage.Header = "Extract Image";
  266. extractImage.Click += ExtractImage_Click;
  267. menu.Items.Add(extractImage);
  268. }
  269. private void ExtractImage_Click(object sender, RoutedEventArgs e)
  270. {
  271. System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog();
  272. if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  273. {
  274. var image = PDFViewControl.FocusPDFViewTool.GetSelectImage();
  275. if (image == null)
  276. {
  277. return;
  278. }
  279. CPDFPage page = PDFViewControl.PDFToolManager.GetDocument().PageAtIndex(image.PageIndex);
  280. string savePath = Path.Combine(folderDialog.SelectedPath, Guid.NewGuid() + ".jpg");
  281. string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".jpg");
  282. page.GetImgSelection().GetImgBitmap(image.ImageIndex, tempPath);
  283. Bitmap bitmap = new Bitmap(tempPath);
  284. bitmap.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
  285. Process.Start("explorer", "/select,\"" + savePath + "\"");
  286. }
  287. }
  288. private void CopyImage_Click(object sender, RoutedEventArgs e)
  289. {
  290. var image = PDFViewControl.FocusPDFViewTool.GetSelectImage();
  291. if (image == null)
  292. {
  293. return;
  294. }
  295. CPDFPage page = PDFViewControl.PDFToolManager.GetDocument().PageAtIndex(image.PageIndex);
  296. string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".jpg");
  297. page.GetImgSelection().GetImgBitmap(image.ImageIndex, tempPath);
  298. Bitmap bitmap = new Bitmap(tempPath);
  299. BitmapImage imageData;
  300. using (MemoryStream ms = new MemoryStream())
  301. {
  302. bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
  303. imageData = new BitmapImage();
  304. imageData.BeginInit();
  305. imageData.StreamSource = ms;
  306. imageData.CacheOption = BitmapCacheOption.OnLoad;
  307. imageData.EndInit();
  308. imageData.Freeze();
  309. Clipboard.SetImage(imageData);
  310. bitmap.Dispose();
  311. File.Delete(tempPath);
  312. }
  313. }
  314. public void UnloadEvent()
  315. {
  316. //PDFViewControl.PDFView.AnnotEditHandler -= PDFView_AnnotEditHandler;
  317. //PDFViewControl.PDFView.AnnotActiveHandler -= PDFView_AnnotActiveHandler;
  318. //panelState.PropertyChanged -= PanelState_PropertyChanged;
  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. }