MainWindow.xaml.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. using ComPDFKit.PDFDocument;
  2. using compdfkit_tools.Data;
  3. using compdfkit_tools.Helper;
  4. using compdfkit_tools.PDFControl;
  5. using compdfkit_tools.PDFControlUI;
  6. using ComPDFKitViewer;
  7. using ComPDFKitViewer.PdfViewer;
  8. using Microsoft.Win32;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.ComponentModel;
  12. using System.Runtime.CompilerServices;
  13. using System.Windows;
  14. using System.Windows.Annotations;
  15. using System.Windows.Controls;
  16. using System.Windows.Controls.Primitives;
  17. using System.Windows.Input;
  18. using System.Windows.Media.Animation;
  19. namespace viewer_ctrl_demo
  20. {
  21. /// <summary>
  22. /// Interaction logic for MainWindow.xaml
  23. /// </summary>
  24. public partial class MainWindow : Window
  25. {
  26. private PDFViewControl passwordViewer;
  27. private PDFViewControl pdfViewControl;
  28. private CPDFAnnotationControl pdfAnnotationControl = null;
  29. private double[] zoomLevelList = { 1f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
  30. public MainWindow()
  31. {
  32. InitializeComponent();
  33. DataContext = this;
  34. }
  35. private void MainWindow_Loaded(object sender, RoutedEventArgs e)
  36. {
  37. pdfAnnotationControl = new CPDFAnnotationControl();
  38. LoadDefaultDocument();
  39. BindZoomLevel();
  40. }
  41. private void BindZoomLevel()
  42. {
  43. foreach (double zoomLevel in zoomLevelList)
  44. {
  45. ComboBoxItem zoomItem = new ComboBoxItem();
  46. zoomItem.Content = zoomLevel + "%";
  47. ZoomComboBox.Items.Add(zoomItem);
  48. }
  49. }
  50. private void LoadDocument()
  51. {
  52. pdfViewControl.PDFView?.Load();
  53. PDFGrid.Child = pdfViewControl;
  54. pdfViewControl.PDFView.InfoChanged -= PdfViewer_InfoChanged;
  55. pdfViewControl.PDFView.InfoChanged += PdfViewer_InfoChanged;
  56. pdfViewControl.PDFView.AnnotCommandHandler += PDFView_AnnotCommandHandler;
  57. PasswordUI.Closed += PasswordUI_Closed;
  58. PasswordUI.Canceled += PasswordUI_Canceled;
  59. PasswordUI.Confirmed += PasswordUI_Confirmed;
  60. UIElement currentBotaTool = GetBotaTool();
  61. if (currentBotaTool is CPDFSearchControl)
  62. {
  63. ((CPDFSearchControl)currentBotaTool).InitWithPDFViewer(pdfViewControl.PDFView);
  64. }
  65. if (currentBotaTool is CPDFThumbnailControl)
  66. {
  67. ((CPDFThumbnailControl)currentBotaTool).InitWithPDFViewer(pdfViewControl.PDFView);
  68. ((CPDFThumbnailControl)currentBotaTool).ThumbLoaded = false;
  69. ((CPDFThumbnailControl)currentBotaTool).LoadThumb();
  70. }
  71. if (currentBotaTool is CPDFBookmarkControl)
  72. {
  73. ((CPDFBookmarkControl)currentBotaTool).InitWithPDFViewer(pdfViewControl.PDFView);
  74. ((CPDFBookmarkControl)currentBotaTool).LoadBookmark();
  75. }
  76. ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
  77. InitialPDFViewControl(pdfViewControl);
  78. }
  79. private void PDFView_AnnotCommandHandler(object sender, ComPDFKitViewer.AnnotEvent.AnnotCommandArgs e)
  80. {
  81. switch (e.CommandType)
  82. {
  83. case CommandType.Context:
  84. e.Handle = true;
  85. if (e.CommandTarget == TargetType.Annot)
  86. {
  87. e.Handle = true;
  88. e.PopupMenu = new ContextMenu();
  89. if (e.PressOnLink)
  90. {
  91. e.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
  92. MenuItem propertyMenu = new MenuItem();
  93. propertyMenu = new MenuItem();
  94. propertyMenu.Header = "Edit";
  95. WeakEventManager<MenuItem, RoutedEventArgs>.AddHandler(propertyMenu, "Click", EditLink_Click);
  96. propertyMenu.CommandParameter = e;
  97. e.PopupMenu.Items.Add(propertyMenu);
  98. }
  99. else if (e.PressOnAnnot)
  100. {
  101. e.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
  102. e.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
  103. e.PopupMenu.Items.Add(new MenuItem() { Header = "Cut", Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
  104. }
  105. else if (e.PressOnMedia || e.PressOnSound)
  106. {
  107. e.Handle = true;
  108. e.PopupMenu.Items.Add(new MenuItem() { Header = "Play", Command = MediaCommands.Play, CommandTarget = (UIElement)sender, CommandParameter = e });
  109. e.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
  110. }
  111. else
  112. {
  113. e.Handle = true;
  114. e.PopupMenu = new ContextMenu();
  115. e.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
  116. }
  117. }
  118. break;
  119. case CommandType.Copy:
  120. e.DoCommand();
  121. break;
  122. case CommandType.Cut:
  123. case CommandType.Paste:
  124. case CommandType.Delete:
  125. e.DoCommand();
  126. break;
  127. default:
  128. break;
  129. }
  130. }
  131. private void PasswordUI_Confirmed(object sender, string e)
  132. {
  133. if (passwordViewer != null && passwordViewer.PDFView != null && passwordViewer.PDFView.Document != null)
  134. {
  135. passwordViewer.PDFView.Document.UnlockWithPassword(e);
  136. if (passwordViewer.PDFView.Document.IsLocked == false)
  137. {
  138. PasswordUI.SetShowError("", Visibility.Collapsed);
  139. PasswordUI.ClearPassword();
  140. PasswordUI.Visibility = Visibility.Collapsed;
  141. PopupBorder.Visibility = Visibility.Collapsed;
  142. pdfViewControl = passwordViewer;
  143. LoadDocument();
  144. }
  145. else
  146. {
  147. PasswordUI.SetShowError("error", Visibility.Visible);
  148. }
  149. }
  150. }
  151. private void PasswordUI_Canceled(object sender, EventArgs e)
  152. {
  153. PopupBorder.Visibility = Visibility.Collapsed;
  154. PasswordUI.Visibility = Visibility.Collapsed;
  155. }
  156. private void PasswordUI_Closed(object sender, EventArgs e)
  157. {
  158. PopupBorder.Visibility = Visibility.Collapsed;
  159. PasswordUI.Visibility = Visibility.Collapsed;
  160. }
  161. private void PdfViewer_InfoChanged(object sender, KeyValuePair<string, object> e)
  162. {
  163. if (e.Key == "PageNum")
  164. {
  165. PageRangeText.Text = string.Format("{0}/{1}", e.Value, pdfViewControl.PDFView.Document.PageCount);
  166. }
  167. if (e.Key == "Zoom")
  168. {
  169. ZoomTextBox.Text = string.Format("{0}", (int)((double)e.Value * 100)) + "%";
  170. }
  171. }
  172. private double CheckZoomLevel(double zoom, bool IsGrowth)
  173. {
  174. double standardZoom = 100;
  175. if (zoom <= 0.01)
  176. {
  177. return 0.01;
  178. }
  179. if (zoom >= 10)
  180. {
  181. return 10;
  182. }
  183. zoom *= 100;
  184. for (int i = 0; i < zoomLevelList.Length - 1; i++)
  185. {
  186. if (zoom > zoomLevelList[i] && zoom <= zoomLevelList[i + 1] && IsGrowth)
  187. {
  188. standardZoom = zoomLevelList[i + 1];
  189. break;
  190. }
  191. if (zoom >= zoomLevelList[i] && zoom < zoomLevelList[i + 1] && !IsGrowth)
  192. {
  193. standardZoom = zoomLevelList[i];
  194. break;
  195. }
  196. }
  197. return standardZoom / 100;
  198. }
  199. private void LoadDefaultDocument()
  200. {
  201. string defaultFilePath = "developer_guide_windows.pdf";
  202. pdfViewControl = new PDFViewControl();
  203. pdfViewControl.PDFView.InitDocument(defaultFilePath);
  204. LoadDocument();
  205. }
  206. /// <summary>
  207. /// 搜索工具点击处理
  208. /// </summary>
  209. private void SearchToolButton_Click(object sender, RoutedEventArgs e)
  210. {
  211. UIElement botaTool = GetBotaTool();
  212. if (botaTool == null || !(botaTool is CPDFSearchControl))
  213. {
  214. CPDFSearchControl searchControl = new CPDFSearchControl();
  215. if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
  216. {
  217. searchControl.InitWithPDFViewer(pdfViewControl.PDFView);
  218. }
  219. SetBotaTool(searchControl);
  220. }
  221. ExpandBotaTool(SearchToolButton.IsChecked == true);
  222. ClearToolState(SearchToolButton);
  223. }
  224. /// <summary>
  225. /// 缩略图列表点击处理
  226. /// </summary>
  227. private void ThumbToolButton_Click(object sender, RoutedEventArgs e)
  228. {
  229. UIElement botaTool = GetBotaTool();
  230. if (botaTool == null || !(botaTool is CPDFThumbnailControl))
  231. {
  232. CPDFThumbnailControl thumbControl = new CPDFThumbnailControl();
  233. if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
  234. {
  235. thumbControl.InitWithPDFViewer(pdfViewControl.PDFView);
  236. thumbControl.LoadThumb();
  237. }
  238. SetBotaTool(thumbControl);
  239. }
  240. ExpandBotaTool(ThumbToolButton.IsChecked == true);
  241. ClearToolState(ThumbToolButton);
  242. }
  243. /// <summary>
  244. /// 书签列表点击处理
  245. /// </summary>
  246. private void BookmarkToolButtonn_Click(object sender, RoutedEventArgs e)
  247. {
  248. UIElement botaTool = GetBotaTool();
  249. if (botaTool == null || !(botaTool is CPDFBookmarkControl))
  250. {
  251. CPDFBookmarkControl bookmarkControl = new CPDFBookmarkControl();
  252. if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
  253. {
  254. bookmarkControl.InitWithPDFViewer(pdfViewControl.PDFView);
  255. bookmarkControl.LoadBookmark();
  256. }
  257. SetBotaTool(bookmarkControl);
  258. }
  259. ExpandBotaTool(BookmarkToolButton.IsChecked == true);
  260. ClearToolState(BookmarkToolButton);
  261. }
  262. /// <summary>
  263. /// 大纲列表处理
  264. /// </summary>
  265. private void OutlineToolButton_Click(object sender, RoutedEventArgs e)
  266. {
  267. UIElement botaTool = GetBotaTool();
  268. if (botaTool == null || !(botaTool is CPDFOutlineControl))
  269. {
  270. CPDFOutlineControl outlineControl = new CPDFOutlineControl();
  271. if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
  272. {
  273. outlineControl.InitWithPDFViewer(pdfViewControl.PDFView);
  274. }
  275. SetBotaTool(outlineControl);
  276. }
  277. ExpandBotaTool(OutlineToolButton.IsChecked == true);
  278. ClearToolState(OutlineToolButton);
  279. }
  280. /// <summary>
  281. /// 设置Bota工具内容
  282. /// </summary>
  283. /// <param name="newChild"></param>
  284. private void SetBotaTool(UIElement newChild)
  285. {
  286. BotaToolContainer.Child = newChild;
  287. }
  288. /// <summary>
  289. /// 获取Bota工具
  290. /// </summary>
  291. /// <returns></returns>
  292. private UIElement GetBotaTool()
  293. {
  294. return BotaToolContainer.Child;
  295. }
  296. /// <summary>
  297. /// 展开Bota工具
  298. /// </summary>
  299. /// <param name="isExpand"></param>
  300. private void ExpandBotaTool(bool isExpand)
  301. {
  302. BotaToolContainer.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
  303. Splitter.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
  304. }
  305. /// <summary>
  306. /// 清除左边工具栏状态
  307. /// </summary>
  308. private void ClearToolState(UIElement ignoreTool)
  309. {
  310. foreach (UIElement child in BotaSideTool.Children)
  311. {
  312. if (child != ignoreTool && child is ToggleButton buttonTool)
  313. {
  314. buttonTool.IsChecked = false;
  315. }
  316. }
  317. }
  318. private void ToolExpand_Click(object sender, RoutedEventArgs e)
  319. {
  320. ToggleButton expandBtn = sender as ToggleButton;
  321. if (expandBtn != null)
  322. {
  323. bool isExpand = expandBtn.IsChecked == true;
  324. ExpandLeftPanel(isExpand);
  325. if (isExpand)
  326. {
  327. ThumbToolButton.IsChecked = isExpand;
  328. ThumbToolButton_Click(ThumbToolButton, new RoutedEventArgs());
  329. }
  330. }
  331. }
  332. private void ExpandSearchBtn_Click(object sender, RoutedEventArgs e)
  333. {
  334. ExpandLeftPanel(true);
  335. SearchToolButton.IsChecked = true;
  336. SearchToolButton_Click(SearchToolButton, new RoutedEventArgs());
  337. }
  338. private void ExpandLeftPanel(bool isExpand)
  339. {
  340. ExpandToolContainer.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
  341. Splitter.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
  342. if (isExpand)
  343. {
  344. BodyGrid.ColumnDefinitions[0].Width = new GridLength(260);
  345. BodyGrid.ColumnDefinitions[1].Width = new GridLength(15);
  346. }
  347. else
  348. {
  349. BodyGrid.ColumnDefinitions[0].Width = new GridLength(0);
  350. BodyGrid.ColumnDefinitions[1].Width = new GridLength(0);
  351. }
  352. }
  353. private void Border_MouseEnter(object sender, MouseEventArgs e)
  354. {
  355. FloatPageTool.Visibility = Visibility.Visible;
  356. }
  357. private void PDFGrid_MouseMove(object sender, MouseEventArgs e)
  358. {
  359. FloatPageTool.Visibility = Visibility.Collapsed;
  360. }
  361. private void ViewSettingBtn_Click(object sender, RoutedEventArgs e)
  362. {
  363. ToggleButton toggleButton = sender as ToggleButton;
  364. if (toggleButton != null)
  365. {
  366. if (toggleButton.IsChecked == true)
  367. {
  368. CPDFDisplaySettingsControl displayPanel = new CPDFDisplaySettingsControl();
  369. displayPanel.InitWithPDFViewer(pdfViewControl.PDFView);
  370. PropertyContainer.Child = displayPanel;
  371. PropertyContainer.Visibility = Visibility.Visible;
  372. }
  373. else
  374. {
  375. PropertyContainer.Child = null;
  376. PropertyContainer.Visibility = Visibility.Collapsed;
  377. }
  378. }
  379. }
  380. private void ZoomComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  381. {
  382. ComboBoxItem selectItem = ZoomComboBox.SelectedItem as ComboBoxItem;
  383. if (selectItem != null && selectItem.Content != null && pdfViewControl != null)
  384. {
  385. if (double.TryParse(selectItem.Content.ToString().TrimEnd('%'), out double zoomLevel))
  386. {
  387. pdfViewControl.PDFView.Zoom(zoomLevel / 100D);
  388. ZoomTextBox.Text = string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)) + "%";
  389. }
  390. }
  391. }
  392. private void ZoomInBtn_Click(object sender, RoutedEventArgs e)
  393. {
  394. if (pdfViewControl != null)
  395. {
  396. double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
  397. pdfViewControl.PDFView.Zoom(newZoom);
  398. ZoomTextBox.Text = string.Format("{0}", (int)(newZoom * 100)) + "%";
  399. }
  400. }
  401. private void ZoomOutBtn_Click(object sender, RoutedEventArgs e)
  402. {
  403. if (pdfViewControl != null)
  404. {
  405. double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
  406. pdfViewControl.PDFView.Zoom(newZoom);
  407. ZoomTextBox.Text = string.Format("{0}", (int)(newZoom * 100)) + "%";
  408. }
  409. }
  410. private void NextPageBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  411. {
  412. pdfViewControl.PDFView?.GoToPage(pdfViewControl.PDFView.CurrentIndex + 1);
  413. }
  414. private void PrevPageBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  415. {
  416. pdfViewControl.PDFView?.GoToPage(pdfViewControl.PDFView.CurrentIndex - 1);
  417. }
  418. private void PageInfoBtn_Click(object sender, RoutedEventArgs e)
  419. {
  420. PasswordUI.Visibility = Visibility.Collapsed;
  421. FileInfoUI.Visibility = Visibility.Visible;
  422. FileInfoControl.InitWithPDFViewer(pdfViewControl.PDFView);
  423. PopupBorder.Visibility = Visibility.Visible;
  424. }
  425. private void FileInfoCloseBtn_Click(object sender, RoutedEventArgs e)
  426. {
  427. PopupBorder.Visibility = Visibility.Collapsed;
  428. }
  429. private void OpenFile_Click(object sender, RoutedEventArgs e)
  430. {
  431. try
  432. {
  433. string filePath = CommonHelper.GetFilePathOrEmpty();
  434. if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
  435. {
  436. passwordViewer = new PDFViewControl();
  437. passwordViewer.PDFView.InitDocument(filePath);
  438. if (passwordViewer.PDFView.Document == null)
  439. {
  440. MessageBox.Show("Open File Failed");
  441. return;
  442. }
  443. if (passwordViewer.PDFView.Document.IsLocked)
  444. {
  445. PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " password encrypted.");
  446. PasswordUI.ClearPassword();
  447. PopupBorder.Visibility = Visibility.Visible;
  448. PasswordUI.Visibility = Visibility.Visible;
  449. }
  450. else
  451. {
  452. pdfViewControl = passwordViewer;
  453. LoadDocument();
  454. }
  455. }
  456. }
  457. catch (Exception ex)
  458. {
  459. }
  460. }
  461. private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
  462. {
  463. if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
  464. {
  465. try
  466. {
  467. CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
  468. if (pdfDoc.WriteToLoadedPath())
  469. {
  470. return;
  471. }
  472. SaveFileDialog saveDialog = new SaveFileDialog();
  473. saveDialog.Filter = "(*.pdf)|*.pdf";
  474. saveDialog.DefaultExt = ".pdf";
  475. saveDialog.OverwritePrompt = true;
  476. if (saveDialog.ShowDialog() == true)
  477. {
  478. pdfDoc.WriteToFilePath(saveDialog.FileName);
  479. }
  480. }
  481. catch (Exception ex)
  482. {
  483. }
  484. }
  485. }
  486. #region Annotation
  487. public void InitialPDFViewControl(PDFViewControl newPDFViewer)
  488. {
  489. pdfAnnotationControl.SetPDFViewer(newPDFViewer.PDFView);
  490. pdfAnnotationControl.AnnotationCancel();
  491. AnnotationBarControl.ClearAllToolState();
  492. ExpandRightPropertyPanel(null, Visibility.Collapsed);
  493. }
  494. #endregion
  495. private void AnnotationBarControl_Loaded(object sender, RoutedEventArgs e)
  496. {
  497. CPDFAnnotationType[] annotationProperties = { CPDFAnnotationType.Highlight, CPDFAnnotationType.Underline, CPDFAnnotationType.Strikeout, CPDFAnnotationType.Squiggly, CPDFAnnotationType.Freehand, CPDFAnnotationType.FreeText, CPDFAnnotationType.Note, CPDFAnnotationType.Circle, CPDFAnnotationType.Square, CPDFAnnotationType.Arrow, CPDFAnnotationType.Line, CPDFAnnotationType.Stamp, CPDFAnnotationType.Signature, CPDFAnnotationType.Link, CPDFAnnotationType.Audio };
  498. AnnotationBarControl.InitAnnotationBar(annotationProperties);
  499. AnnotationBarControl.AnnotationPropertyChanged += AnnotationBarControl_AnnotationPropertyChanged;
  500. AnnotationBarControl.AnnotationCancel += AnnotationBarControl_AnnotationCancel;
  501. }
  502. private void AnnotationBarControl_Unloaded(object sender, RoutedEventArgs e)
  503. {
  504. AnnotationBarControl.AnnotationPropertyChanged -= AnnotationBarControl_AnnotationPropertyChanged;
  505. AnnotationBarControl.AnnotationCancel -= AnnotationBarControl_AnnotationCancel;
  506. }
  507. private void AnnotationBarControl_AnnotationCancel(object sender, EventArgs e)
  508. {
  509. pdfAnnotationControl.AnnotationCancel();
  510. ExpandRightPropertyPanel(null, Visibility.Collapsed);
  511. }
  512. private void AnnotationBarControl_AnnotationPropertyChanged(object sender, CPDFAnnotationType e)
  513. {
  514. pdfAnnotationControl.LoadAnnotationPanel(e);
  515. ExpandRightPropertyPanel(pdfAnnotationControl, Visibility.Visible);
  516. }
  517. private void AnnotationBarControl_Click(object sender, RoutedEventArgs e)
  518. {
  519. ToggleButton toggleButton = sender as ToggleButton;
  520. if (toggleButton != null)
  521. {
  522. if (toggleButton.IsChecked == true)
  523. {
  524. if (pdfAnnotationControl != null)
  525. {
  526. ExpandRightPropertyPanel(pdfAnnotationControl, Visibility.Visible);
  527. }
  528. }
  529. else
  530. {
  531. ExpandRightPropertyPanel(null, Visibility.Collapsed);
  532. }
  533. }
  534. }
  535. public void ExpandRightPropertyPanel(UIElement properytPanel, Visibility visible)
  536. {
  537. PropertyContainer.Width = 260;
  538. PropertyContainer.Child = properytPanel;
  539. PropertyContainer.Visibility = visible;
  540. }
  541. private void EditLink_Click(object sender, RoutedEventArgs e)
  542. {
  543. PropertyContainer.Visibility = Visibility.Visible;
  544. }
  545. }
  546. }