MainWindow.xaml.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. using ComPDFKit.Controls.Helper;
  2. using ComPDFKit.Controls.PDFControl;
  3. using ComPDFKitViewer;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Input;
  9. using System.Windows.Media.Imaging;
  10. using System.Diagnostics;
  11. using System.IO;
  12. using System.Drawing;
  13. using System.ComponentModel;
  14. using System.Data;
  15. using System.Linq;
  16. using System.Reflection;
  17. using System.Runtime.CompilerServices;
  18. using ComPDFKit.PDFDocument;
  19. using Microsoft.Win32;
  20. using System.Windows.Controls.Primitives;
  21. using ComPDFKit.Tool;
  22. namespace DocsEditor
  23. {
  24. public partial class MainWindow : Window, INotifyPropertyChanged
  25. {
  26. #region Property
  27. private bool isFirstLoad = true;
  28. private string currentMode = "Page Edit";
  29. private PDFViewControl passwordViewer;
  30. private PDFViewControl pdfViewControl;
  31. private CPDFAnnotationControl pdfAnnotationControl = null;
  32. private CPDFSearchControl searchControl = null;
  33. private CPDFPageEditControl pageEditControl = null;
  34. private CPDFDisplaySettingsControl displayPanel = new CPDFDisplaySettingsControl();
  35. private double[] zoomLevelList = { 1f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
  36. /// <summary>
  37. /// Whether the save operation can be performed.
  38. /// </summary>
  39. private bool _canSave = true;
  40. public bool CanSave
  41. {
  42. get => _canSave;
  43. set
  44. {
  45. _canSave = value;
  46. OnPropertyChanged();
  47. }
  48. }
  49. public event PropertyChangedEventHandler PropertyChanged;
  50. public string AppInfo
  51. {
  52. get { return Assembly.GetExecutingAssembly().GetName().Name + " " + string.Join(".", Assembly.GetExecutingAssembly().GetName().Version.ToString().Split('.').Take(3)); }
  53. }
  54. #endregion
  55. public MainWindow()
  56. {
  57. InitializeComponent();
  58. Loaded += MainWindow_Loaded;
  59. DataContext = this;
  60. }
  61. #region Load document
  62. private void LoadDefaultDocument()
  63. {
  64. string defaultFilePath = "ComPDFKit_Sample_File_Windows.pdf";
  65. LeftToolPanelButton.IsEnabled = false;
  66. SearchButton.IsEnabled = false;
  67. RightPanelButton.IsEnabled = false;
  68. ViewSettingBtn.IsEnabled = false;
  69. pdfViewControl = new PDFViewControl();
  70. pdfViewControl.InitDocument(defaultFilePath);
  71. LoadDocument();
  72. }
  73. private void LoadDocument()
  74. {
  75. if (pdfViewControl.PDFToolManager.GetDocument() == null)
  76. {
  77. return;
  78. }
  79. pdfViewControl.PDFToolManager?.SetToolType(ToolType.Viewer);
  80. if (ViewComboBox.SelectedIndex == 0)
  81. {
  82. PDFGrid.Child = pdfViewControl;
  83. }
  84. else
  85. {
  86. ToolBarContainer.Visibility = Visibility.Visible;
  87. if (pageEditControl == null)
  88. {
  89. pageEditControl = new CPDFPageEditControl();
  90. }
  91. pageEditControl.ExitPageEdit -= PageEditControl_ExitPageEdit;
  92. pageEditControl.ExitPageEdit += PageEditControl_ExitPageEdit;
  93. pageEditControl.PageMoved -= PageEditControl_PageMoved;
  94. pageEditControl.PageMoved += PageEditControl_PageMoved;
  95. CPDFPageEditBarControl.PageEditEvent -= CPDFPageEditBarControl_PageEditEvent;
  96. CPDFPageEditBarControl.PageEditEvent += CPDFPageEditBarControl_PageEditEvent;
  97. pageEditControl.LoadThumbnails(pdfViewControl);
  98. pageEditControl.viewControl = pdfViewControl;
  99. PDFGrid.Child = pageEditControl;
  100. FloatPageTool.Visibility = Visibility.Collapsed;
  101. }
  102. PasswordUI.Closed -= PasswordUI_Closed;
  103. PasswordUI.Canceled -= PasswordUI_Canceled;
  104. PasswordUI.Confirmed -= PasswordUI_Confirmed;
  105. PasswordUI.Closed += PasswordUI_Closed;
  106. PasswordUI.Canceled += PasswordUI_Canceled;
  107. PasswordUI.Confirmed += PasswordUI_Confirmed;
  108. pdfViewControl.PDFViewTool?.GetCPDFViewer().SetFitMode(FitMode.FitWidth);
  109. CPDFSaclingControl.InitWithPDFViewer(pdfViewControl);
  110. CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewControl.PDFViewTool.GetCPDFViewer().GetZoom() * 100)));
  111. ViewSettingBtn.IsChecked = false;
  112. PropertyContainer.Child = null;
  113. PropertyContainer.Visibility = Visibility.Collapsed;
  114. FloatPageTool.InitWithPDFViewer(pdfViewControl);
  115. BotaSideTool.InitWithPDFViewer(pdfViewControl);
  116. BotaSideTool.SelectBotaTool(BOTATools.Thumbnail);
  117. pdfViewControl.PDFViewTool.DocumentModifiedChanged -= PDFViewTool_DocumentModifiedChanged;
  118. pdfViewControl.PDFViewTool.DocumentModifiedChanged += PDFViewTool_DocumentModifiedChanged;
  119. }
  120. private void PDFViewTool_DocumentModifiedChanged(object sender, EventArgs e)
  121. {
  122. CanSave = pdfViewControl.PDFViewTool.IsDocumentModified;
  123. }
  124. #endregion
  125. #region password
  126. private void PasswordUI_Canceled(object sender, EventArgs e)
  127. {
  128. PopupBorder.Visibility = Visibility.Collapsed;
  129. PasswordUI.Visibility = Visibility.Collapsed;
  130. }
  131. private void PasswordUI_Closed(object sender, EventArgs e)
  132. {
  133. PopupBorder.Visibility = Visibility.Collapsed;
  134. PasswordUI.Visibility = Visibility.Collapsed;
  135. }
  136. private void PasswordUI_Confirmed(object sender, string e)
  137. {
  138. if (passwordViewer != null && passwordViewer.PDFToolManager != null && passwordViewer.PDFToolManager.GetDocument() != null)
  139. {
  140. passwordViewer.PDFToolManager.GetDocument().UnlockWithPassword(e);
  141. if (passwordViewer.PDFToolManager.GetDocument().IsLocked == false)
  142. {
  143. PasswordUI.SetShowError("", Visibility.Collapsed);
  144. PasswordUI.ClearPassword();
  145. PasswordUI.Visibility = Visibility.Collapsed;
  146. PopupBorder.Visibility = Visibility.Collapsed;
  147. pdfViewControl.PDFToolManager.GetDocument().Release();
  148. pdfViewControl = passwordViewer;
  149. LoadDocument();
  150. }
  151. else
  152. {
  153. PasswordUI.SetShowError("error", Visibility.Visible);
  154. }
  155. }
  156. }
  157. #endregion
  158. #region Expand and collapse Panel
  159. public void ExpandRightPropertyPanel(UIElement properytPanel, Visibility visible)
  160. {
  161. PropertyContainer.Width = 260;
  162. PropertyContainer.Child = properytPanel;
  163. PropertyContainer.Visibility = visible;
  164. if (visible == Visibility.Hidden || visible == Visibility.Collapsed)
  165. {
  166. RightPanelButton.IsChecked = false;
  167. }
  168. }
  169. private void ExpandLeftPanel(bool isExpand)
  170. {
  171. BotaSideTool.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
  172. Splitter.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
  173. if (isExpand)
  174. {
  175. BodyGrid.ColumnDefinitions[0].Width = new GridLength(320);
  176. BodyGrid.ColumnDefinitions[1].Width = new GridLength(15);
  177. }
  178. else
  179. {
  180. BodyGrid.ColumnDefinitions[0].Width = new GridLength(0);
  181. BodyGrid.ColumnDefinitions[1].Width = new GridLength(0);
  182. }
  183. }
  184. #endregion
  185. #region UI
  186. private void PageInfoBtn_Click(object sender, RoutedEventArgs e)
  187. {
  188. PasswordUI.Visibility = Visibility.Collapsed;
  189. FileInfoUI.Visibility = Visibility.Visible;
  190. FileInfoControl.InitWithPDFViewer(pdfViewControl);
  191. PopupBorder.Visibility = Visibility.Visible;
  192. }
  193. private void CPDFInfoControl_CloseInfoEvent(object sender, EventArgs e)
  194. {
  195. PopupBorder.Visibility = Visibility.Collapsed;
  196. }
  197. private void OpenFile()
  198. {
  199. string filePath = CommonHelper.GetExistedPathOrEmpty();
  200. if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
  201. {
  202. if (pdfViewControl.PDFToolManager != null && pdfViewControl.PDFToolManager.GetDocument() != null)
  203. {
  204. string oldFilePath = pdfViewControl.PDFToolManager.GetDocument().FilePath;
  205. if (oldFilePath.ToLower() == filePath.ToLower())
  206. {
  207. return;
  208. }
  209. else
  210. {
  211. pdfViewControl.PDFToolManager.GetDocument().Release();
  212. }
  213. }
  214. passwordViewer = new PDFViewControl();
  215. passwordViewer.InitDocument(filePath);
  216. if (passwordViewer.PDFToolManager.GetDocument() == null)
  217. {
  218. MessageBox.Show("Open File Failed");
  219. return;
  220. }
  221. if (passwordViewer.PDFToolManager.GetDocument().IsLocked)
  222. {
  223. PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " " + LanguageHelper.CommonManager.GetString("Tip_Encrypted"));
  224. PasswordUI.ClearPassword();
  225. PopupBorder.Visibility = Visibility.Visible;
  226. PasswordUI.Visibility = Visibility.Visible;
  227. }
  228. else
  229. {
  230. pdfViewControl.PDFToolManager.GetDocument().Release();
  231. pdfViewControl = passwordViewer;
  232. LoadDocument();
  233. }
  234. }
  235. }
  236. private void OpenFile_Click(object sender, RoutedEventArgs e)
  237. {
  238. OpenFile();
  239. }
  240. private void ControlLeftPanel()
  241. {
  242. if (LeftToolPanelButton != null)
  243. {
  244. bool isExpand = LeftToolPanelButton.IsChecked == true;
  245. ExpandLeftPanel(isExpand);
  246. }
  247. }
  248. private void LeftToolPanelButton_Click(object sender, RoutedEventArgs e)
  249. {
  250. ControlLeftPanel();
  251. }
  252. private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
  253. {
  254. SaveFile();
  255. pdfViewControl.PDFViewTool.IsDocumentModified = false;
  256. }
  257. private void FileInfoCloseBtn_Click(object sender, RoutedEventArgs e)
  258. {
  259. PopupBorder.Visibility = Visibility.Collapsed;
  260. }
  261. private void ExpandSearchBtn_Click(object sender, RoutedEventArgs e)
  262. {
  263. ExpandLeftPanel(true);
  264. LeftToolPanelButton.IsChecked = true;
  265. BotaSideTool.SelectBotaTool(BOTATools.Search);
  266. }
  267. private void ControlRightPanel()
  268. {
  269. if ((bool)ViewSettingBtn.IsChecked)
  270. {
  271. ViewSettingBtn.IsChecked = false;
  272. }
  273. if (RightPanelButton != null)
  274. {
  275. if (RightPanelButton.IsChecked == true)
  276. {
  277. ExpandRightPropertyPanel(pdfAnnotationControl, Visibility.Visible);
  278. }
  279. else
  280. {
  281. ExpandRightPropertyPanel(null, Visibility.Collapsed);
  282. }
  283. }
  284. }
  285. private void RightPanelButton_Click(object sender, RoutedEventArgs e)
  286. {
  287. ControlRightPanel();
  288. }
  289. private void ViewSettingBtn_Click(object sender, RoutedEventArgs e)
  290. {
  291. ShowViewSettings();
  292. }
  293. private double CheckZoomLevel(double zoom, bool IsGrowth)
  294. {
  295. double standardZoom = 100;
  296. if (zoom <= 0.01)
  297. {
  298. return 0.01;
  299. }
  300. if (zoom >= 10)
  301. {
  302. return 10;
  303. }
  304. zoom *= 100;
  305. for (int i = 0; i < zoomLevelList.Length - 1; i++)
  306. {
  307. if (zoom > zoomLevelList[i] && zoom <= zoomLevelList[i + 1] && IsGrowth)
  308. {
  309. standardZoom = zoomLevelList[i + 1];
  310. break;
  311. }
  312. if (zoom >= zoomLevelList[i] && zoom < zoomLevelList[i + 1] && !IsGrowth)
  313. {
  314. standardZoom = zoomLevelList[i];
  315. break;
  316. }
  317. }
  318. return standardZoom / 100;
  319. }
  320. #endregion
  321. #region Save file
  322. /// <summary>
  323. /// Save the file to another PDF file.
  324. /// </summary>
  325. public void SaveAsFile()
  326. {
  327. {
  328. if (pdfViewControl != null && pdfViewControl.PDFToolManager != null && pdfViewControl.PDFToolManager.GetDocument() != null)
  329. {
  330. CPDFDocument pdfDoc = pdfViewControl.PDFToolManager.GetDocument();
  331. SaveFileDialog saveDialog = new SaveFileDialog();
  332. saveDialog.Filter = "(*.pdf)|*.pdf";
  333. saveDialog.DefaultExt = ".pdf";
  334. saveDialog.OverwritePrompt = true;
  335. if (saveDialog.ShowDialog() == true)
  336. {
  337. pdfDoc.WriteToFilePath(saveDialog.FileName);
  338. }
  339. }
  340. }
  341. }
  342. /// <summary>
  343. /// Save the file in the current path.
  344. /// </summary>
  345. private void SaveFile()
  346. {
  347. if (pdfViewControl != null && pdfViewControl.PDFToolManager != null && pdfViewControl.PDFToolManager.GetDocument() != null)
  348. {
  349. CPDFDocument pdfDoc = pdfViewControl.PDFToolManager.GetDocument();
  350. if (pdfDoc.WriteToLoadedPath())
  351. {
  352. return;
  353. }
  354. SaveFileDialog saveDialog = new SaveFileDialog();
  355. saveDialog.Filter = "(*.pdf)|*.pdf";
  356. saveDialog.DefaultExt = ".pdf";
  357. saveDialog.OverwritePrompt = true;
  358. if (saveDialog.ShowDialog() == true)
  359. {
  360. pdfDoc.WriteToFilePath(saveDialog.FileName);
  361. }
  362. }
  363. }
  364. #endregion
  365. #region Selection changed
  366. private void ViewComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  367. {
  368. if (isFirstLoad)
  369. {
  370. isFirstLoad = false;
  371. return;
  372. }
  373. var item = (sender as ComboBox).SelectedItem as ComboBoxItem;
  374. switch (currentMode)
  375. {
  376. case "Viewer":
  377. break;
  378. case "Page Edit":
  379. ToolBarContainer.Visibility = Visibility.Collapsed;
  380. pageEditControl.ExitPageEdit -= PageEditControl_ExitPageEdit;
  381. pageEditControl.PageMoved -= PageEditControl_PageMoved;
  382. CPDFPageEditBarControl.PageEditEvent -= CPDFPageEditBarControl_PageEditEvent;
  383. FloatPageTool.Visibility = Visibility.Visible;
  384. //pdfViewControl.PDFView.ReloadDocument();
  385. LeftToolPanelButton.IsEnabled = true;
  386. SearchButton.IsEnabled = true;
  387. RightPanelButton.IsEnabled = true;
  388. ViewSettingBtn.IsEnabled = true;
  389. break;
  390. default:
  391. break;
  392. }
  393. if ((string)item.Content == "Viewer")
  394. {
  395. ToolBarContainer.Visibility = Visibility.Collapsed;
  396. PDFGrid.Child = pdfViewControl;
  397. }
  398. else if ((string)item.Content == "Page Edit")
  399. {
  400. ToolBarContainer.Visibility = Visibility.Visible;
  401. if (pageEditControl == null)
  402. {
  403. pageEditControl = new CPDFPageEditControl();
  404. }
  405. pageEditControl.ExitPageEdit += PageEditControl_ExitPageEdit;
  406. pageEditControl.PageMoved += PageEditControl_PageMoved;
  407. CPDFPageEditBarControl.PageEditEvent += CPDFPageEditBarControl_PageEditEvent;
  408. pageEditControl.LoadThumbnails(pdfViewControl);
  409. PDFGrid.Child = pageEditControl;
  410. LeftToolPanelButton.IsChecked = false;
  411. LeftToolPanelButton.IsEnabled = false;
  412. SearchButton.IsEnabled = false;
  413. RightPanelButton.IsChecked = false;
  414. RightPanelButton.IsEnabled = false;
  415. ViewSettingBtn.IsChecked = false;
  416. ViewSettingBtn.IsEnabled = false;
  417. ExpandLeftPanel(false);
  418. ExpandRightPropertyPanel(null, Visibility.Collapsed);
  419. FloatPageTool.Visibility = Visibility.Collapsed;
  420. }
  421. currentMode = (string)item.Content;
  422. }
  423. #endregion
  424. #region Event handle
  425. private void MainWindow_Loaded(object sender, RoutedEventArgs e)
  426. {
  427. BotaSideTool.AddBOTAContent(new []{BOTATools.Thumbnail , BOTATools.Outline , BOTATools.Bookmark , BOTATools.Search});
  428. pdfAnnotationControl = new CPDFAnnotationControl();
  429. LoadDefaultDocument();
  430. }
  431. private void CPDFPageEditBarControl_PageEditEvent(object sender, string e)
  432. {
  433. pageEditControl.PageEdit(e);
  434. }
  435. private void PageEditControl_ExitPageEdit(object sender, EventArgs e)
  436. {
  437. ViewComboBox.SelectedIndex = 0;
  438. }
  439. private void UndoManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
  440. {
  441. OnPropertyChanged(e.PropertyName);
  442. }
  443. private void PageEditControl_PageMoved(object sender, RoutedEventArgs e)
  444. {
  445. if (pdfViewControl == null)
  446. {
  447. return;
  448. }
  449. BotaSideTool.InitWithPDFViewer(pdfViewControl);
  450. }
  451. private void PdfViewer_InfoChanged(object sender, KeyValuePair<string, object> e)
  452. {
  453. if (e.Key == "Zoom")
  454. {
  455. CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)((double)e.Value * 100)));
  456. }
  457. }
  458. #endregion
  459. #region Property changed
  460. protected void OnPropertyChanged([CallerMemberName] string name = null)
  461. {
  462. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
  463. }
  464. #endregion
  465. #region Shortcut
  466. private void CommandBinding_Executed_Open(object sender, ExecutedRoutedEventArgs e)
  467. {
  468. OpenFile();
  469. }
  470. private void CommandBinding_Executed_Save(object sender, ExecutedRoutedEventArgs e)
  471. {
  472. if (CanSave)
  473. {
  474. SaveFile();
  475. }
  476. }
  477. private void CommandBinding_Executed_SaveAs(object sender, ExecutedRoutedEventArgs e)
  478. {
  479. SaveAsFile();
  480. }
  481. private void CommandBinding_Executed_ControlLeftPanel(object sender, ExecutedRoutedEventArgs e)
  482. {
  483. if (currentMode != "Page Edit")
  484. {
  485. LeftToolPanelButton.IsChecked = !LeftToolPanelButton.IsChecked;
  486. ControlLeftPanel();
  487. }
  488. }
  489. private void CommandBinding_Executed_ControlRightPanel(object sender, ExecutedRoutedEventArgs e)
  490. {
  491. if (currentMode != "Page Edit")
  492. {
  493. RightPanelButton.IsChecked = !RightPanelButton.IsChecked;
  494. ControlRightPanel();
  495. }
  496. }
  497. private void CommandBinding_Executed_Bookmark(object sender, ExecutedRoutedEventArgs e)
  498. {
  499. if (currentMode != "Page Edit")
  500. {
  501. ExpandLeftPanel(true);
  502. LeftToolPanelButton.IsChecked = true;
  503. BotaSideTool.SelectBotaTool(BOTATools.Bookmark);
  504. }
  505. }
  506. private void CommandBinding_Executed_Outline(object sender, ExecutedRoutedEventArgs e)
  507. {
  508. if (currentMode != "Page Edit")
  509. {
  510. ExpandLeftPanel(true);
  511. LeftToolPanelButton.IsChecked = true;
  512. BotaSideTool.SelectBotaTool(BOTATools.Outline);
  513. }
  514. }
  515. private void CommandBinding_Executed_Thumbnail(object sender, ExecutedRoutedEventArgs e)
  516. {
  517. if (currentMode != "Page Edit")
  518. {
  519. ExpandLeftPanel(true);
  520. LeftToolPanelButton.IsChecked = true;
  521. BotaSideTool.SelectBotaTool(BOTATools.Thumbnail);
  522. }
  523. }
  524. private void CommandBinding_Executed_Search(object sender, ExecutedRoutedEventArgs e)
  525. {
  526. if (currentMode != "Page Edit")
  527. {
  528. ExpandLeftPanel(true);
  529. LeftToolPanelButton.IsChecked = true;
  530. BotaSideTool.SelectBotaTool(BOTATools.Search);
  531. }
  532. }
  533. private void CommandBinding_Executed_ScaleAdd(object sender, ExecutedRoutedEventArgs e)
  534. {
  535. double newZoom = CheckZoomLevel(pdfViewControl.GetCPDFViewer().GetZoom() + 0.01, true);
  536. pdfViewControl.GetCPDFViewer().SetZoom(newZoom);
  537. }
  538. private void CommandBinding_Executed_ScaleSubtract(object sender, ExecutedRoutedEventArgs e)
  539. {
  540. double newZoom = CheckZoomLevel(pdfViewControl.GetCPDFViewer().GetZoom() - 0.01, false);
  541. pdfViewControl.GetCPDFViewer().SetZoom(newZoom);
  542. }
  543. private void ShowViewSettings()
  544. {
  545. if (ViewSettingBtn != null)
  546. {
  547. if (ViewSettingBtn.IsChecked == true)
  548. {
  549. displayPanel = new CPDFDisplaySettingsControl();
  550. displayPanel.InitWithPDFViewer(pdfViewControl);
  551. PropertyContainer.Child = displayPanel;
  552. PropertyContainer.Visibility = Visibility.Visible;
  553. if ((bool)RightPanelButton.IsChecked)
  554. {
  555. RightPanelButton.IsChecked = false;
  556. }
  557. }
  558. else
  559. {
  560. PropertyContainer.Child = null;
  561. PropertyContainer.Visibility = Visibility.Collapsed;
  562. }
  563. }
  564. }
  565. private void CommandBinding_Executed_DisplaySettings(object sender, ExecutedRoutedEventArgs e)
  566. {
  567. if (currentMode != "Page Edit")
  568. {
  569. ViewSettingBtn.IsChecked = !ViewSettingBtn.IsChecked;
  570. ShowViewSettings();
  571. }
  572. }
  573. private void CommandBinding_Executed_DocumentInfo(object sender, ExecutedRoutedEventArgs e)
  574. {
  575. if (PopupBorder.Visibility != Visibility.Visible)
  576. {
  577. PasswordUI.Visibility = Visibility.Collapsed;
  578. FileInfoUI.Visibility = Visibility.Visible;
  579. FileInfoControl.InitWithPDFViewer(pdfViewControl);
  580. PopupBorder.Visibility = Visibility.Visible;
  581. }
  582. else
  583. {
  584. FileInfoUI.Visibility = Visibility.Collapsed;
  585. PopupBorder.Visibility = Visibility.Collapsed;
  586. }
  587. }
  588. #endregion
  589. }
  590. }