MainWindow.xaml.cs 23 KB

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