ViewContentViewModel.cs 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357
  1. using Microsoft.Win32;
  2. using Prism.Commands;
  3. using Prism.Mvvm;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using ComPDFKitViewer.PdfViewer;
  10. using Prism.Regions;
  11. using DryIoc;
  12. using System.Diagnostics;
  13. using Prism.Services.Dialogs;
  14. using PDF_Office.CustomControl;
  15. using PDF_Office.Model;
  16. using System.Windows;
  17. using System.Windows.Controls;
  18. using System.IO;
  19. using PDFSettings;
  20. using ComPDFKitViewer.AnnotEvent;
  21. using PDF_Office.ViewModels.Tools;
  22. using PDF_Office.Views;
  23. using Prism.Events;
  24. using PDF_Office.EventAggregators;
  25. using PDF_Office.Views.EditTools.Background;
  26. using PDF_Office.Views.Dialog;
  27. using PDF_Office.Helper;
  28. using System.Security.Policy;
  29. using System.Windows.Documents;
  30. namespace PDF_Office.ViewModels
  31. {
  32. public class ViewContentViewModel : BindableBase, INavigationAware
  33. {
  34. #region 属性、变量
  35. public CPDFViewer PDFViewer { get; set; }
  36. private MainContentViewModel mainViewModel { get; set; }
  37. public IRegionManager region;
  38. public IDialogService dialogs;
  39. public IEventAggregator events;
  40. public bool IsCreateLink { get => isCreateLink; set => isCreateLink = value; }
  41. public string ViwerRegionName { get; set; }
  42. /// <summary>
  43. /// 分屏视图的region名称
  44. /// </summary>
  45. public string SplitViewerRegionName { get; set; }
  46. /// <summary>
  47. /// OCR视图名称
  48. /// </summary>
  49. public string OCRViewerRegionName { get; set; }
  50. public string BOTARegionName { get; set; }
  51. public string PropertyRegionName { get; set; }
  52. public string ToolContentRegionName { get; set; }
  53. public string ToolsBarContentRegionName { get; set; }
  54. public string ReadModeRegionName { get; set; }
  55. public string ConverterBarContentRegionName { get; set; }
  56. public string TextEditContentRegionName { get; set; }
  57. public string BackgroundContentRegionName { get; set; }
  58. private Visibility readModelTip = Visibility.Collapsed;
  59. public Visibility ReadModelTip
  60. {
  61. get { return readModelTip; }
  62. set
  63. {
  64. SetProperty(ref readModelTip, value);
  65. }
  66. }
  67. /// <summary>
  68. /// 底部工具栏 RegionName
  69. /// </summary>
  70. public string BottomToolRegionName { get; set; }
  71. private bool _isInPageEdit = false;
  72. /// <summary>
  73. /// 是否处于页面编辑模式,用于执行undo redo 的具体操作
  74. /// </summary>
  75. public bool isInPageEdit
  76. {
  77. get { return _isInPageEdit; }
  78. set
  79. {
  80. _isInPageEdit = value;
  81. if (!value)
  82. {
  83. CanRedo = PDFViewer.UndoManager.CanRedo;
  84. CanUndo = PDFViewer.UndoManager.CanUndo;
  85. }
  86. }
  87. }
  88. public Action PageEditUndo { get; set; }
  89. public Action PageEditRedo { get; set; }
  90. /// <summary>
  91. ///工具条
  92. ///0:收起
  93. ///40:显示
  94. /// </summary>
  95. private int toolRowHeight = 40;
  96. public int ToolRowHeight
  97. {
  98. get { return toolRowHeight; }
  99. set
  100. {
  101. SetProperty(ref toolRowHeight, value);
  102. }
  103. }
  104. /// <summary>
  105. /// 水印,背景侧边栏宽度
  106. /// 0:收起
  107. /// 260:显示
  108. /// </summary>
  109. private int propertyColumnWidth = 0;
  110. public int PropertyColumnWidth
  111. {
  112. get { return propertyColumnWidth; }
  113. set
  114. {
  115. SetProperty(ref propertyColumnWidth, value);
  116. }
  117. }
  118. private int gridToolRow = 1;
  119. /// <summary>
  120. /// 控制ToolContent的Row
  121. /// </summary>
  122. public int GridToolRow
  123. {
  124. get { return gridToolRow; }
  125. set
  126. {
  127. SetProperty(ref gridToolRow, value);
  128. }
  129. }
  130. private int gridToolRowSpan = 3;
  131. /// <summary>
  132. /// 控制ToolContent的RowSpan
  133. /// </summary>
  134. public int GridToolRowSpan
  135. {
  136. get { return gridToolRowSpan; }
  137. set
  138. {
  139. SetProperty(ref gridToolRowSpan, value);
  140. }
  141. }
  142. private Visibility toolContentVisible = Visibility.Collapsed;
  143. /// <summary>
  144. /// 控制Content的显示 用于显示水印、贝茨码、密文等功能模块
  145. /// 留意:显示前需要先注入内容、设置好行和跨行数
  146. /// </summary>
  147. public Visibility ToolContentVisible
  148. {
  149. get { return toolContentVisible; }
  150. set
  151. {
  152. SetProperty(ref toolContentVisible, value);
  153. }
  154. }
  155. private Visibility gridVisibility = Visibility.Visible;
  156. /// <summary>
  157. /// 是否正在加载中
  158. /// </summary>
  159. public Visibility GridVisibility
  160. {
  161. get { return gridVisibility; }
  162. set
  163. {
  164. SetProperty(ref gridVisibility, value);
  165. }
  166. }
  167. private Visibility isLoading = Visibility.Collapsed;
  168. private Visibility ocrContentVisible = Visibility.Collapsed;
  169. public Visibility OCRContentVisible
  170. {
  171. get { return ocrContentVisible; }
  172. set
  173. {
  174. SetProperty(ref ocrContentVisible, value);
  175. }
  176. }
  177. /// <summary>
  178. /// 是否正在加载中
  179. /// </summary>
  180. public Visibility IsLoading
  181. {
  182. get { return isLoading; }
  183. set
  184. {
  185. SetProperty(ref isLoading, value);
  186. }
  187. }
  188. private Visibility converterBarContentVisible = Visibility.Collapsed;
  189. private Visibility toolsbarContentVisible = Visibility.Collapsed;
  190. /// <summary>
  191. /// 控制ToolsBarContent的显示
  192. /// 留意:显示前需要先注入内容、设置好行和跨行数
  193. /// </summary>
  194. public Visibility ConverterBarContentVisible
  195. {
  196. get { return converterBarContentVisible; }
  197. set
  198. {
  199. SetProperty(ref converterBarContentVisible, value);
  200. }
  201. }
  202. private Visibility toolsBarContentVisible = Visibility.Collapsed;
  203. /// <summary>
  204. /// 控制ToolsBarContent的显示
  205. /// 留意:显示前需要先注入内容、设置好行和跨行数
  206. /// </summary>
  207. public Visibility ToolsBarContentVisible
  208. {
  209. get { return toolsBarContentVisible; }
  210. set
  211. {
  212. SetProperty(ref toolsBarContentVisible, value);
  213. }
  214. }
  215. private Visibility textEditToolContentVisible = Visibility.Collapsed;
  216. /// <summary>
  217. /// 控制ToolsBarContent的显示
  218. /// 留意:显示前需要先注入内容、设置好行和跨行数
  219. /// </summary>
  220. public Visibility TextEditToolContentVisible
  221. {
  222. get { return textEditToolContentVisible; }
  223. set
  224. {
  225. SetProperty(ref textEditToolContentVisible, value);
  226. }
  227. }
  228. private bool isPorpertyOpen = false;
  229. /// <summary>
  230. /// 属性栏是否展开
  231. /// </summary>
  232. public bool IsPropertyOpen
  233. {
  234. get { return isPorpertyOpen; }
  235. set
  236. {
  237. SetProperty(ref isPorpertyOpen, value);
  238. }
  239. }
  240. private Visibility isReadMode = Visibility.Visible;
  241. /// <summary>
  242. ///是否为阅读模式
  243. /// </summary>
  244. public Visibility IsReadMode
  245. {
  246. get { return isReadMode; }
  247. set
  248. {
  249. SetProperty(ref isReadMode, value);
  250. }
  251. }
  252. private bool canSave;
  253. /// <summary>
  254. /// 是否可以保存
  255. /// </summary>
  256. public bool CanSave
  257. {
  258. get { return canSave; }
  259. set
  260. {
  261. SetProperty(ref canSave, value);
  262. }
  263. }
  264. private bool canUndo;
  265. /// <summary>
  266. /// 是否可以进行Undo
  267. /// </summary>
  268. public bool CanUndo
  269. {
  270. get { return canUndo; }
  271. set
  272. {
  273. SetProperty(ref canUndo, value);
  274. }
  275. }
  276. private bool canRedo;
  277. /// <summary>
  278. /// 是否可以进行Redo
  279. /// </summary>
  280. public bool CanRedo
  281. {
  282. get { return canRedo; }
  283. set
  284. {
  285. SetProperty(ref canRedo, value);
  286. }
  287. }
  288. private GridLength botaWidth = new GridLength(48);
  289. /// <summary>
  290. /// BOTA栏的宽度
  291. /// </summary>
  292. public GridLength BOTAWidth
  293. {
  294. get { return botaWidth; }
  295. set
  296. {
  297. SetProperty(ref botaWidth, value);
  298. if (botaWidth.Value <= 48)
  299. {
  300. OpenBOTA = false;
  301. }
  302. }
  303. }
  304. private int selectedIndex;
  305. /// <summary>
  306. /// 工具栏选中项的索引
  307. /// </summary>
  308. public int TabSelectedIndex
  309. {
  310. get { return selectedIndex; }
  311. set
  312. {
  313. SetProperty(ref selectedIndex, value);
  314. }
  315. }
  316. private bool openBOTA = false;
  317. /// <summary>
  318. /// 是否展开BOTA
  319. /// </summary>
  320. public bool OpenBOTA
  321. {
  322. get { return openBOTA; }
  323. set
  324. {
  325. openBOTA = value;
  326. if (openBOTA && BOTAWidth.Value <= 48)
  327. {
  328. BOTAWidth = new GridLength(256);
  329. }
  330. }
  331. }
  332. private Dictionary<string, string> regionNameByTabItem;
  333. private Dictionary<string, string> barContentByTabItem;
  334. private string previousBar = "";
  335. public string CurrentBar = "";
  336. public string unicode = null;
  337. /// <summary>
  338. /// 用来避免重复触发导航事件的标志符
  339. /// </summary>
  340. private bool isOpenFile = false;
  341. /// <summary>
  342. /// 鼠标滚轮缩放的缩放值
  343. /// </summary>
  344. private double[] zoomLevel = { 1.00f, 10, 25, 50, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
  345. /// <summary>
  346. /// 注释-链接,提示语
  347. /// </summary>
  348. private Visibility linkAnnotTipVisibility = Visibility.Collapsed;
  349. public Visibility LinkAnnotTipVisibility
  350. {
  351. get { return linkAnnotTipVisibility; }
  352. set
  353. {
  354. SetProperty(ref linkAnnotTipVisibility, value);
  355. }
  356. }
  357. private string linkAnnotTipText = "Please use the scroll bar, thumbnail tool to locate the target page, click or box the area to select the target range";
  358. private bool isCreateLink = false;
  359. public string LinkAnnotTipText
  360. {
  361. get { return linkAnnotTipText; }
  362. set
  363. {
  364. SetProperty(ref linkAnnotTipText, value);
  365. }
  366. }
  367. #endregion 属性、变量
  368. #region 命令
  369. public DelegateCommand LoadFile { get; set; }
  370. public DelegateCommand Load { get; set; }
  371. public DelegateCommand<object> TabControlSelectionChangedCommand { get; set; }
  372. public DelegateCommand SaveFile { get; set; }
  373. public DelegateCommand SaveAsFile { get; set; }
  374. public DelegateCommand UndoCommand { get; set; }
  375. public DelegateCommand RedoCommand { get; set; }
  376. public DelegateCommand<object> MenuEnterReadMode { get; set; }
  377. public DelegateCommand PrintCommand { get; set; }
  378. public DelegateCommand SettingsCommand { get; set; }
  379. public DelegateCommand ShareCommand { get; set; }
  380. public DelegateCommand<object> CreateLinkCommand { get; set; }
  381. public DelegateCommand PropertyCommand { get; set; }
  382. public DelegateCommand ShowInFolderCommand { get; set; }
  383. #endregion 命令
  384. public ViewContentViewModel(IRegionManager regionManager, IDialogService dialogService, IEventAggregator eventAggregator)
  385. {
  386. region = regionManager;
  387. dialogs = dialogService;
  388. events = eventAggregator;
  389. unicode = App.mainWindowViewModel.SelectedItem.Unicode;
  390. LoadFile = new DelegateCommand(loadFile);
  391. Load = new DelegateCommand(LoadControl);
  392. SaveFile = new DelegateCommand(() => { saveFile(); }, CanSaveExcute).ObservesProperty(() => CanSave);
  393. SaveAsFile = new DelegateCommand(() => { saveAsFile(); });
  394. UndoCommand = new DelegateCommand(Undo);
  395. RedoCommand = new DelegateCommand(Redo);
  396. ShareCommand = new DelegateCommand(share);
  397. PropertyCommand = new DelegateCommand(property);
  398. ShowInFolderCommand = new DelegateCommand(ShowInFolder);
  399. TabControlSelectionChangedCommand = new DelegateCommand<object>(TabControlSelectonChangedEvent);
  400. ViwerRegionName = RegionNames.ViwerRegionName;
  401. SplitViewerRegionName = RegionNames.SplitScreenViewRegionName;
  402. BOTARegionName = RegionNames.BOTARegionName;
  403. PropertyRegionName = RegionNames.PropertyRegionName;
  404. BottomToolRegionName = RegionNames.BottomToolRegionName;
  405. ReadModeRegionName = RegionNames.ReadModeRegionName;
  406. MenuEnterReadMode = new DelegateCommand<object>(MenuEnterReadModeEvent);
  407. PrintCommand = new DelegateCommand(ShowPrintDialog);
  408. SettingsCommand = new DelegateCommand(SettingsEvent);
  409. CreateLinkCommand = new DelegateCommand<object>(CreateLinkEvent);
  410. //未显示时无法注册上Region名称
  411. ToolContentVisible = Visibility.Visible;
  412. ToolsBarContentVisible = Visibility.Visible;
  413. OCRContentVisible = Visibility.Visible;
  414. OCRViewerRegionName = RegionNames.OCRViewerRegionName;
  415. ToolContentRegionName = Guid.NewGuid().ToString();
  416. ToolsBarContentRegionName = Guid.NewGuid().ToString();
  417. ConverterBarContentRegionName = Guid.NewGuid().ToString();
  418. TextEditContentRegionName = Guid.NewGuid().ToString();
  419. ToolContentVisible = Visibility.Collapsed;
  420. ToolsBarContentVisible = Visibility.Collapsed;
  421. OCRContentVisible = Visibility.Collapsed;
  422. regionNameByTabItem = new Dictionary<string, string>();
  423. barContentByTabItem = new Dictionary<string, string>();
  424. InitialregionNameByTabItem(ref regionNameByTabItem);
  425. InitialbarContentByTabItem(ref barContentByTabItem);
  426. eventAggregator.GetEvent<EnterSelectedEditToolEvent>().Subscribe(EnterEditTools, e => e.Unicode == unicode);
  427. eventAggregator.GetEvent<CloseEditToolEvent>().Subscribe(CloseEditTool, e => e.Unicode == unicode);
  428. //TODO:根据缓存 选择用户上次选择的菜单
  429. EnterSelectedBar("TabItemAnnotation");
  430. }
  431. /// <summary>
  432. /// 右键菜单创建链接
  433. /// </summary>
  434. /// <param name="obj"></param>
  435. private void CreateLinkEvent(object obj)
  436. {
  437. if (obj is object[] objArry)
  438. {
  439. if (objArry[0] is AnnotToolContentViewModel toolContentViewModel && objArry[1] is AnnotCommandArgs annotCommand)
  440. {
  441. LinkAnnotArgs linkArgs = new LinkAnnotArgs();
  442. linkArgs.URI = string.Empty;
  443. linkArgs.LinkType = LINK_TYPE.GOTO;
  444. linkArgs.PageIndex = annotCommand.PageIndex;
  445. //linkArgs.InvokeLinkSaveCalled(this, EventArgs.Empty);
  446. this.IsCreateLink = true;
  447. AnnotHandlerEventArgs annotArgs = toolContentViewModel.GetLink(linkArgs);
  448. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  449. PDFViewer.SetToolParam(annotArgs);
  450. this.IsPropertyOpen = true;
  451. }
  452. }
  453. }
  454. private void ShowInFolder()
  455. {
  456. CommonHelper.ShowFileBrowser(PDFViewer.Document.FilePath);
  457. }
  458. private void property()
  459. {
  460. DialogParameters valuePairs = new DialogParameters();
  461. valuePairs.Add(ParameterNames.PDFDocument, PDFViewer.Document);
  462. dialogs.ShowDialog(DialogNames.PropertyDialog, valuePairs, null);
  463. }
  464. private void share()
  465. {
  466. try
  467. {
  468. var path = PDFViewer.Document.FilePath;
  469. string subject = "分享至" + " " + PDFViewer.Document.FileName;
  470. System.Diagnostics.Process.Start("outlook", "/a,\"" + path + "\"" + "/m \"" + "&subject=" + subject + "\"");
  471. }
  472. catch
  473. {
  474. AlertsMessage alertsMessage = new AlertsMessage();
  475. alertsMessage.ShowDialog("", "未检测到Ooutlook软件,请先安装Outlook", "OK");
  476. }
  477. }
  478. private void SettingsEvent()
  479. {
  480. dialogs.ShowDialog(DialogNames.SettingsDialog, null, null);
  481. }
  482. private bool CanSaveExcute()
  483. {
  484. return CanSave;
  485. }
  486. private void MenuEnterReadModeEvent(object obj)
  487. {
  488. }
  489. public void ShowPrintDialog()
  490. {
  491. DialogParameters printValue = new DialogParameters();
  492. printValue.Add(ParameterNames.PDFViewer, PDFViewer);
  493. printValue.Add(ParameterNames.FilePath, PDFViewer.Document.FileName);
  494. printValue.Add(ParameterNames.PrintCurrentPage, PDFViewer.CurrentIndex);
  495. dialogs.ShowDialog(DialogNames.HomePagePrinterDialog, printValue, e => { });
  496. }
  497. private void InitialregionNameByTabItem(ref Dictionary<string, string> dictionary)
  498. {
  499. dictionary.Add("TabItemPageEdit", ToolContentRegionName);
  500. dictionary.Add("TabItemTool", ToolsBarContentRegionName);
  501. //其他工具菜单栏共用一个ToolsBarContentRegionName
  502. dictionary.Add("TabItemAnnotation", ToolsBarContentRegionName);
  503. dictionary.Add("TabItemConvert", ConverterBarContentRegionName);
  504. dictionary.Add("TabItemScan", ToolsBarContentRegionName);
  505. dictionary.Add("TabItemEdit", TextEditContentRegionName);
  506. dictionary.Add("TabItemForm", ToolsBarContentRegionName);
  507. dictionary.Add("TabItemFill", ToolsBarContentRegionName);
  508. }
  509. private void InitialbarContentByTabItem(ref Dictionary<string, string> dictionary)
  510. {
  511. dictionary.Add("TabItemPageEdit", "PageEditContent");
  512. dictionary.Add("TabItemTool", "ToolsBarContent");
  513. dictionary.Add("TabItemAnnotation", "AnnotToolContent");
  514. dictionary.Add("TabItemConvert", "ConverterBarContent");
  515. dictionary.Add("TabItemScan", "ScanContent");
  516. dictionary.Add("TabItemEdit", "TextEditToolContent");
  517. dictionary.Add("TabItemForm", "FormsToolContent");
  518. dictionary.Add("TabItemFill", "FillAndSignContent");
  519. }
  520. private void UpdateShowContent(string currentBar)
  521. {
  522. ToolContentVisible = Visibility.Collapsed;
  523. ToolsBarContentVisible = Visibility.Collapsed;
  524. ConverterBarContentVisible = Visibility.Collapsed;
  525. TextEditToolContentVisible = Visibility.Collapsed;
  526. OCRContentVisible = Visibility.Collapsed;
  527. switch (currentBar)
  528. {
  529. case "TabItemAnnotation":
  530. case "TabItemTool":
  531. case "TabItemForm":
  532. case "TabItemFill":
  533. ToolsBarContentVisible = Visibility.Visible;
  534. break;
  535. case "TabItemScan":
  536. ToolsBarContentVisible = Visibility.Visible;
  537. OCRContentVisible = Visibility.Visible;
  538. break;
  539. case "TabItemEdit":
  540. TextEditToolContentVisible = Visibility.Visible;
  541. break;
  542. case "TabItemConvert":
  543. ConverterBarContentVisible = Visibility.Visible;
  544. break;
  545. case "TabItemPageEdit":
  546. case "HeaderFooterContent":
  547. case "BatesContent":
  548. case "WatermarkContent":
  549. case "BackgroundContent":
  550. case "RedactionContent":
  551. ToolContentVisible = Visibility.Visible;
  552. break;
  553. default:
  554. break;
  555. }
  556. PDFEditMode(currentBar);
  557. FormMode(currentBar);
  558. }
  559. private void PDFEditMode(string currentBar)
  560. {
  561. if (currentBar == "TabItemEdit")
  562. {
  563. if (PDFViewer != null)
  564. {
  565. PDFViewer.SetMouseMode(MouseModes.PDFEdit);
  566. //SelectedPrpoertyPanel("TextEditProperty", null);
  567. //IsPropertyOpen = true;
  568. }
  569. }
  570. else
  571. {
  572. if (PDFViewer != null && PDFViewer.MouseMode == MouseModes.PDFEdit)
  573. {
  574. IsPropertyOpen = false;
  575. PDFViewer.SetMouseMode(MouseModes.PanTool);
  576. }
  577. }
  578. }
  579. private void FormMode(string currentBar)
  580. {
  581. if (currentBar == "TabItemForm")
  582. {
  583. if (PDFViewer != null)
  584. {
  585. PDFViewer.SetMouseMode(MouseModes.FormEditTool);
  586. }
  587. }
  588. else
  589. {
  590. if (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool)
  591. {
  592. PDFViewer.SetMouseMode(MouseModes.PanTool);
  593. }
  594. }
  595. }
  596. private void UndoManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  597. {
  598. if (!isInPageEdit)
  599. {
  600. //不处于页面编辑模式下时,根据PDFVIewer的undo redo状态来更新按钮状态
  601. //页面编辑模式下,按钮状态根据页面编辑的undo redo来显示
  602. if (e.PropertyName == "CanUndo")
  603. {
  604. CanUndo = PDFViewer.UndoManager.CanUndo;
  605. }
  606. if (e.PropertyName == "CanRedo")
  607. {
  608. CanRedo = PDFViewer.UndoManager.CanRedo;
  609. }
  610. }
  611. if (e.PropertyName == "CanSave")
  612. {
  613. CanSave = PDFViewer.UndoManager.CanSave;
  614. }
  615. }
  616. /// <summary>
  617. /// 选项卡切换事件
  618. /// </summary>
  619. /// <param name="e"></param>
  620. private void TabControlSelectonChangedEvent(object e)
  621. {
  622. var args = e as SelectionChangedEventArgs;
  623. if (args != null)
  624. {
  625. var item = args.AddedItems[0] as TabItem;
  626. CurrentBar = item.Name;
  627. if (previousBar != CurrentBar)
  628. {
  629. if (CurrentBar == "TabItemPageEdit")//如果是页面编辑则进入页面编辑模式
  630. {
  631. EnterToolMode(barContentByTabItem[CurrentBar]);
  632. isInPageEdit = true;
  633. }
  634. else//其余情况直接导航至对应的工具栏即可,不需要清空之前的content,region里是单例模式
  635. {
  636. EnterSelectedBar(CurrentBar);
  637. isInPageEdit = false;
  638. }
  639. previousBar = CurrentBar;
  640. }
  641. }
  642. }
  643. /// <summary>
  644. /// 阅读模式
  645. /// </summary>
  646. /// <param name="viewContent"></param>
  647. public async void RbtnReadMode()
  648. {
  649. App.mainWindowViewModel.SelectedItem.IsInReadctonMode = true;
  650. App.IsBookMode = true;
  651. IsLoading = Visibility.Visible;
  652. await Task.Delay(1);
  653. NavigationParameters param = new NavigationParameters();
  654. param.Add(ParameterNames.PDFViewer, PDFViewer);
  655. param.Add(ParameterNames.ViewContentViewModel, this);
  656. region.RequestNavigate(ToolContentRegionName, "ReadViewContent", param);
  657. //ShowContent(CurrentBar, true);
  658. if (GridToolRow != 0)
  659. {
  660. GridToolRow = 0;
  661. }
  662. if (GridToolRowSpan != 4)
  663. {
  664. GridToolRowSpan = 4;
  665. }
  666. //isInPageEdit = true;
  667. UpdateShowContent("TabItemPageEdit");
  668. IsLoading = Visibility.Collapsed;
  669. }
  670. /// <summary>
  671. /// 退出阅读模式
  672. /// </summary>
  673. public async void UnReadModel()
  674. {
  675. App.mainWindowViewModel.SelectedItem.IsInReadctonMode = false;
  676. App.IsBookMode = false;
  677. IsLoading = Visibility.Visible;
  678. await Task.Delay(1);
  679. //PDFViewer.MouseMode = MouseModes.None;
  680. if (region.Regions.ContainsRegionWithName(ViwerRegionName))
  681. {
  682. if (region.Regions[ViwerRegionName].Views.Contains(PDFViewer))
  683. {
  684. var contentRegion = region.Regions[ViwerRegionName];
  685. contentRegion.Remove(PDFViewer);
  686. }
  687. region.AddToRegion(ViwerRegionName, PDFViewer);
  688. }
  689. if (string.IsNullOrEmpty(CurrentBar) || CurrentBar.Equals("TabItemPageEdit", StringComparison.OrdinalIgnoreCase))
  690. {
  691. EnterSelectedBar("TabItemAnnotation");
  692. }
  693. else
  694. {
  695. EnterSelectedBar(CurrentBar);
  696. }
  697. //isInPageEdit = false;
  698. //ShowContent(CurrentBar, false);
  699. //isInPageEdit = false;
  700. IsLoading = Visibility.Collapsed;
  701. ReadModelTip = Visibility.Visible;
  702. await Task.Delay(3000);
  703. ReadModelTip = Visibility.Collapsed;
  704. }
  705. #region PDFViewer鼠标滚轮缩放事件
  706. public void PdfViewer_MouseWheelZoomHandler(object sender, bool e)
  707. {
  708. double newZoom = CheckZoomLevel(PDFViewer.ZoomFactor + (e ? 0.01 : -0.01), e);
  709. PDFViewer.Zoom(newZoom);
  710. }
  711. private double CheckZoomLevel(double zoom, bool IsGrowth)
  712. {
  713. double standardZoom = 100;
  714. if (zoom <= 0.01)
  715. {
  716. return 0.01;
  717. }
  718. if (zoom >= 10)
  719. {
  720. return 10;
  721. }
  722. zoom *= 100;
  723. for (int i = 0; i < zoomLevel.Length - 1; i++)
  724. {
  725. if (zoom > zoomLevel[i] && zoom <= zoomLevel[i + 1] && IsGrowth)
  726. {
  727. standardZoom = zoomLevel[i + 1];
  728. break;
  729. }
  730. if (zoom >= zoomLevel[i] && zoom < zoomLevel[i + 1] && !IsGrowth)
  731. {
  732. standardZoom = zoomLevel[i];
  733. break;
  734. }
  735. }
  736. return standardZoom / 100;
  737. }
  738. #endregion PDFViewer鼠标滚轮缩放事件
  739. #region Navigate
  740. public void OnNavigatedTo(NavigationContext navigationContext)
  741. {
  742. if (isOpenFile)
  743. return;
  744. var mainVM = navigationContext.Parameters[ParameterNames.MainViewModel] as MainContentViewModel;
  745. if (mainVM != null)
  746. {
  747. mainViewModel = mainVM;
  748. }
  749. var pdfview = navigationContext.Parameters[ParameterNames.PDFViewer] as CPDFViewer;
  750. if (pdfview != null)
  751. {
  752. PDFViewer = pdfview;
  753. loadFile();
  754. }
  755. isOpenFile = true;
  756. }
  757. public bool IsNavigationTarget(NavigationContext navigationContext)
  758. {
  759. return true;
  760. }
  761. public void OnNavigatedFrom(NavigationContext navigationContext)
  762. {
  763. }
  764. #endregion Navigate
  765. #region 方法
  766. /// <summary>
  767. /// 视图面板 切换分屏模式
  768. /// </summary>
  769. /// <param name="mode"></param>
  770. public void EnterSplitMode(SplitMode mode)
  771. {
  772. ///通知UI层更改布局
  773. this.events.GetEvent<SplitEvent>().Publish(new SplitEventArgs() { Unicode = unicode, Mode = mode });
  774. }
  775. private void Undo()
  776. {
  777. if (isInPageEdit)
  778. {
  779. //执行页面编辑的Undo
  780. PageEditUndo?.Invoke();
  781. }
  782. else
  783. {
  784. PDFViewer.UndoManager.Undo();
  785. }
  786. }
  787. private void Redo()
  788. {
  789. if (isInPageEdit)
  790. {
  791. //执行页面编辑的Redo
  792. PageEditRedo?.Invoke();
  793. }
  794. else
  795. {
  796. PDFViewer.UndoManager.Redo();
  797. }
  798. }
  799. private void LoadControl()
  800. {
  801. //在构造函数中使用Region需要借助Dispatcher 确保UI已经加载完成,加载BOTA区域
  802. System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
  803. {
  804. NavigationParameters parameters = new NavigationParameters();
  805. parameters.Add(ParameterNames.PDFViewer, PDFViewer);
  806. parameters.Add(ParameterNames.ViewContentViewModel, this);
  807. region.RequestNavigate(BOTARegionName, "BOTAContent", parameters);
  808. region.RequestNavigate(BottomToolRegionName, "BottomToolContent", parameters);
  809. region.RequestNavigate(ReadModeRegionName, "ReadModeContent", parameters);
  810. region.RequestNavigate(SplitViewerRegionName, "SplitScreenContent", parameters);
  811. //TODO 根据上一次关闭记录的菜单,选中TabItem
  812. EnterSelectedBar("TabItemAnnotation");
  813. }
  814. ));
  815. }
  816. /// <summary>
  817. /// 各个注释(选中和创建注释)导航到对应注释的属性面板
  818. /// </summary>
  819. /// <param name="Content"></param>
  820. /// <param name="annotPropertyPanel"></param>
  821. public void SelectedPrpoertyPanel(string Content, AnnotPropertyPanel annotPropertyPanel)
  822. {
  823. System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
  824. {
  825. NavigationParameters parameters = new NavigationParameters();
  826. //传其他参数:文档类,空注释面板;
  827. parameters.Add(ParameterNames.PDFViewer, PDFViewer);
  828. parameters.Add(ParameterNames.PropertyPanelContentViewModel, annotPropertyPanel);
  829. parameters.Add(ParameterNames.ViewContentViewModel, this);
  830. region.RequestNavigate(PropertyRegionName, Content, parameters);
  831. }
  832. ));
  833. }
  834. /// <summary>
  835. /// 将PDFViwer添加到Region
  836. /// </summary>
  837. private void loadFile()
  838. {
  839. PDFViewer.MouseWheelZoomHandler += PdfViewer_MouseWheelZoomHandler;
  840. PDFViewer.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
  841. CanSave = PDFViewer.UndoManager.CanSave;
  842. CanUndo = PDFViewer.UndoManager.CanUndo;
  843. CanRedo = PDFViewer.UndoManager.CanRedo;
  844. region.AddToRegion(ViwerRegionName, PDFViewer);
  845. }
  846. /// <summary>
  847. /// 已有路径文档的保存逻辑
  848. /// </summary>
  849. private bool saveFile()
  850. {
  851. try
  852. {
  853. if (string.IsNullOrEmpty(PDFViewer.Document.FilePath))
  854. return saveAsFile();
  855. //文档已被修复时 提示另存为
  856. if (PDFViewer.Document.HasRepaired)
  857. {
  858. AlertsMessage alertsMessage = new AlertsMessage();
  859. alertsMessage.ShowDialog("", "文件已被修复,建议另存为", "Cancel", "OK");
  860. if (alertsMessage.result == ContentResult.Ok)
  861. return saveAsFile();
  862. else
  863. return false;
  864. }
  865. //文件路径无法存在时
  866. if (!File.Exists(PDFViewer.Document.FilePath))
  867. {
  868. AlertsMessage alertsMessage = new AlertsMessage();
  869. alertsMessage.ShowDialog("", "文件路径不存在,需要另存为", "Cancel", "OK");
  870. if (alertsMessage.result == ContentResult.Ok)
  871. return saveAsFile();
  872. else
  873. return false;
  874. }
  875. //只读文件无法写入时,提示另存为
  876. FileInfo fileInfo = new FileInfo(PDFViewer.Document.FilePath);
  877. if (fileInfo.IsReadOnly)
  878. {
  879. AlertsMessage alertsMessage = new AlertsMessage();
  880. alertsMessage.ShowDialog("", "文件为只读文件,需要另存为", "Cancel", "OK");
  881. if (alertsMessage.result == ContentResult.Ok)
  882. return saveAsFile();
  883. else
  884. return false;
  885. }
  886. bool result = PDFViewer.Document.WriteToLoadedPath();
  887. if (result)
  888. {
  889. PDFViewer.UndoManager.CanSave = false;
  890. App.Current.Dispatcher.Invoke(() =>
  891. {
  892. //TODO:更新缩略图
  893. //OpenFileInfo info = SettingHelper.GetFileInfo(PdfViewer.Document.FilePath);
  894. //try
  895. //{
  896. // if (!string.IsNullOrEmpty(info.ThumbImgPath) && !PdfViewer.Document.IsEncrypted)//加密的文档不获取缩略图
  897. // {
  898. // var size = PdfViewer.Document.GetPageSize(0);
  899. // System.Drawing.Bitmap bitmap = ToolMethod.RenderPageBitmapNoWait(PdfViewer.Document, (int)size.Width, (int)size.Height, 0, true, true);
  900. // string folderPath = System.IO.Path.Combine(App.CurrentPath, "CoverImage");
  901. // if (File.Exists(folderPath))
  902. // File.Delete(folderPath);
  903. // DirectoryInfo folder = new DirectoryInfo(folderPath);
  904. // if (!folder.Exists)
  905. // folder.Create();
  906. // string imagePath = info.ThumbImgPath;
  907. // if (!File.Exists(imagePath))//由加密文档变为非加密文档时 新建一个路径
  908. // {
  909. // string imageName = Guid.NewGuid().ToString();
  910. // imagePath = System.IO.Path.Combine(folderPath, imageName);
  911. // using (FileStream stream = new FileStream(imagePath, FileMode.Create))
  912. // {
  913. // bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
  914. // }
  915. // }
  916. // else
  917. // {
  918. // using (FileStream stream = new FileStream(imagePath, FileMode.Open))
  919. // {
  920. // bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
  921. // }
  922. // }
  923. // info.ThumbImgPath = imagePath;
  924. // SettingHelper.SetFileInfo(info);
  925. // }
  926. //}
  927. //catch
  928. //{
  929. // info.ThumbImgPath = null;
  930. // SettingHelper.SetFileInfo(info);
  931. //}
  932. });
  933. }
  934. else
  935. {
  936. //文件被占用 保存失败时
  937. AlertsMessage alertsMessage = new AlertsMessage();
  938. alertsMessage.ShowDialog("", "文件被占用,需要另存为", "Cancel", "OK");
  939. if (alertsMessage.result == ContentResult.Ok)
  940. return saveAsFile();
  941. else
  942. return false;
  943. }
  944. return result;
  945. }
  946. catch { return false; }
  947. }
  948. /// <summary>
  949. /// 另存为或新文档保存逻辑
  950. /// </summary>
  951. public bool saveAsFile(bool isApplyRedaction = false, bool isEraseRedaction = false)
  952. {
  953. var dlg = new Microsoft.Win32.SaveFileDialog();
  954. dlg.Filter = Properties.Resources.OpenDialogFilter;
  955. dlg.FileName = PDFViewer.Document.FileName;
  956. if (dlg.ShowDialog() == true && !string.IsNullOrEmpty(dlg.FileName))
  957. {
  958. bool result = false;
  959. //标记密文后的保存
  960. if (isApplyRedaction)
  961. {
  962. //应用标记密文并另存为保存
  963. try
  964. {
  965. PDFViewer.Document.ApplyRedaction();
  966. PDFViewer.Document.ReleasePages();
  967. PDFViewer.ReloadDocument();
  968. }
  969. catch { }
  970. }
  971. else if (isEraseRedaction)
  972. {
  973. EraseReadction();
  974. }
  975. if (App.OpenedFileList.Contains(dlg.FileName))
  976. {
  977. //提示文件已经被打开
  978. }
  979. else
  980. {
  981. result = PDFViewer.Document.WriteToFilePath(dlg.FileName);
  982. if (result)
  983. {
  984. DoAfterSaveAs(dlg.FileName);
  985. }
  986. else
  987. {
  988. //提示文件被其他软件占用 无法保存
  989. //MessageBoxEx.Show(App.MainPageLoader.GetString("Main_TheFileOccupiedWarning"), "", Winform.MessageBoxButtons.OKCancel, new string[] { App.MainPageLoader.GetString("Main_SaveAs"), App.MainPageLoader.GetString("Main_Cancel") })
  990. }
  991. ;
  992. }
  993. return result;
  994. }
  995. else
  996. return false;
  997. }
  998. private void EraseReadction()
  999. {
  1000. for (int i = 0; i < PDFViewer.Document.PageCount; i++)
  1001. {
  1002. //获取页面Page对象
  1003. var page = PDFViewer.Document.PageAtIndex(i);
  1004. var annots = PDFViewer.GetAnnotCommentList(i, PDFViewer.Document);
  1005. //循环擦除当前页的标记密文
  1006. for (int j = 0; j < annots.Count; j++)
  1007. {
  1008. if (annots[j].EventType == AnnotArgsType.AnnotRedaction)
  1009. {
  1010. foreach (var rect in (annots[j] as RedactionAnnotArgs).QuardRects)
  1011. {
  1012. page.ErasureRedaction(rect);
  1013. }
  1014. }
  1015. }
  1016. }
  1017. }
  1018. /// <summary>
  1019. /// 另存为后进行的操作
  1020. /// 重新打开新文档
  1021. /// </summary>
  1022. /// <param name="targetPath"></param>
  1023. public void DoAfterSaveAs(string targetPath)
  1024. {
  1025. App.OpenedFileList.Remove(targetPath);
  1026. string oldFilePath = targetPath;
  1027. PDFViewer.UndoManager.CanSave = false;
  1028. mainViewModel.OpenFile(targetPath);
  1029. //TODO:通知各模块更新PDFview对象
  1030. //var result = OpenFile(targetPath, true);
  1031. //if (result)
  1032. //{
  1033. // FileChanged.Invoke(this, null);
  1034. // Zoomer.PdfViewer = PdfViewer;
  1035. // PageSelector.PdfViewer = PdfViewer;
  1036. // ViewModeSelector.PdfViewer = PdfViewer;
  1037. // OpenFileInfo fileInfo = SettingHelper.GetFileInfo(oldFilePath);
  1038. // if (fileInfo != null)
  1039. // {
  1040. // PdfViewer.ChangeViewMode(fileInfo.LastViewMode);
  1041. // PdfViewer.ChangeFitMode(fileInfo.LastFitMode);
  1042. // if (fileInfo.LastFitMode == FitMode.FitFree)
  1043. // PdfViewer.Zoom(fileInfo.LastZoom);
  1044. // PdfViewer.GoToPage(fileInfo.LastPageIndex);
  1045. // if (fileInfo.LastDrawMode == DrawModes.Draw_Mode_Custom && fileInfo.LastFillColor != 0)
  1046. // PdfViewer.SetDrawMode(fileInfo.LastDrawMode, fileInfo.LastFillColor);
  1047. // else
  1048. // PdfViewer.SetDrawMode(fileInfo.LastDrawMode);
  1049. // }
  1050. //}
  1051. }
  1052. /// <summary>
  1053. /// 显示前添加内容到Region
  1054. /// </summary>
  1055. /// <param name="isPageEdit"></param>
  1056. private void ShowContent(string currentBar, bool isToolMode = false)
  1057. {
  1058. GridVisibility = Visibility.Visible;
  1059. //显示页面编辑或其他工具
  1060. if (currentBar == "TabItemPageEdit" || isToolMode)
  1061. {
  1062. if (currentBar == "TabItemPageEdit")//进入页面编辑
  1063. {
  1064. if (GridToolRow != 1)
  1065. {
  1066. GridToolRow = 1;
  1067. }
  1068. if (GridToolRowSpan != 3)
  1069. {
  1070. GridToolRowSpan = 3;
  1071. }
  1072. }
  1073. else//进入水印等其他工具模式
  1074. {
  1075. GridVisibility = Visibility.Collapsed;
  1076. if (GridToolRow != 0)
  1077. {
  1078. GridToolRow = 0;
  1079. }
  1080. if (GridToolRowSpan != 4)
  1081. {
  1082. GridToolRowSpan = 4;
  1083. }
  1084. }
  1085. //ToolContent的visible跟toolsbarContent 的visible是互斥的
  1086. UpdateShowContent(currentBar);
  1087. }
  1088. else
  1089. {
  1090. if (GridToolRow != 1)
  1091. {
  1092. GridToolRow = 1;
  1093. }
  1094. UpdateShowContent(currentBar);
  1095. }
  1096. }
  1097. /// <summary>
  1098. /// 从二级工具栏进入需要修改界面布局的场景
  1099. /// </summary>
  1100. /// <param name="EditToolName"></param>
  1101. private void EnterEditTools(StringWithUnicode EditToolName)
  1102. {
  1103. EnterSelectedEditTool(EditToolName);
  1104. }
  1105. private void CloseEditTool(EnumCloseModeUnicode enumCloseModeunicode)
  1106. {
  1107. EnumCloseMode enumCloseMode = enumCloseModeunicode.Status;
  1108. if (enumCloseMode == EnumCloseMode.StatusConfirm)
  1109. {
  1110. PDFViewer.Document.ReleasePages();
  1111. PDFViewer.ReloadDocument();
  1112. }
  1113. //如果是其他工具共用一个PDFview,退出工具模式后,需要重新添加到Region,否则不会显示
  1114. if (!region.Regions[ViwerRegionName].Views.Contains(PDFViewer))
  1115. {
  1116. region.AddToRegion(ViwerRegionName, PDFViewer);
  1117. }
  1118. CurrentBar = "TabItemTool";
  1119. EnterSelectedBar(CurrentBar);
  1120. }
  1121. /// <summary>
  1122. /// 二级菜单指定目标处理
  1123. /// </summary>
  1124. /// <param name="e"></param>
  1125. private void EnterSelectedEditTool(StringWithUnicode EditToolName)
  1126. {
  1127. CurrentBar = EditToolName.EditToolsContentName;
  1128. EnterToolMode(CurrentBar);
  1129. }
  1130. /// <summary>
  1131. /// 进入工具编辑(如页面编辑、水印、密文等)模式
  1132. /// </summary>
  1133. /// <param name="targetToolMode">要导航过去的控件名称</param>
  1134. /// <param name="valuePairs">导航需要传送的参数,为空时,默认传送PDFView和ViewContentViewModel</param>
  1135. private async void EnterToolMode(string targetToolMode, NavigationParameters valuePairs = null)
  1136. {
  1137. IsLoading = Visibility.Visible;
  1138. await Task.Delay(3);
  1139. NavigationParameters param = new NavigationParameters();
  1140. if (valuePairs == null)
  1141. {
  1142. param.Add(ParameterNames.PDFViewer, PDFViewer);
  1143. param.Add(ParameterNames.ViewContentViewModel, this);
  1144. }
  1145. else//有传入其他内容的参数时
  1146. {
  1147. param = valuePairs;
  1148. }
  1149. region.RequestNavigate(ToolContentRegionName, targetToolMode, param);
  1150. ShowContent(CurrentBar, true);
  1151. IsLoading = Visibility.Collapsed;
  1152. }
  1153. private void EnterSelectedBar(string currentBar)
  1154. {
  1155. NavigationParameters param = new NavigationParameters();
  1156. param.Add(ParameterNames.PDFViewer, PDFViewer);
  1157. param.Add(ParameterNames.ViewContentViewModel, this);
  1158. region.RequestNavigate(regionNameByTabItem[currentBar], barContentByTabItem[currentBar], param);
  1159. if (currentBar == "TabItemScan")
  1160. {
  1161. region.RequestNavigate(RegionNames.OCRViewerRegionName, "ScanViwer", param);
  1162. }
  1163. ShowContent(currentBar);
  1164. }
  1165. /// <summary>
  1166. /// 退出工具(水印、密文等)编辑模式,隐藏ToolContent
  1167. /// </summary>
  1168. public void ExitToolMode()
  1169. {
  1170. ToolContentVisible = Visibility.Collapsed;
  1171. if (isInPageEdit)
  1172. {
  1173. TabSelectedIndex = 0;
  1174. isInPageEdit = false;
  1175. }
  1176. }
  1177. #endregion 方法
  1178. }
  1179. }