MainWindow.xaml.cs 23 KB

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