BottomToolContentViewModel.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837
  1. using Prism.Mvvm;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using ComPDFKitViewer.PdfViewer;
  8. using Prism.Commands;
  9. using Prism.Regions;
  10. using System.Windows;
  11. using PDF_Office.Views;
  12. using ComPDFKitViewer;
  13. using System.Windows.Input;
  14. using System.Windows.Controls;
  15. using Prism.Services.Dialogs;
  16. using PDF_Office.CustomControl;
  17. using PDF_Office.Model;
  18. using PDF_Office.ViewModels.BOTA;
  19. using PDF_Office.Views.BOTA;
  20. using PDF_Office.Views.PropertyPanel.AnnotPanel;
  21. using PDF_Office.Views.Tools;
  22. using PDFSettings.Settings;
  23. using PDF_Office.Helper;
  24. using System.IO;
  25. using ImTools;
  26. using PDF_Office.Views.PropertyPanel.ViewModular;
  27. namespace PDF_Office.ViewModels
  28. {
  29. public class BottomToolContentViewModel : BindableBase, INavigationAware
  30. {
  31. #region 文案
  32. private string T_actual;
  33. public string T_Actual
  34. {
  35. get { return T_actual; }
  36. set
  37. {
  38. SetProperty(ref T_actual, value);
  39. }
  40. }
  41. private string T_fitWidth;
  42. public string T_FitWidth
  43. {
  44. get { return T_fitWidth; }
  45. set
  46. {
  47. SetProperty(ref T_fitWidth, value);
  48. }
  49. }
  50. private string T_fitPage;
  51. public string T_FitPage
  52. {
  53. get { return T_fitPage; }
  54. set
  55. {
  56. SetProperty(ref T_fitPage, value);
  57. }
  58. }
  59. private void InitString()
  60. {
  61. T_Actual = App.MainPageLoader.GetString("Zoom_Actual");
  62. T_FitWidth = App.MainPageLoader.GetString("Zoom_FitWidth");
  63. T_FitPage = App.MainPageLoader.GetString("Zoom_FitPage");
  64. }
  65. #endregion 文案
  66. public DelegateCommand Load { get; set; }
  67. public DelegateCommand FirstPageCommand { get; set; }
  68. public DelegateCommand LastPageCommand { get; set; }
  69. public DelegateCommand PrePageCommand { get; set; }
  70. public DelegateCommand NextPageCommand { get; set; }
  71. public DelegateCommand MyPropertyCommand { get; set; }
  72. public DelegateCommand FullScreenCommand { get; set; }
  73. public DelegateCommand ReadModeCommand { get; set; }
  74. public DelegateCommand OpenViewCommand { get; set; }
  75. public DelegateCommand ZoomInCommand { get; set; }
  76. public DelegateCommand ZoomOutCommand { get; set; }
  77. public DelegateCommand SetViewModeCommand { get; set; }
  78. public DelegateCommand OpenFullCommand { get; set; }
  79. public DelegateCommand<object> PageTextKeyDownCommand { get; set; }
  80. public DelegateCommand<object> PageTextPreviewKeyDownCommand { get; set; }
  81. public DelegateCommand<object> SelectionChangedCommand { get; set; }
  82. public DelegateCommand<object> ShowViewModularCommand { get; set; }
  83. /// <summary>
  84. /// 上一个视图
  85. /// </summary>
  86. public DelegateCommand PreViewCommand { get; set; }
  87. /// <summary>
  88. /// 下一个视图
  89. /// </summary>
  90. public DelegateCommand NextViewCommnad { get; set; }
  91. private bool isShowViewModular = false;
  92. /// <summary>
  93. /// 属性栏是否展开
  94. /// </summary>
  95. public bool IsShowViewModular
  96. {
  97. get { return isShowViewModular; }
  98. set
  99. {
  100. SetProperty(ref isShowViewModular, value);
  101. }
  102. }
  103. private bool isSingleView;
  104. public bool IsSingleView
  105. {
  106. get { return isSingleView; }
  107. set
  108. {
  109. SetProperty(ref isSingleView, value);
  110. if (value)
  111. {
  112. SetModeView();
  113. }
  114. }
  115. }
  116. private bool isContinue;
  117. public bool IsContinue
  118. {
  119. get { return isContinue; }
  120. set
  121. {
  122. SetProperty(ref isContinue, value);
  123. SetModeView();
  124. }
  125. }
  126. private bool isDoubleView;
  127. public bool IsDoubleView
  128. {
  129. get { return isDoubleView; }
  130. set
  131. {
  132. SetProperty(ref isDoubleView, value);
  133. if (value)
  134. {
  135. SetModeView();
  136. }
  137. }
  138. }
  139. private bool isBookMode;
  140. public bool IsBookMode
  141. {
  142. get { return isBookMode; }
  143. set
  144. {
  145. SetProperty(ref isBookMode, value);
  146. if (value)
  147. {
  148. SetModeView();
  149. }
  150. }
  151. }
  152. private int pageCount;
  153. public int PageCount
  154. {
  155. get { return pageCount; }
  156. set
  157. {
  158. SetProperty(ref pageCount, value);
  159. }
  160. }
  161. private int currentPage;
  162. public int CurrentPage
  163. {
  164. get { return currentPage; }
  165. set
  166. {
  167. SetProperty(ref currentPage, value);
  168. }
  169. }
  170. private double currenZoom;
  171. public double CurrentZoom
  172. {
  173. get { return currenZoom; }
  174. set { SetProperty(ref currenZoom, value); }
  175. }
  176. private int selectedIndex;
  177. public int SelectedIndex
  178. {
  179. get { return selectedIndex; }
  180. set
  181. {
  182. SetProperty(ref selectedIndex, value);
  183. }
  184. }
  185. private bool rightPanelEnable = true;
  186. public bool RightPanelEnable
  187. {
  188. get { return rightPanelEnable; }
  189. set
  190. {
  191. SetProperty(ref rightPanelEnable, value);
  192. }
  193. }
  194. private bool isPreEnable = false;
  195. /// <summary>
  196. /// 前进是否启用
  197. /// </summary>
  198. public bool IsPreEnable
  199. {
  200. get { return isPreEnable; }
  201. set
  202. {
  203. SetProperty(ref isPreEnable, value);
  204. }
  205. }
  206. private bool isNextEnable = false;
  207. public bool IsNextEnable
  208. {
  209. get { return isNextEnable; }
  210. set
  211. {
  212. SetProperty(ref isNextEnable, value);
  213. }
  214. }
  215. private Stack<int> UndoStack = new Stack<int>();
  216. private Stack<int> RedoStack = new Stack<int>();
  217. public CPDFViewer PDFViewer { get; set; }
  218. public ViewContentViewModel ViewContentViewModel { get; set; }
  219. public OpenFileInfo OpenFileInfo = null;
  220. /// <summary>
  221. /// 来自undo redo方法的跳页 不计入栈
  222. /// </summary>
  223. private bool isFromMethod = false;
  224. /// <summary>
  225. /// 记录上一个页面索引值
  226. /// </summary>
  227. private int oldPageIndex = 0;
  228. private IRegionManager region;
  229. private IDialogService dialogs;
  230. public BottomToolContentViewModel(IRegionManager regionManager, IDialogService dialogService)
  231. {
  232. region = regionManager;
  233. dialogs = dialogService;
  234. PrePageCommand = new DelegateCommand(GoPrePage, CanPrePageExcute).ObservesProperty(() => CurrentPage);
  235. NextPageCommand = new DelegateCommand(GoNextPage, CanNextPageExcute).ObservesProperty(() => CurrentPage);
  236. FirstPageCommand = new DelegateCommand(GoFirstPage, CanPrePageExcute).ObservesProperty(() => CurrentPage);
  237. LastPageCommand = new DelegateCommand(GoLastPage, CanNextPageExcute).ObservesProperty(() => CurrentPage);
  238. ZoomInCommand = new DelegateCommand(ZoomIn, CanZoomIn).ObservesProperty(() => CurrentZoom);
  239. ZoomOutCommand = new DelegateCommand(ZoomOut, CanZoomOut).ObservesProperty(() => CurrentZoom);
  240. SetViewModeCommand = new DelegateCommand(SetModeView);
  241. PageTextKeyDownCommand = new DelegateCommand<object>(PageNumText_KeyDown);
  242. PageTextPreviewKeyDownCommand = new DelegateCommand<object>(PageNumText_PreviewKeyDown);
  243. SelectionChangedCommand = new DelegateCommand<object>(SelectionChangedEvent);
  244. ShowViewModularCommand = new DelegateCommand<object>(ShowViewModularEvent);
  245. PreViewCommand = new DelegateCommand(undo);
  246. NextViewCommnad = new DelegateCommand(redo);
  247. InitString();
  248. }
  249. private void undo()
  250. {
  251. RedoStack.Push(PDFViewer.CurrentIndex);
  252. IsNextEnable = true;
  253. int index = UndoStack.Pop();
  254. PDFViewer.GoToPage(index);
  255. if (UndoStack.Count <= 0)
  256. {
  257. IsPreEnable = false;
  258. }
  259. isFromMethod = true;
  260. }
  261. private void redo()
  262. {
  263. App.Current.Dispatcher.Invoke(() =>
  264. {
  265. UndoStack.Push(PDFViewer.CurrentIndex);
  266. IsPreEnable = true;
  267. int index = RedoStack.Pop();
  268. PDFViewer.GoToPage(index);
  269. if (RedoStack.Count <= 0)
  270. {
  271. IsNextEnable = false;
  272. }
  273. });
  274. isFromMethod = true;
  275. }
  276. private void ShowViewModularEvent(object obj)
  277. {
  278. ViewContentViewModel.IsPropertyOpen = true;
  279. if (region.Regions.ContainsRegionWithName(ViewContentViewModel.PropertyRegionName))
  280. {
  281. var views = region.Regions[ViewContentViewModel.PropertyRegionName].Views;
  282. var item = views.FindFirst(p => p is ViewModularContent);
  283. if (item == null)
  284. {
  285. NavigationParameters param = new NavigationParameters();
  286. param.Add(ParameterNames.PDFViewer, PDFViewer);
  287. param.Add(ParameterNames.BottomToolContentViewModel, this);
  288. region.RequestNavigate(RegionNames.PropertyRegionName, "ViewModularContent", param);
  289. }
  290. else
  291. {
  292. if (item is ViewModularContent viewModular)
  293. {
  294. var contentRegion = region.Regions[ViewContentViewModel.PropertyRegionName];
  295. contentRegion.Activate(viewModular);
  296. }
  297. }
  298. }
  299. //if (ViewContentViewModel.IsPropertyOpen == false)
  300. //{
  301. // ViewContentViewModel.IsPropertyOpen = true;
  302. // NavigationParameters param = new NavigationParameters();
  303. // param.Add(ParameterNames.PDFViewer, PDFViewer);
  304. // param.Add(ParameterNames.BottomToolContentViewModel, this);
  305. // region.RequestNavigate(RegionNames.PropertyRegionName, "ViewModularContent", param);
  306. // //if (region.Regions.ContainsRegionWithName(ViewContentViewModel.PropertyRegionName))
  307. // //{
  308. // // var views = region.Regions[ViewContentViewModel.PropertyRegionName].Views;
  309. // // foreach (var item in views)
  310. // // {
  311. // // if (item is LinkAnnotProperty linkAnnotProperty)
  312. // // {
  313. // // var contentRegion = region.Regions[ViewContentViewModel.PropertyRegionName];
  314. // // contentRegion.Remove(item);
  315. // // break;
  316. // // }
  317. // // }
  318. // //}
  319. //}
  320. //else
  321. //{
  322. //}
  323. IsShowViewModular = ViewContentViewModel.IsPropertyOpen;
  324. }
  325. private void SelectionChangedEvent(object e)
  326. {
  327. var args = e as SelectionChangedEventArgs;
  328. if (args != null)
  329. {
  330. if (SelectedIndex <= 2)
  331. {
  332. switch (SelectedIndex)
  333. {
  334. case 0:
  335. PDFViewer.ChangeFitMode(FitMode.FitSize);
  336. OpenFileInfo.LastFitMode = FitMode.FitSize;
  337. break;
  338. case 1:
  339. PDFViewer.ChangeFitMode(FitMode.FitWidth);
  340. OpenFileInfo.LastFitMode = FitMode.FitWidth;
  341. break;
  342. case 2:
  343. PDFViewer.ChangeFitMode(FitMode.FitHeight);
  344. OpenFileInfo.LastFitMode = FitMode.FitHeight;
  345. break;
  346. default:
  347. break;
  348. }
  349. }
  350. else
  351. {
  352. if (args.AddedItems[0] is ComboBoxItem)
  353. {
  354. if ((args.AddedItems[0] as ComboBoxItem).Tag != null)
  355. {
  356. PDFViewer.Zoom(Convert.ToDouble((args.AddedItems[0] as ComboBoxItem).Tag.ToString()) / 100.0);
  357. }
  358. }
  359. }
  360. }
  361. }
  362. private void PageNumText_PreviewKeyDown(object e)
  363. {
  364. var args = e as KeyEventArgs;
  365. if (args != null)
  366. {
  367. //显示文本框输入内容
  368. List<Key> NumberKeys = new List<Key>() { Key.D0,Key.D1,Key.D2,Key.D3,Key.D4,Key.D5,Key.D6,Key.D7,Key.D8,Key.D9,Key.NumPad0,Key.NumPad1,Key.NumPad2,
  369. Key.NumPad3,Key.NumPad4,Key.NumPad5,Key.NumPad6,Key.NumPad7,Key.NumPad8,Key.NumPad9,Key.Delete,Key.Back,Key.Enter,Key.Right,Key.Left};
  370. if (!NumberKeys.Contains(args.Key))
  371. {
  372. args.Handled = true;
  373. }
  374. }
  375. }
  376. private void PageNumText_KeyDown(object e)
  377. {
  378. if (!(e is KeyEventArgs))
  379. return;
  380. //回车提交输入
  381. if ((e as KeyEventArgs).Key == System.Windows.Input.Key.Enter)
  382. {
  383. int pagenum = 0;
  384. string text = ((e as KeyEventArgs).OriginalSource as TextBox).Text.ToString();
  385. char[] chs = { ' ', '/', '\\' };//字符截取 拒止非法输入
  386. int i = text.LastIndexOfAny(chs);
  387. if (i > 0)
  388. text = text.Substring(0, i - 1);
  389. if (!int.TryParse(text, out pagenum))
  390. {
  391. CurrentPage = PDFViewer.Document.PageCount;
  392. ((e as KeyEventArgs).OriginalSource as TextBox).Text = PDFViewer.Document.PageCount.ToString();
  393. return;
  394. }
  395. if (pagenum < 1)
  396. pagenum = 1;
  397. else if (pagenum > PDFViewer.Document.PageCount)
  398. pagenum = PDFViewer.Document.PageCount;
  399. PDFViewer.GoToPage(pagenum - 1);
  400. CurrentPage = pagenum;
  401. ((e as KeyEventArgs).OriginalSource as TextBox).Text = pagenum.ToString();
  402. }
  403. }
  404. private void GoPrePage()
  405. {
  406. if (PDFViewer != null)
  407. {
  408. PDFViewer.GoToPage(PDFViewer.CurrentIndex - 1);
  409. }
  410. }
  411. private bool CanPrePageExcute()
  412. {
  413. if (PDFViewer != null)
  414. {
  415. if (PDFViewer.CurrentIndex <= 0)
  416. return false;
  417. else
  418. return true;
  419. }
  420. return false;
  421. }
  422. private void GoNextPage()
  423. {
  424. if (PDFViewer != null)
  425. {
  426. PDFViewer.GoToPage(PDFViewer.CurrentIndex + 1);
  427. //双页模式 一次性跳两页
  428. if (((int)PDFViewer.ModeView > 2))
  429. {
  430. PDFViewer.GoToPage(PDFViewer.CurrentIndex + 2);
  431. }
  432. }
  433. }
  434. private bool CanNextPageExcute()
  435. {
  436. if (PDFViewer != null)
  437. {
  438. if (PDFViewer.CurrentIndex >= PDFViewer.Document.PageCount - 1)
  439. return false;
  440. else
  441. return true;
  442. }
  443. return false;
  444. }
  445. private void GoFirstPage()
  446. {
  447. if (PDFViewer != null)
  448. {
  449. PDFViewer.GoToPage(0);
  450. }
  451. }
  452. private void GoLastPage()
  453. {
  454. if (PDFViewer != null)
  455. {
  456. PDFViewer.GoToPage(PDFViewer.Document.PageCount - 1);
  457. }
  458. }
  459. private void ZoomIn()
  460. {
  461. double zoom = SetPageZoomFactor(true);
  462. PDFViewer.Zoom(zoom / 100);
  463. }
  464. private void ZoomOut()
  465. {
  466. double zoom = SetPageZoomFactor(false);
  467. PDFViewer.Zoom(zoom / 100);
  468. }
  469. private double SetPageZoomFactor(bool flag)
  470. {
  471. double zoom = PDFViewer.ZoomFactor * 100;
  472. if (flag)
  473. {
  474. if (zoom >= 25 && zoom <= 300)
  475. {
  476. zoom = zoom + 25;
  477. }
  478. else if (zoom >= 301 && zoom <= 1000)
  479. {
  480. zoom = zoom + 40;
  481. }
  482. else if (zoom >= 1001 && zoom <= 10000)
  483. {
  484. zoom = zoom + 100;
  485. }
  486. }
  487. else
  488. {
  489. if (zoom >= 25 && zoom <= 300)
  490. {
  491. zoom = zoom - 25;
  492. }
  493. else if (zoom >= 301 && zoom <= 1000)
  494. {
  495. zoom = zoom - 40;
  496. }
  497. else if (zoom >= 1001 && zoom <= 10000)
  498. {
  499. zoom = zoom - 100;
  500. }
  501. }
  502. if (zoom < 25)
  503. {
  504. zoom = 25;
  505. }
  506. if (zoom > 10000)
  507. {
  508. zoom = 10000;
  509. }
  510. return zoom;
  511. }
  512. private bool CanZoomIn()
  513. {
  514. if (PDFViewer != null)
  515. {
  516. if (PDFViewer.ZoomFactor * 100 >= 10000)
  517. return false;
  518. else
  519. return true;
  520. }
  521. return false;
  522. }
  523. private bool CanZoomOut()
  524. {
  525. if (PDFViewer != null)
  526. {
  527. if (PDFViewer.ZoomFactor * 100 <= 25)
  528. return false;
  529. else
  530. return true;
  531. }
  532. return false;
  533. }
  534. public void PDFViewer_InfoChanged(object sender, KeyValuePair<string, object> e)
  535. {
  536. if (e.Key == "PageNum")
  537. {
  538. RenderData renderData = e.Value as RenderData;
  539. if (renderData != null)
  540. {
  541. CurrentPage = renderData.PageIndex;
  542. PageCount = PDFViewer.Document.PageCount;
  543. if (!renderData.IsMouseWheel && !isFromMethod)
  544. {
  545. UndoStack.Push(oldPageIndex);
  546. RedoStack.Clear();
  547. IsNextEnable = false;
  548. IsPreEnable = true;
  549. }
  550. isFromMethod = false;
  551. }
  552. oldPageIndex = renderData.PageIndex - 1;
  553. }
  554. if (e.Key == "ViewMode")
  555. {
  556. GetModeView((ViewMode)e.Value);
  557. }
  558. if (e.Key == "Zoom")
  559. {
  560. CurrentZoom = (double)e.Value * 100;
  561. SelectedIndex = -1;
  562. }
  563. if (OpenFileInfo != null)
  564. {
  565. if (OpenFileInfo.LastFitMode != PDFViewer.ModeFit)
  566. {
  567. OpenFileInfo.LastFitMode = PDFViewer.ModeFit;
  568. }
  569. if (PDFViewer.ModeFit == FitMode.FitFree)
  570. {
  571. if (OpenFileInfo.LastZoom != PDFViewer.ZoomFactor)
  572. {
  573. OpenFileInfo.LastZoom = PDFViewer.ZoomFactor;
  574. }
  575. }
  576. if (OpenFileInfo.LastPageIndex != PDFViewer.CurrentIndex)
  577. {
  578. OpenFileInfo.LastPageIndex = PDFViewer.CurrentIndex;
  579. }
  580. SettingHelper.SetFileInfo(OpenFileInfo);
  581. }
  582. }
  583. private void ViewContentViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  584. {
  585. if (e.PropertyName == "OCRContentVisible")
  586. {
  587. if (ViewContentViewModel.OCRContentVisible == Visibility.Visible)
  588. {
  589. RightPanelEnable = false;
  590. }
  591. else
  592. {
  593. RightPanelEnable = true;
  594. }
  595. }
  596. }
  597. private void GetModeView(ViewMode mode)
  598. {
  599. if ((int)mode % 2 == 0)
  600. {
  601. if (!IsContinue)
  602. {
  603. IsContinue = true;
  604. }
  605. }
  606. else
  607. {
  608. if (IsContinue)
  609. {
  610. IsContinue = false;
  611. }
  612. }
  613. if ((int)mode <= 2)
  614. {
  615. if (!isSingleView)
  616. {
  617. IsSingleView = true;
  618. }
  619. }
  620. else if ((int)mode <= 4)
  621. {
  622. if (!isDoubleView)
  623. {
  624. IsDoubleView = true;
  625. }
  626. }
  627. else
  628. {
  629. if (!isBookMode)
  630. {
  631. IsBookMode = true;
  632. }
  633. }
  634. }
  635. public void SetModeView()
  636. {
  637. if (PDFViewer != null)
  638. {
  639. if (IsContinue)
  640. {
  641. if (IsSingleView)
  642. {
  643. PDFViewer.ChangeViewMode(ViewMode.SingleContinuous);
  644. }
  645. else if (IsDoubleView)
  646. {
  647. PDFViewer.ChangeViewMode(ViewMode.DoubleContinuous);
  648. }
  649. else
  650. {
  651. PDFViewer.ChangeViewMode(ViewMode.BookContinuous);
  652. }
  653. }
  654. else
  655. {
  656. if (IsSingleView)
  657. {
  658. PDFViewer.ChangeViewMode(ViewMode.Single);
  659. }
  660. else if (IsDoubleView)
  661. {
  662. PDFViewer.ChangeViewMode(ViewMode.Double);
  663. }
  664. else
  665. {
  666. PDFViewer.ChangeViewMode(ViewMode.Book);
  667. }
  668. }
  669. }
  670. SaveMode(PDFViewer.ModeView);
  671. }
  672. private void SaveMode(object modeView)
  673. {
  674. OpenFileInfo fileInfo = SettingHelper.GetFileInfo(PDFViewer.Document.FilePath);
  675. if (fileInfo != null)
  676. {
  677. if (modeView is SplitMode)
  678. {
  679. fileInfo.LastSplitMode = PDFViewer.Mode;
  680. }
  681. else if (modeView is ViewMode)
  682. {
  683. fileInfo.LastViewMode = PDFViewer.ModeView;
  684. }
  685. else if (modeView is bool)
  686. {
  687. fileInfo.LastPageSpace = (bool)modeView;
  688. }
  689. SettingHelper.SetFileInfo(fileInfo);
  690. }
  691. }
  692. #region Navigation
  693. public void OnNavigatedTo(NavigationContext navigationContext)
  694. {
  695. var viewContentViewModel = navigationContext.Parameters[ParameterNames.ViewContentViewModel] as ViewContentViewModel;
  696. if (viewContentViewModel != null)
  697. {
  698. this.ViewContentViewModel = viewContentViewModel;
  699. IsShowViewModular = viewContentViewModel.IsPropertyOpen;
  700. viewContentViewModel.PropertyChanged -= ViewContentViewModel_PropertyChanged;
  701. viewContentViewModel.PropertyChanged += ViewContentViewModel_PropertyChanged;
  702. }
  703. var pdfview = navigationContext.Parameters[ParameterNames.PDFViewer] as CPDFViewer;
  704. if (pdfview != null)
  705. {
  706. if (ViewContentViewModel.OpenFileInfo != null)
  707. {
  708. OpenFileInfo = ViewContentViewModel.OpenFileInfo;
  709. }
  710. //获取页面设置等信息
  711. PDFViewer = pdfview;
  712. oldPageIndex = pdfview.CurrentIndex;
  713. PageCount = PDFViewer.Document.PageCount;
  714. GetModeView(PDFViewer.ModeView);
  715. CurrentPage = PDFViewer.CurrentIndex + 1;
  716. CurrentZoom = PDFViewer.ZoomFactor * 100;
  717. PDFViewer.InfoChanged += PDFViewer_InfoChanged;
  718. }
  719. }
  720. public bool IsNavigationTarget(NavigationContext navigationContext)
  721. {
  722. return true;
  723. }
  724. public void OnNavigatedFrom(NavigationContext navigationContext)
  725. {
  726. }
  727. #endregion Navigation
  728. }
  729. }