ViewContentViewModel.cs 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942
  1. using Microsoft.Win32;
  2. using Prism.Commands;
  3. using Prism.Mvvm;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Threading.Tasks;
  7. using ComPDFKitViewer.PdfViewer;
  8. using Prism.Regions;
  9. using Prism.Services.Dialogs;
  10. using PDF_Office.CustomControl;
  11. using PDF_Office.Model;
  12. using System.Windows;
  13. using System.Windows.Controls;
  14. using System.IO;
  15. using ComPDFKitViewer.AnnotEvent;
  16. using PDF_Office.ViewModels.Tools;
  17. using Prism.Events;
  18. using PDF_Office.EventAggregators;
  19. using PDF_Office.Helper;
  20. using ComPDFKit.PDFDocument;
  21. using PDFSettings.Settings;
  22. using PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs;
  23. using static PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs.SetPasswordDialogModel;
  24. using PDF_Office.Model.Dialog.ToolsDialogs;
  25. using DryIoc;
  26. using PDF_Office.Model.Dialog.ConverterDialogs;
  27. using static PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs.DeleteSafetySettintgsModel;
  28. using PDF_Office.Views.PropertyPanel.AnnotPanel;
  29. using System.Linq;
  30. using System.Text;
  31. namespace PDF_Office.ViewModels
  32. {
  33. public class ViewContentViewModel : BindableBase, INavigationAware
  34. {
  35. #region 属性、变量
  36. public OpenFileInfo OpenFileInfo = null;
  37. public CPDFViewer PDFViewer { get; set; }
  38. public MainContentViewModel mainViewModel { get; set; }
  39. public IRegionManager region;
  40. public IDialogService dialogs;
  41. public IEventAggregator events;
  42. public bool IsRightMenuCreateLink { get => isCreateLink; set => isCreateLink = value; }
  43. public string ViwerRegionName { get; set; }
  44. /// <summary>
  45. /// 分屏视图的region名称
  46. /// </summary>
  47. public string SplitViewerRegionName { get; set; }
  48. /// <summary>
  49. /// OCR视图名称
  50. /// </summary>
  51. public string OCRViewerRegionName { get; set; }
  52. public string BOTARegionName { get; set; }
  53. public string PropertyRegionName { get; set; }
  54. public string ToolContentRegionName { get; set; }
  55. public string ToolsBarContentRegionName { get; set; }
  56. /// <summary>
  57. /// 顶部提示的Content
  58. /// </summary>
  59. public string TipContentRegionName { get; set; }
  60. public string LeftTipContentRegionName { get; set; }
  61. public string ReadModeRegionName { get; set; }
  62. public string ConverterBarContentRegionName { get; set; }
  63. public string TextEditContentRegionName { get; set; }
  64. public string BackgroundContentRegionName { get; set; }
  65. public List<Point> FillAndSign = new List<Point>();
  66. /// <summary>
  67. /// 文档的密码
  68. /// </summary>
  69. public string PassWord { get; set; }
  70. private Visibility tipVisible = Visibility.Collapsed;
  71. /// <summary>
  72. /// 顶部提示栏的显示状态
  73. /// </summary>
  74. public Visibility TipVisible
  75. {
  76. get { return tipVisible; }
  77. set
  78. {
  79. SetProperty(ref tipVisible, value);
  80. }
  81. }
  82. private Visibility leftTipVisible = Visibility.Collapsed;
  83. public Visibility LeftTipVisible
  84. {
  85. get { return leftTipVisible; }
  86. set
  87. {
  88. SetProperty(ref leftTipVisible, value);
  89. }
  90. }
  91. private Visibility readModelTip = Visibility.Collapsed;
  92. public Visibility ReadModelTip
  93. {
  94. get { return readModelTip; }
  95. set
  96. {
  97. SetProperty(ref readModelTip, value);
  98. }
  99. }
  100. /// <summary>
  101. /// 底部工具栏 RegionName
  102. /// </summary>
  103. public string BottomToolRegionName { get; set; }
  104. private bool _isInPageEdit = false;
  105. /// <summary>
  106. /// 是否处于页面编辑模式,用于执行undo redo 的具体操作
  107. /// </summary>
  108. public bool isInPageEdit
  109. {
  110. get { return _isInPageEdit; }
  111. set
  112. {
  113. SetProperty(ref _isInPageEdit, value);
  114. if (!value)
  115. {
  116. CanRedo = PDFViewer.UndoManager.CanRedo;
  117. CanUndo = PDFViewer.UndoManager.CanUndo;
  118. }
  119. }
  120. }
  121. public Action PageEditUndo { get; set; }
  122. public Action PageEditRedo { get; set; }
  123. /// <summary>
  124. ///工具条
  125. ///0:收起
  126. ///40:显示
  127. /// </summary>
  128. private int toolRowHeight = 40;
  129. public int ToolRowHeight
  130. {
  131. get { return toolRowHeight; }
  132. set
  133. {
  134. SetProperty(ref toolRowHeight, value);
  135. }
  136. }
  137. /// <summary>
  138. /// 水印,背景侧边栏宽度
  139. /// 0:收起
  140. /// 260:显示
  141. /// </summary>
  142. private int propertyColumnWidth = 0;
  143. public int PropertyColumnWidth
  144. {
  145. get { return propertyColumnWidth; }
  146. set
  147. {
  148. SetProperty(ref propertyColumnWidth, value);
  149. }
  150. }
  151. private int gridToolRow = 1;
  152. /// <summary>
  153. /// 控制ToolContent的Row
  154. /// </summary>
  155. public int GridToolRow
  156. {
  157. get { return gridToolRow; }
  158. set
  159. {
  160. SetProperty(ref gridToolRow, value);
  161. }
  162. }
  163. private int gridToolRowSpan = 3;
  164. /// <summary>
  165. /// 控制ToolContent的RowSpan
  166. /// </summary>
  167. public int GridToolRowSpan
  168. {
  169. get { return gridToolRowSpan; }
  170. set
  171. {
  172. SetProperty(ref gridToolRowSpan, value);
  173. }
  174. }
  175. private Visibility toolContentVisible = Visibility.Collapsed;
  176. /// <summary>
  177. /// 控制Content的显示 用于显示水印、贝茨码、密文等功能模块
  178. /// 留意:显示前需要先注入内容、设置好行和跨行数
  179. /// </summary>
  180. public Visibility ToolContentVisible
  181. {
  182. get { return toolContentVisible; }
  183. set
  184. {
  185. SetProperty(ref toolContentVisible, value);
  186. }
  187. }
  188. private Visibility gridVisibility = Visibility.Visible;
  189. /// <summary>
  190. /// 是否正在加载中
  191. /// </summary>
  192. public Visibility GridVisibility
  193. {
  194. get { return gridVisibility; }
  195. set
  196. {
  197. SetProperty(ref gridVisibility, value);
  198. }
  199. }
  200. private Visibility isLoading = Visibility.Collapsed;
  201. private Visibility ocrContentVisible = Visibility.Collapsed;
  202. public Visibility OCRContentVisible
  203. {
  204. get { return ocrContentVisible; }
  205. set
  206. {
  207. SetProperty(ref ocrContentVisible, value);
  208. }
  209. }
  210. /// <summary>
  211. /// 是否正在加载中
  212. /// </summary>
  213. public Visibility IsLoading
  214. {
  215. get { return isLoading; }
  216. set
  217. {
  218. SetProperty(ref isLoading, value);
  219. }
  220. }
  221. private Visibility converterBarContentVisible = Visibility.Collapsed;
  222. private Visibility toolsbarContentVisible = Visibility.Collapsed;
  223. /// <summary>
  224. /// 控制ToolsBarContent的显示
  225. /// 留意:显示前需要先注入内容、设置好行和跨行数
  226. /// </summary>
  227. public Visibility ConverterBarContentVisible
  228. {
  229. get { return converterBarContentVisible; }
  230. set
  231. {
  232. SetProperty(ref converterBarContentVisible, value);
  233. }
  234. }
  235. private Visibility toolsBarContentVisible = Visibility.Collapsed;
  236. /// <summary>
  237. /// 控制ToolsBarContent的显示
  238. /// 留意:显示前需要先注入内容、设置好行和跨行数
  239. /// </summary>
  240. public Visibility ToolsBarContentVisible
  241. {
  242. get { return toolsBarContentVisible; }
  243. set
  244. {
  245. SetProperty(ref toolsBarContentVisible, value);
  246. }
  247. }
  248. private Visibility textEditToolContentVisible = Visibility.Collapsed;
  249. /// <summary>
  250. /// 控制ToolsBarContent的显示
  251. /// 留意:显示前需要先注入内容、设置好行和跨行数
  252. /// </summary>
  253. public Visibility TextEditToolContentVisible
  254. {
  255. get { return textEditToolContentVisible; }
  256. set
  257. {
  258. SetProperty(ref textEditToolContentVisible, value);
  259. }
  260. }
  261. private bool isPorpertyOpen = false;
  262. /// <summary>
  263. /// 属性栏是否展开
  264. /// </summary>
  265. public bool IsPropertyOpen
  266. {
  267. get { return isPorpertyOpen; }
  268. set
  269. {
  270. SetProperty(ref isPorpertyOpen, value);
  271. }
  272. }
  273. private Visibility isReadMode = Visibility.Visible;
  274. /// <summary>
  275. ///是否为阅读模式
  276. /// </summary>
  277. public Visibility IsReadMode
  278. {
  279. get { return isReadMode; }
  280. set
  281. {
  282. SetProperty(ref isReadMode, value);
  283. }
  284. }
  285. private bool canSave;
  286. /// <summary>
  287. /// 是否可以保存
  288. /// </summary>
  289. public bool CanSave
  290. {
  291. get { return canSave; }
  292. set
  293. {
  294. SetProperty(ref canSave, value);
  295. }
  296. }
  297. private bool canUndo;
  298. /// <summary>
  299. /// 是否可以进行Undo
  300. /// </summary>
  301. public bool CanUndo
  302. {
  303. get { return canUndo; }
  304. set
  305. {
  306. SetProperty(ref canUndo, value);
  307. }
  308. }
  309. private bool canRedo;
  310. /// <summary>
  311. /// 是否可以进行Redo
  312. /// </summary>
  313. public bool CanRedo
  314. {
  315. get { return canRedo; }
  316. set
  317. {
  318. SetProperty(ref canRedo, value);
  319. }
  320. }
  321. private GridLength botaWidth = new GridLength(48);
  322. /// <summary>
  323. /// BOTA栏的宽度
  324. /// </summary>
  325. public GridLength BOTAWidth
  326. {
  327. get { return botaWidth; }
  328. set
  329. {
  330. SetProperty(ref botaWidth, value);
  331. if (botaWidth.Value <= 48)
  332. {
  333. OpenBOTA = false;
  334. }
  335. }
  336. }
  337. private int selectedIndex;
  338. /// <summary>
  339. /// 工具栏选中项的索引
  340. /// </summary>
  341. public int TabSelectedIndex
  342. {
  343. get { return selectedIndex; }
  344. set
  345. {
  346. SetProperty(ref selectedIndex, value);
  347. }
  348. }
  349. private bool openBOTA = false;
  350. /// <summary>
  351. /// 是否展开BOTA
  352. /// </summary>
  353. public bool OpenBOTA
  354. {
  355. get { return openBOTA; }
  356. set
  357. {
  358. SetProperty(ref openBOTA, value);
  359. if (openBOTA && BOTAWidth.Value <= 48)
  360. {
  361. BOTAWidth = new GridLength(260);
  362. }
  363. //关闭BOTA的逻辑在xaml.cs代码里控制,无法绑定后台
  364. }
  365. }
  366. public SecurityInfo SecurityInfo = new SecurityInfo();
  367. private Dictionary<string, string> regionNameByTabItem;
  368. private Dictionary<string, string> barContentByTabItem;
  369. private string previousBar = "";
  370. public string CurrentBar = "";
  371. public string unicode = null;
  372. /// <summary>
  373. /// 用来避免重复触发导航事件的标志符
  374. /// </summary>
  375. private bool isOpenFile = false;
  376. /// <summary>
  377. /// 鼠标滚轮缩放的缩放值
  378. /// </summary>
  379. private double[] zoomLevel = { 1.00f, 10, 25, 50, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
  380. /// <summary>
  381. /// 注释-链接,提示语
  382. /// </summary>
  383. private Visibility linkAnnotTipVisibility = Visibility.Collapsed;
  384. public Visibility LinkAnnotTipVisibility
  385. {
  386. get { return linkAnnotTipVisibility; }
  387. set
  388. {
  389. SetProperty(ref linkAnnotTipVisibility, value);
  390. }
  391. }
  392. 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";
  393. private bool isCreateLink = false;
  394. public string LinkAnnotTipText
  395. {
  396. get { return linkAnnotTipText; }
  397. set
  398. {
  399. SetProperty(ref linkAnnotTipText, value);
  400. }
  401. }
  402. #endregion 属性、变量
  403. #region 命令
  404. public DelegateCommand LoadFile { get; set; }
  405. public DelegateCommand Load { get; set; }
  406. public DelegateCommand<object> TabControlSelectionChangedCommand { get; set; }
  407. public DelegateCommand SaveFile { get; set; }
  408. public DelegateCommand SaveAsFile { get; set; }
  409. public DelegateCommand SaveAsFlattenCommand { get; set; }
  410. public DelegateCommand UndoCommand { get; set; }
  411. public DelegateCommand RedoCommand { get; set; }
  412. public DelegateCommand<object> MenuEnterReadMode { get; set; }
  413. public DelegateCommand PrintCommand { get; set; }
  414. public DelegateCommand SettingsCommand { get; set; }
  415. public DelegateCommand ShareCommand { get; set; }
  416. public DelegateCommand<object> CreateLinkCommand { get; set; }
  417. public DelegateCommand PropertyCommand { get; set; }
  418. public DelegateCommand ShowInFolderCommand { get; set; }
  419. public DelegateCommand CompressCommand { get; set; }
  420. public DelegateCommand MergeFileCommand { get; set; }
  421. public DelegateCommand EncryptCommand { get; set; }
  422. public DelegateCommand DecryptCommand { get; set; }
  423. public DelegateCommand<string> ConvertCommand { get; set; }
  424. public DelegateCommand CloseWindowCommand { get; set; }
  425. public DelegateCommand OpenFileCommand { get; set; }
  426. public DelegateCommand<string> HelpCommand { get; set; }
  427. public DelegateCommand CreateBlankFileCommand { get; set; }
  428. #endregion 命令
  429. public ViewContentViewModel(IRegionManager regionManager, IDialogService dialogService, IEventAggregator eventAggregator)
  430. {
  431. region = regionManager;
  432. dialogs = dialogService;
  433. events = eventAggregator;
  434. unicode = App.mainWindowViewModel.SelectedItem.Unicode;
  435. LoadFile = new DelegateCommand(loadFile);
  436. Load = new DelegateCommand(LoadControl);
  437. SaveFile = new DelegateCommand(() => { saveFile(); }, CanSaveExcute).ObservesProperty(() => CanSave);
  438. SaveAsFlattenCommand = new DelegateCommand(saveAsFlatten);
  439. SaveAsFile = new DelegateCommand(() => { saveAsFile(); });
  440. UndoCommand = new DelegateCommand(Undo);
  441. RedoCommand = new DelegateCommand(Redo);
  442. ShareCommand = new DelegateCommand(share);
  443. PropertyCommand = new DelegateCommand(property);
  444. ShowInFolderCommand = new DelegateCommand(ShowInFolder);
  445. TabControlSelectionChangedCommand = new DelegateCommand<object>(TabControlSelectonChangedEvent);
  446. CompressCommand = new DelegateCommand(compress);
  447. MergeFileCommand = new DelegateCommand(mergeFile);
  448. EncryptCommand = new DelegateCommand(encrypt);
  449. DecryptCommand = new DelegateCommand(decrypt);
  450. ConvertCommand = new DelegateCommand<string>(convert);
  451. CloseWindowCommand = new DelegateCommand(closeWindow);
  452. OpenFileCommand = new DelegateCommand(openfile);
  453. HelpCommand = new DelegateCommand<string>(help);
  454. CreateBlankFileCommand = new DelegateCommand(createBlankFile);
  455. ViwerRegionName = RegionNames.ViwerRegionName;
  456. SplitViewerRegionName = RegionNames.Viewer_SplitRegionName;
  457. BOTARegionName = RegionNames.BOTARegionName;
  458. PropertyRegionName = RegionNames.PropertyRegionName;
  459. BottomToolRegionName = RegionNames.BottomToolRegionName;
  460. ReadModeRegionName = RegionNames.ReadModeRegionName;
  461. MenuEnterReadMode = new DelegateCommand<object>(MenuEnterReadModeEvent);
  462. PrintCommand = new DelegateCommand(ShowPrintDialog);
  463. SettingsCommand = new DelegateCommand(SettingsEvent);
  464. CreateLinkCommand = new DelegateCommand<object>(CreateLinkEvent);
  465. //未显示时无法注册上Region名称
  466. ToolContentVisible = Visibility.Visible;
  467. ToolsBarContentVisible = Visibility.Visible;
  468. OCRContentVisible = Visibility.Visible;
  469. TipVisible = Visibility.Visible;
  470. TipContentRegionName = RegionNames.TipContentRegionName;
  471. LeftTipContentRegionName = RegionNames.LeftTipContentRegionName;
  472. OCRViewerRegionName = RegionNames.OCRViewerRegionName;
  473. ToolContentRegionName = Guid.NewGuid().ToString();
  474. ToolsBarContentRegionName = Guid.NewGuid().ToString();
  475. ConverterBarContentRegionName = Guid.NewGuid().ToString();
  476. TextEditContentRegionName = Guid.NewGuid().ToString();
  477. ToolContentVisible = Visibility.Collapsed;
  478. ToolsBarContentVisible = Visibility.Collapsed;
  479. OCRContentVisible = Visibility.Collapsed;
  480. TipVisible = Visibility.Collapsed;
  481. regionNameByTabItem = new Dictionary<string, string>();
  482. barContentByTabItem = new Dictionary<string, string>();
  483. InitialregionNameByTabItem(ref regionNameByTabItem);
  484. InitialbarContentByTabItem(ref barContentByTabItem);
  485. eventAggregator.GetEvent<EnterSelectedEditToolEvent>().Subscribe(EnterEditTools, e => e.Unicode == unicode);
  486. eventAggregator.GetEvent<CloseEditToolEvent>().Subscribe(CloseEditTool, e => e.Unicode == unicode);
  487. eventAggregator.GetEvent<ShowTipEvent>().Subscribe(ShowSelectedTip, e => e.Unicode == unicode);
  488. //TODO:根据缓存 选择用户上次选择的菜单
  489. EnterSelectedBar("TabItemAnnotation");
  490. }
  491. /// <summary>
  492. ///创建空白文档
  493. /// </summary>
  494. private async void createBlankFile()
  495. {
  496. App.mainWindowViewModel.AddTab.Execute();
  497. await Task.Delay(30);
  498. (App.mainWindowViewModel.SelectedItem.DataContext as MainContentViewModel).CreateFile();
  499. }
  500. private void help(string args)
  501. {
  502. string url = "";
  503. switch (args)
  504. {
  505. case "Guid":
  506. //TODO 打开内嵌文档
  507. break;
  508. case "Online":
  509. url = @"https://www.pdfreaderpro.com/windows/help";
  510. break;
  511. case "More":
  512. url = @"https://www.pdfreaderpro.com/product?utm_source=MacApp&utm_campaign=ProductLink&utm_medium=PdfProduct";
  513. break;
  514. case "Template":
  515. url = @"https://www.pdfreaderpro.com/templates?utm_source=MacApp&utm_campaign=TemplatesLink&utm_medium=PdfTemplates";
  516. break;
  517. case "Blog":
  518. //TODO:显示订阅电子报弹窗
  519. break;
  520. case "ComPDF":
  521. url = @"https://www.compdf.com/?utm_source=macapp&utm_medium=pdfmac&utm_campaign=compdfkit-promp";
  522. break;
  523. case "FeedBack":
  524. //调用邮箱 发送邮件
  525. StringBuilder sr = new StringBuilder();
  526. sr.AppendFormat("{0} - {1};{2};{3} - {4}", App.Name, App.Version, "Propose a New Feature", ServiceHelper.ComputerInfo, ServiceHelper.SystemInfo);
  527. System.Diagnostics.Process.Start(string.Format("mailto:support@pdfreaderpro.com?subject={0}", sr));
  528. break;
  529. default:
  530. break;
  531. }
  532. if(!string.IsNullOrEmpty(url))
  533. {
  534. //需要跳转网页的情况
  535. System.Diagnostics.Process.Start(url);
  536. }
  537. }
  538. /// <summary>
  539. /// 打开文件,跟首页的打开文件有区别,需要新开一个页签
  540. /// </summary>
  541. private void openfile()
  542. {
  543. OpenFileDialog openFileDialog = new OpenFileDialog();
  544. openFileDialog.Filter = Properties.Resources.OpenDialogFilter;
  545. openFileDialog.Multiselect = true;
  546. if ((bool)openFileDialog.ShowDialog())
  547. {
  548. if (openFileDialog.FileNames.Count() == 1)
  549. {
  550. if (App.OpenedFileList.Contains(openFileDialog.FileName))
  551. {
  552. App.mainWindowViewModel.SelectItem(openFileDialog.FileName);
  553. }
  554. else
  555. {
  556. App.mainWindowViewModel.AddTabItem(openFileDialog.FileName);
  557. }
  558. ToolMethod.SetFileThumbImg(openFileDialog.FileName);
  559. }
  560. else
  561. {
  562. var fileList = openFileDialog.FileNames.ToList().Where(x => !App.OpenedFileList.Exists(y => y == x)).ToList();
  563. if (fileList.Count <= 0)
  564. {
  565. App.mainWindowViewModel.SelectItem(openFileDialog.FileName);
  566. return;
  567. }
  568. mainViewModel.OpenFile(fileList[0]);
  569. for (int i = 1; i < fileList.Count(); i++)
  570. {
  571. if (!App.OpenedFileList.Contains(fileList[i]))
  572. {
  573. App.mainWindowViewModel.AddTabItem(fileList[i]);
  574. }
  575. ToolMethod.SetFileThumbImg(fileList[i]);
  576. }
  577. }
  578. }
  579. }
  580. /// <summary>
  581. /// 关闭当前窗体
  582. /// </summary>
  583. private void closeWindow()
  584. {
  585. App.Current.MainWindow.Close();
  586. }
  587. /// <summary>
  588. /// 转档
  589. /// </summary>
  590. /// <param name="obj"></param>
  591. private void convert(string obj)
  592. {
  593. if (!string.IsNullOrEmpty(obj))
  594. {
  595. DialogParameters value = new DialogParameters();
  596. value.Add(ParameterNames.PDFViewer, PDFViewer);
  597. switch (obj)
  598. {
  599. case "Word":
  600. dialogs.ShowDialog(DialogNames.ConverterWordDialog, value, e =>
  601. {
  602. ConverterDialogsModel converterDialogsModel = new ConverterDialogsModel();
  603. converterDialogsModel.OnOpened((DialogResult)e);
  604. });
  605. break;
  606. case "Excel":
  607. dialogs.ShowDialog(DialogNames.ConverterExcelDialog, value, e =>
  608. {
  609. ConverterDialogsModel converterDialogsModel = new ConverterDialogsModel();
  610. converterDialogsModel.OnOpened((DialogResult)e);
  611. });
  612. break;
  613. case "PPT":
  614. dialogs.ShowDialog(DialogNames.ConverterPPTDialog, value, e =>
  615. {
  616. ConverterDialogsModel converterDialogsModel = new ConverterDialogsModel();
  617. converterDialogsModel.OnOpened((DialogResult)e);
  618. });
  619. break;
  620. case "RTF":
  621. dialogs.ShowDialog(DialogNames.ConverterRTFDialog, value, e =>
  622. {
  623. ConverterDialogsModel converterDialogsModel = new ConverterDialogsModel();
  624. converterDialogsModel.OnOpened((DialogResult)e);
  625. });
  626. break;
  627. case "CSV":
  628. dialogs.ShowDialog(DialogNames.ConverterCSVDialog, value, e =>
  629. {
  630. ConverterDialogsModel converterDialogsModel = new ConverterDialogsModel();
  631. converterDialogsModel.OnOpened((DialogResult)e);
  632. });
  633. break;
  634. case "HTML":
  635. dialogs.ShowDialog(DialogNames.ConverterHTMLDialog, value, e =>
  636. {
  637. ConverterDialogsModel converterDialogsModel = new ConverterDialogsModel();
  638. converterDialogsModel.OnOpened((DialogResult)e);
  639. });
  640. break;
  641. case "Text":
  642. dialogs.ShowDialog(DialogNames.ConverterTextDialog, value, e =>
  643. {
  644. ConverterDialogsModel converterDialogsModel = new ConverterDialogsModel();
  645. converterDialogsModel.OnOpened((DialogResult)e);
  646. });
  647. break;
  648. case "Image":
  649. dialogs.ShowDialog(DialogNames.ConverterImgDialog, value, e =>
  650. {
  651. ConverterDialogsModel converterDialogsModel = new ConverterDialogsModel();
  652. converterDialogsModel.OnOpened((DialogResult)e);
  653. });
  654. break;
  655. default:
  656. break;
  657. }
  658. }
  659. }
  660. /// <summary>
  661. /// 解密
  662. /// </summary>
  663. private void decrypt()
  664. {
  665. if (!PDFViewer.Document.IsEncrypted)
  666. {
  667. MessageBoxEx.Show("No security settings available ");
  668. }
  669. else
  670. {
  671. VerifyPasswordResult result = SecurityHelper.VerifyPasswordByPasswordKind(PDFViewer.Document, EnumPasswordKind.StatusPermissionsPassword, dialogs);
  672. if (result.IsDiscryptied)
  673. {
  674. if (result.Password != null)
  675. {
  676. string filePath = PDFViewer.Document.FilePath;
  677. PDFViewer.Document.Release();
  678. PDFViewer.InitDocument(filePath);
  679. PDFViewer.Document.UnlockWithPassword(result.Password);
  680. }
  681. DialogParameters value = new DialogParameters();
  682. value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
  683. dialogs.ShowDialog(DialogNames.DeleteSafetySettingsDialog, value, e => { });
  684. }
  685. }
  686. }
  687. /// <summary>
  688. /// 加密
  689. /// </summary>
  690. private void encrypt()
  691. {
  692. if (!this.SecurityInfo.IsPasswordChanged)
  693. {
  694. VerifyPasswordResult result = SecurityHelper.VerifyPasswordByPasswordKind(PDFViewer.Document, EnumPasswordKind.StatusPermissionsPassword, dialogs);
  695. if (result.IsDiscryptied)
  696. {
  697. if (result.Password != null)
  698. {
  699. string filePath = PDFViewer.Document.FilePath;
  700. PDFViewer.Document.Release();
  701. PDFViewer.InitDocument(filePath);
  702. PDFViewer.Document.UnlockWithPassword(result.Password);
  703. }
  704. }
  705. }
  706. DialogParameters value = new DialogParameters();
  707. value.Add(ParameterNames.PDFViewer, this.PDFViewer);
  708. value.Add(ParameterNames.ViewContentViewModel, this);
  709. dialogs.ShowDialog(DialogNames.SetPasswordDialog, value, e =>
  710. {
  711. if (e.Result == ButtonResult.OK)
  712. {
  713. SecurityHelper.IsPasswordChanged = true;
  714. if (this.SecurityInfo.IsPasswordChanged)
  715. {
  716. this.PDFViewer.UndoManager.CanSave = true;
  717. }
  718. this.events.GetEvent<ShowTipEvent>().Publish(new ShowTipEventArgs() { enumTipKind = EnumTipKind.StatusSetPasswordSuccessfully, Unicode = unicode });
  719. }
  720. });
  721. }
  722. /// <summary>
  723. /// 合并
  724. /// </summary>
  725. private void mergeFile()
  726. {
  727. DialogParameters value = new DialogParameters();
  728. value.Add(ParameterNames.PDFViewer, PDFViewer);
  729. dialogs.ShowDialog(DialogNames.MergeDialog, value, e => { });
  730. }
  731. /// <summary>
  732. /// 压缩
  733. /// </summary>
  734. private void compress()
  735. {
  736. DialogParameters value = new DialogParameters();
  737. value.Add(ParameterNames.PDFViewer, PDFViewer);
  738. dialogs.ShowDialog(DialogNames.CompressDialog, value, e =>
  739. {
  740. CompressDialogModel compressDialogModel = new CompressDialogModel();
  741. compressDialogModel.OnOpened((Prism.Services.Dialogs.DialogResult)e);
  742. });
  743. }
  744. /// <summary>
  745. /// 设置Tip状态栏的显示状态
  746. /// </summary>
  747. /// <param name="show">是否显示</param>
  748. public void ShowTip(bool show)
  749. {
  750. if (show)
  751. {
  752. TipVisible = Visibility.Visible;
  753. }
  754. else
  755. {
  756. TipVisible = Visibility.Collapsed;
  757. }
  758. }
  759. /// <summary>
  760. /// 设置LeftTip状态栏的显示状态
  761. /// </summary>
  762. /// <param name="show">是否显示</param>
  763. public void ShowLeftTip(bool show)
  764. {
  765. if (show)
  766. {
  767. LeftTipVisible = Visibility.Visible;
  768. }
  769. else
  770. {
  771. LeftTipVisible = Visibility.Collapsed;
  772. }
  773. }
  774. public void CheckHaveAllPermission()
  775. {
  776. if (!SecurityHelper.CheckHaveAllPermissions(PDFViewer.Document))
  777. {
  778. ShowLeftTip(true);
  779. NavigationParameters param = new NavigationParameters();
  780. param.Add(ParameterNames.PDFViewer, PDFViewer);
  781. region.RequestNavigate(LeftTipContentRegionName, "FileRestrictedTip", param);
  782. }
  783. }
  784. public void ShowSelectedTip(ShowTipEventArgs showTipEventArgs)
  785. {
  786. switch (showTipEventArgs.enumTipKind)
  787. {
  788. case EnumTipKind.StatusNone:
  789. ShowLeftTip(false);
  790. break;
  791. case EnumTipKind.StatusSetPasswordSuccessfully:
  792. ShowLeftTip(true);
  793. region.RequestNavigate(LeftTipContentRegionName, "SetPasswordSuccessfullyTip");
  794. break;
  795. default: break;
  796. }
  797. }
  798. /// <summary>
  799. /// 右键菜单创建链接
  800. /// </summary>
  801. /// <param name="obj"></param>
  802. private void CreateLinkEvent(object obj)
  803. {
  804. if (obj is object[] objArry)
  805. {
  806. if (objArry[0] is AnnotToolContentViewModel toolContentViewModel && objArry[1] is AnnotCommandArgs annotCommand)
  807. {
  808. LinkAnnotArgs linkArgs = new LinkAnnotArgs();
  809. linkArgs.URI = string.Empty;
  810. linkArgs.LinkType = LINK_TYPE.GOTO;
  811. linkArgs.PageIndex = annotCommand.PageIndex;
  812. //linkArgs.InvokeLinkSaveCalled(this, EventArgs.Empty);
  813. this.IsRightMenuCreateLink = true;
  814. List<AnnotHandlerEventArgs> lists = new List<AnnotHandlerEventArgs>();
  815. lists.Add(linkArgs);
  816. AnnotHandlerEventArgs annotArgs = toolContentViewModel.GetLink(lists);
  817. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  818. PDFViewer.SetToolParam(annotArgs);
  819. this.IsPropertyOpen = true;
  820. }
  821. }
  822. }
  823. /// <summary>
  824. /// 在文件资源管理器中显示
  825. /// </summary>
  826. private void ShowInFolder()
  827. {
  828. CommonHelper.ShowFileBrowser(PDFViewer.Document.FilePath);
  829. }
  830. private void property()
  831. {
  832. DialogParameters valuePairs = new DialogParameters();
  833. valuePairs.Add(ParameterNames.PDFDocument, PDFViewer.Document);
  834. dialogs.ShowDialog(DialogNames.PropertyDialog, valuePairs, null);
  835. }
  836. private void share()
  837. {
  838. try
  839. {
  840. var path = PDFViewer.Document.FilePath;
  841. string subject = "分享至" + " " + PDFViewer.Document.FileName;
  842. System.Diagnostics.Process.Start("outlook", "/a,\"" + path + "\"" + "/m \"" + "&subject=" + subject + "\"");
  843. }
  844. catch
  845. {
  846. AlertsMessage alertsMessage = new AlertsMessage();
  847. alertsMessage.ShowDialog("", "未检测到Ooutlook软件,请先安装Outlook", "OK");
  848. }
  849. }
  850. private void SettingsEvent()
  851. {
  852. dialogs.ShowDialog(DialogNames.SettingsDialog, null, null);
  853. }
  854. private bool CanSaveExcute()
  855. {
  856. return CanSave;
  857. }
  858. private void MenuEnterReadModeEvent(object obj)
  859. {
  860. }
  861. public void ShowPrintDialog()
  862. {
  863. DialogParameters printValue = new DialogParameters();
  864. printValue.Add(ParameterNames.PDFViewer, PDFViewer);
  865. printValue.Add(ParameterNames.FilePath, PDFViewer.Document.FileName);
  866. printValue.Add(ParameterNames.PrintCurrentPage, PDFViewer.CurrentIndex);
  867. dialogs.ShowDialog(DialogNames.HomePagePrinterDialog, printValue, e => { });
  868. }
  869. private void InitialregionNameByTabItem(ref Dictionary<string, string> dictionary)
  870. {
  871. dictionary.Add("TabItemPageEdit", ToolContentRegionName);
  872. dictionary.Add("TabItemTool", ToolsBarContentRegionName);
  873. //其他工具菜单栏共用一个ToolsBarContentRegionName
  874. dictionary.Add("TabItemAnnotation", ToolsBarContentRegionName);
  875. dictionary.Add("TabItemConvert", ConverterBarContentRegionName);
  876. dictionary.Add("TabItemScan", ToolsBarContentRegionName);
  877. dictionary.Add("TabItemEdit", TextEditContentRegionName);
  878. dictionary.Add("TabItemForm", ToolsBarContentRegionName);
  879. dictionary.Add("TabItemFill", ToolsBarContentRegionName);
  880. }
  881. private void InitialbarContentByTabItem(ref Dictionary<string, string> dictionary)
  882. {
  883. dictionary.Add("TabItemPageEdit", "PageEditContent");
  884. dictionary.Add("TabItemTool", "ToolsBarContent");
  885. dictionary.Add("TabItemAnnotation", "AnnotToolContent");
  886. dictionary.Add("TabItemConvert", "ConverterBarContent");
  887. dictionary.Add("TabItemScan", "ScanContent");
  888. dictionary.Add("TabItemEdit", "TextEditToolContent");
  889. dictionary.Add("TabItemForm", "FormsToolContent");
  890. dictionary.Add("TabItemFill", "FillAndSignContent");
  891. }
  892. private void UpdateShowContent(string currentBar)
  893. {
  894. ToolContentVisible = Visibility.Collapsed;
  895. ToolsBarContentVisible = Visibility.Collapsed;
  896. ConverterBarContentVisible = Visibility.Collapsed;
  897. TextEditToolContentVisible = Visibility.Collapsed;
  898. OCRContentVisible = Visibility.Collapsed;
  899. switch (currentBar)
  900. {
  901. case "TabItemAnnotation":
  902. case "TabItemTool":
  903. case "TabItemForm":
  904. case "TabItemFill":
  905. ToolsBarContentVisible = Visibility.Visible;
  906. break;
  907. case "TabItemScan":
  908. ToolsBarContentVisible = Visibility.Visible;
  909. OCRContentVisible = Visibility.Visible;
  910. break;
  911. case "TabItemEdit":
  912. TextEditToolContentVisible = Visibility.Visible;
  913. break;
  914. case "TabItemConvert":
  915. ConverterBarContentVisible = Visibility.Visible;
  916. break;
  917. case "TabItemPageEdit":
  918. case "HeaderFooterContent":
  919. case "BatesContent":
  920. case "WatermarkContent":
  921. case "BackgroundContent":
  922. case "RedactionContent":
  923. ToolContentVisible = Visibility.Visible;
  924. break;
  925. default:
  926. break;
  927. }
  928. PDFEditMode(currentBar);
  929. FormMode(currentBar);
  930. }
  931. private void PDFEditMode(string currentBar)
  932. {
  933. if (currentBar == "TabItemEdit")
  934. {
  935. if (PDFViewer != null)
  936. {
  937. PDFViewer.SetMouseMode(MouseModes.PDFEdit);
  938. //SelectedPrpoertyPanel("TextEditProperty", null);
  939. //IsPropertyOpen = true;
  940. }
  941. }
  942. else
  943. {
  944. if (PDFViewer != null && PDFViewer.MouseMode == MouseModes.PDFEdit)
  945. {
  946. IsPropertyOpen = false;
  947. PDFViewer.SetMouseMode(MouseModes.PanTool);
  948. }
  949. }
  950. }
  951. private void FormMode(string currentBar)
  952. {
  953. if (currentBar == "TabItemForm")
  954. {
  955. if (PDFViewer != null)
  956. {
  957. PDFViewer.SetMouseMode(MouseModes.FormEditTool);
  958. }
  959. }
  960. else
  961. {
  962. if (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool)
  963. {
  964. PDFViewer.SetMouseMode(MouseModes.PanTool);
  965. }
  966. }
  967. }
  968. private void UndoManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  969. {
  970. if (!isInPageEdit)
  971. {
  972. //不处于页面编辑模式下时,根据PDFVIewer的undo redo状态来更新按钮状态
  973. //页面编辑模式下,按钮状态根据页面编辑的undo redo来显示
  974. if (e.PropertyName == "CanUndo")
  975. {
  976. CanUndo = PDFViewer.UndoManager.CanUndo;
  977. }
  978. if (e.PropertyName == "CanRedo")
  979. {
  980. CanRedo = PDFViewer.UndoManager.CanRedo;
  981. }
  982. }
  983. if (e.PropertyName == "CanSave")
  984. {
  985. CanSave = PDFViewer.UndoManager.CanSave;
  986. }
  987. }
  988. /// <summary>
  989. /// 选项卡切换事件
  990. /// </summary>
  991. /// <param name="e"></param>
  992. private void TabControlSelectonChangedEvent(object e)
  993. {
  994. var args = e as SelectionChangedEventArgs;
  995. if (args != null)
  996. {
  997. var item = args.AddedItems[0] as TabItem;
  998. CurrentBar = item.Name;
  999. if (previousBar != CurrentBar)
  1000. {
  1001. if (CurrentBar == "TabItemPageEdit")//如果是页面编辑则进入页面编辑模式
  1002. {
  1003. EnterToolMode(barContentByTabItem[CurrentBar]);
  1004. isInPageEdit = true;
  1005. }
  1006. else//其余情况直接导航至对应的工具栏即可,不需要清空之前的content,region里是单例模式
  1007. {
  1008. EnterSelectedBar(CurrentBar);
  1009. isInPageEdit = false;
  1010. }
  1011. previousBar = CurrentBar;
  1012. }
  1013. }
  1014. }
  1015. /// <summary>
  1016. /// 阅读模式
  1017. /// </summary>
  1018. /// <param name="viewContent"></param>
  1019. public async void RbtnReadMode()
  1020. {
  1021. App.mainWindowViewModel.SelectedItem.IsInReadctonMode = true;
  1022. mainViewModel.IsBookMode = true;
  1023. IsLoading = Visibility.Visible;
  1024. await Task.Delay(1);
  1025. PDFViewer.SetMouseMode(MouseModes.PanTool);
  1026. NavigationParameters param = new NavigationParameters();
  1027. param.Add(ParameterNames.PDFViewer, PDFViewer);
  1028. param.Add(ParameterNames.ViewContentViewModel, this);
  1029. region.RequestNavigate(ToolContentRegionName, "ReadViewContent", param);
  1030. //ShowContent(CurrentBar, true);
  1031. if (GridToolRow != 0)
  1032. {
  1033. GridToolRow = 0;
  1034. }
  1035. if (GridToolRowSpan != 4)
  1036. {
  1037. GridToolRowSpan = 4;
  1038. }
  1039. //isInPageEdit = true;
  1040. UpdateShowContent("TabItemPageEdit");
  1041. IsLoading = Visibility.Collapsed;
  1042. }
  1043. /// <summary>
  1044. /// 退出阅读模式
  1045. /// </summary>
  1046. public async void UnReadModel()
  1047. {
  1048. App.mainWindowViewModel.SelectedItem.IsInReadctonMode = false;
  1049. mainViewModel.IsBookMode = false;
  1050. IsLoading = Visibility.Visible;
  1051. await Task.Delay(1);
  1052. //PDFViewer.MouseMode = MouseModes.None;
  1053. if (region.Regions.ContainsRegionWithName(ViwerRegionName))
  1054. {
  1055. if (region.Regions[ViwerRegionName].Views.Contains(PDFViewer))
  1056. {
  1057. var contentRegion = region.Regions[ViwerRegionName];
  1058. contentRegion.Remove(PDFViewer);
  1059. }
  1060. region.AddToRegion(ViwerRegionName, PDFViewer);
  1061. }
  1062. if (string.IsNullOrEmpty(CurrentBar) || CurrentBar.Equals("TabItemPageEdit", StringComparison.OrdinalIgnoreCase))
  1063. {
  1064. EnterSelectedBar("TabItemAnnotation");
  1065. }
  1066. else
  1067. {
  1068. EnterSelectedBar(CurrentBar);
  1069. }
  1070. bool isExist = false;
  1071. if (region.Regions.ContainsRegionWithName(TipContentRegionName))
  1072. {
  1073. var views = region.Regions[TipContentRegionName].Views;
  1074. foreach (var item in views)
  1075. {
  1076. if (item is Views.TipContent.ReadModelTip readModelTip)
  1077. {
  1078. isExist = true;
  1079. break;
  1080. }
  1081. }
  1082. }
  1083. if (isExist == false)
  1084. {
  1085. region.RequestNavigate(TipContentRegionName, "ReadModelTip");
  1086. }
  1087. IsLoading = Visibility.Collapsed;
  1088. ShowTip(true);
  1089. await Task.Delay(3000);
  1090. //ReadModelTip = Visibility.Collapsed;
  1091. TipVisible = Visibility.Collapsed;
  1092. }
  1093. #region PDFViewer鼠标滚轮缩放事件
  1094. public void PdfViewer_MouseWheelZoomHandler(object sender, bool e)
  1095. {
  1096. double newZoom = CheckZoomLevel(PDFViewer.ZoomFactor + (e ? 0.01 : -0.01), e);
  1097. PDFViewer.Zoom(newZoom);
  1098. }
  1099. public double CheckZoomLevel(double zoom, bool IsGrowth)
  1100. {
  1101. double standardZoom = 100;
  1102. if (zoom <= 0.01)
  1103. {
  1104. return 0.01;
  1105. }
  1106. if (zoom >= 10)
  1107. {
  1108. return 10;
  1109. }
  1110. zoom *= 100;
  1111. for (int i = 0; i < zoomLevel.Length - 1; i++)
  1112. {
  1113. if (zoom > zoomLevel[i] && zoom <= zoomLevel[i + 1] && IsGrowth)
  1114. {
  1115. standardZoom = zoomLevel[i + 1];
  1116. break;
  1117. }
  1118. if (zoom >= zoomLevel[i] && zoom < zoomLevel[i + 1] && !IsGrowth)
  1119. {
  1120. standardZoom = zoomLevel[i];
  1121. break;
  1122. }
  1123. }
  1124. return standardZoom / 100;
  1125. }
  1126. #endregion PDFViewer鼠标滚轮缩放事件
  1127. #region Navigate
  1128. public void OnNavigatedTo(NavigationContext navigationContext)
  1129. {
  1130. if (isOpenFile)
  1131. return;
  1132. var mainVM = navigationContext.Parameters[ParameterNames.MainViewModel] as MainContentViewModel;
  1133. if (mainVM != null)
  1134. {
  1135. mainViewModel = mainVM;
  1136. mainViewModel.viewContentViewModel = this;
  1137. }
  1138. var pdfview = navigationContext.Parameters[ParameterNames.PDFViewer] as CPDFViewer;
  1139. if (pdfview != null)
  1140. {
  1141. PDFViewer = pdfview;
  1142. if (pdfview.Tag != null)
  1143. {
  1144. //保存密码
  1145. PassWord = pdfview.Tag.ToString();
  1146. }
  1147. loadFile();
  1148. CheckHaveAllPermission();
  1149. }
  1150. isOpenFile = true;
  1151. }
  1152. public bool IsNavigationTarget(NavigationContext navigationContext)
  1153. {
  1154. if (navigationContext != null)
  1155. {
  1156. //另存为打开导航进来时 不能新建一个实例
  1157. return true;
  1158. }
  1159. else
  1160. {
  1161. //一次性打开多个文件时,需要新建实例
  1162. return false;
  1163. }
  1164. }
  1165. public void OnNavigatedFrom(NavigationContext navigationContext)
  1166. {
  1167. }
  1168. #endregion Navigate
  1169. #region 方法
  1170. /// <summary>
  1171. /// 视图面板 切换分屏模式
  1172. /// </summary>
  1173. /// <param name="mode"></param>
  1174. public void EnterSplitMode(SplitMode mode)
  1175. {
  1176. ///通知UI层更改布局
  1177. this.events.GetEvent<SplitEvent>().Publish(new SplitEventArgs() { Unicode = unicode, Mode = mode });
  1178. }
  1179. private void Undo()
  1180. {
  1181. if (isInPageEdit)
  1182. {
  1183. //执行页面编辑的Undo
  1184. PageEditUndo?.Invoke();
  1185. }
  1186. else
  1187. {
  1188. PDFViewer.UndoManager.Undo();
  1189. }
  1190. }
  1191. private void Redo()
  1192. {
  1193. if (isInPageEdit)
  1194. {
  1195. //执行页面编辑的Redo
  1196. PageEditRedo?.Invoke();
  1197. }
  1198. else
  1199. {
  1200. PDFViewer.UndoManager.Redo();
  1201. }
  1202. }
  1203. private void LoadControl()
  1204. {
  1205. //在构造函数中使用Region需要借助Dispatcher 确保UI已经加载完成,加载BOTA区域
  1206. // 非必要情况不要使用该异步方法,可能会导致一次性加载多个文件时出现因异步引起的regionname 错乱问题
  1207. //System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
  1208. // {
  1209. NavigationParameters parameters = new NavigationParameters();
  1210. parameters.Add(ParameterNames.PDFViewer, PDFViewer);
  1211. parameters.Add(ParameterNames.ViewContentViewModel, this);
  1212. region.RequestNavigate(BOTARegionName, "BOTAContent", parameters);
  1213. region.RequestNavigate(BottomToolRegionName, "BottomToolContent", parameters);
  1214. region.RequestNavigate(ReadModeRegionName, "ReadModeContent", parameters);
  1215. region.RequestNavigate(SplitViewerRegionName, "SplitScreenContent", parameters);
  1216. //TODO 根据上一次关闭记录的菜单,选中TabItem
  1217. EnterSelectedBar("TabItemAnnotation");
  1218. //}
  1219. //));
  1220. //if (App.IsBookMode)
  1221. //{
  1222. // RbtnReadMode();
  1223. //}
  1224. //else
  1225. //{
  1226. // UnReadModel();
  1227. //}
  1228. }
  1229. /// <summary>
  1230. /// 各个注释(选中和创建注释)导航到对应注释的属性面板
  1231. /// </summary>
  1232. /// <param name="Content"></param>
  1233. /// <param name="annotPropertyPanel"></param>
  1234. public void SelectedPrpoertyPanel(string Content, AnnotPropertyPanel annotPropertyPanel)
  1235. {
  1236. NavigationParameters parameters = new NavigationParameters();
  1237. //传其他参数:文档类,空注释面板;
  1238. parameters.Add(ParameterNames.PDFViewer, PDFViewer);
  1239. parameters.Add(ParameterNames.PropertyPanelContentViewModel, annotPropertyPanel);
  1240. parameters.Add(ParameterNames.ViewContentViewModel, this);
  1241. region.RequestNavigate(PropertyRegionName, Content, parameters);
  1242. }
  1243. /// <summary>
  1244. /// 将PDFViwer添加到Region
  1245. /// </summary>
  1246. private void loadFile()
  1247. {
  1248. PDFViewer.MouseWheelZoomHandler += PdfViewer_MouseWheelZoomHandler;
  1249. PDFViewer.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
  1250. CanSave = PDFViewer.UndoManager.CanSave;
  1251. CanUndo = PDFViewer.UndoManager.CanUndo;
  1252. CanRedo = PDFViewer.UndoManager.CanRedo;
  1253. region.Regions[ViwerRegionName].RemoveAll();
  1254. //OpenFileInfo 内容赋值给PDFViewer
  1255. GetOpenFileInfo();
  1256. region.AddToRegion(ViwerRegionName, PDFViewer);
  1257. }
  1258. private void GetOpenFileInfo()
  1259. {
  1260. OpenFileInfo = SettingHelper.GetFileInfo(PDFViewer.Document.FilePath);
  1261. if (OpenFileInfo != null)
  1262. {
  1263. if (OpenFileInfo.LastViewMode != PDFViewer.ModeView)
  1264. {
  1265. PDFViewer.ChangeViewMode(OpenFileInfo.LastViewMode);
  1266. }
  1267. if (OpenFileInfo.LastFitMode != PDFViewer.ModeFit)
  1268. {
  1269. PDFViewer.ChangeFitMode(OpenFileInfo.LastFitMode);
  1270. }
  1271. if (OpenFileInfo.LastFitMode == ComPDFKitViewer.FitMode.FitFree)
  1272. {
  1273. PDFViewer.Zoom(OpenFileInfo.LastZoom);
  1274. }
  1275. if (OpenFileInfo.LastPageIndex != PDFViewer.CurrentIndex)
  1276. {
  1277. PDFViewer.GoToPage(OpenFileInfo.LastPageIndex);
  1278. }
  1279. PDFViewer.SetSplitMode(OpenFileInfo.LastSplitMode);
  1280. PDFViewer.SetShowLink(OpenFileInfo.ShowHighLightLink);
  1281. if (OpenFileInfo.LastPageSpace)
  1282. {
  1283. PDFViewer.SetPageSpacing(8);
  1284. }
  1285. else
  1286. {
  1287. PDFViewer.SetPageSpacing(0);
  1288. }
  1289. if (OpenFileInfo.LastDrawMode == ComPDFKitViewer.DrawModes.Draw_Mode_Custom && OpenFileInfo.LastFillColor != 0)
  1290. {
  1291. PDFViewer.SetDrawMode(OpenFileInfo.LastDrawMode, OpenFileInfo.LastFillColor);
  1292. }
  1293. else
  1294. {
  1295. PDFViewer.SetDrawMode(OpenFileInfo.LastDrawMode);
  1296. }
  1297. }
  1298. }
  1299. /// <summary>
  1300. /// 已有路径文档的保存逻辑
  1301. /// </summary>
  1302. public bool saveFile()
  1303. {
  1304. try
  1305. {
  1306. if (string.IsNullOrEmpty(PDFViewer.Document.FilePath))
  1307. return saveAsFile();
  1308. //文档已被修复时 提示另存为
  1309. if (PDFViewer.Document.HasRepaired)
  1310. {
  1311. AlertsMessage alertsMessage = new AlertsMessage();
  1312. alertsMessage.ShowDialog("", "文件已被修复,建议另存为", "Cancel", "OK");
  1313. if (alertsMessage.result == ContentResult.Ok)
  1314. return saveAsFile();
  1315. else
  1316. return false;
  1317. }
  1318. //文件路径无法存在时
  1319. if (!File.Exists(PDFViewer.Document.FilePath))
  1320. {
  1321. AlertsMessage alertsMessage = new AlertsMessage();
  1322. alertsMessage.ShowDialog("", "文件路径不存在,需要另存为", "Cancel", "OK");
  1323. if (alertsMessage.result == ContentResult.Ok)
  1324. return saveAsFile();
  1325. else
  1326. return false;
  1327. }
  1328. //只读文件无法写入时,提示另存为
  1329. FileInfo fileInfo = new FileInfo(PDFViewer.Document.FilePath);
  1330. if (fileInfo.IsReadOnly)
  1331. {
  1332. AlertsMessage alertsMessage = new AlertsMessage();
  1333. alertsMessage.ShowDialog("", "文件为只读文件,需要另存为", "Cancel", "OK");
  1334. if (alertsMessage.result == ContentResult.Ok)
  1335. return saveAsFile();
  1336. else
  1337. return false;
  1338. }
  1339. if (SecurityInfo.IsPasswordChanged)
  1340. {
  1341. string currentFilePath = PDFViewer.Document.FilePath;
  1342. string tempFilePath = PDFViewer.Document.FilePath + ".temp.pdf";
  1343. string openPassword = null;
  1344. string permissionsPassword = null;
  1345. CPDFPermissionsInfo cPDFPermissionsInfo = CreateDefaultPermissionsInfo();
  1346. if (SecurityInfo.NeedOpenPassword)
  1347. {
  1348. openPassword = SecurityInfo.OpenPassword;
  1349. }
  1350. if (SecurityInfo.NeedPermissionsPassword)
  1351. {
  1352. permissionsPassword = SecurityInfo.PermissionsPassword;
  1353. cPDFPermissionsInfo = SecurityInfo.CPDFPermissionsInfo;
  1354. }
  1355. //方案一
  1356. if (false)
  1357. {
  1358. PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
  1359. AlertsMessage alertsMessage = new AlertsMessage();
  1360. alertsMessage.ShowDialog("", "文件安全设置已修改,需要另存为", "Cancel", "OK");
  1361. if (alertsMessage.result == ContentResult.Ok)
  1362. return saveAsFile();
  1363. else
  1364. return false;
  1365. }
  1366. else if (false)
  1367. {
  1368. //方案二
  1369. try
  1370. {
  1371. string currentPath = PDFViewer.Document.FilePath;
  1372. string tempPath = PDFViewer.Document.FilePath + ".temp.pdf";
  1373. //PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
  1374. PDFViewer.Document.WriteToFilePath(tempPath);
  1375. PDFViewer.CloseDocument();
  1376. PDFViewer.InitDocument(tempPath);
  1377. PDFViewer.Document.UnlockWithPassword(permissionsPassword);
  1378. PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
  1379. PDFViewer.Document.WriteToFilePath(currentPath);
  1380. PDFViewer.CloseDocument();
  1381. PDFViewer.InitDocument(currentPath);
  1382. System.IO.File.Delete(tempPath);
  1383. PDFViewer.Document.UnlockWithPassword(permissionsPassword);
  1384. CanSave = false;
  1385. return true;
  1386. }
  1387. catch
  1388. {
  1389. return false;
  1390. }
  1391. }
  1392. else if(false)
  1393. {
  1394. //方案三
  1395. PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
  1396. if (PDFViewer.Document.WriteToFilePath(PDFViewer.Document.FilePath))
  1397. {
  1398. DoAfterSaveAs(PDFViewer.Document.FilePath);
  1399. return true;
  1400. }
  1401. else
  1402. {
  1403. return false;
  1404. }
  1405. }
  1406. }
  1407. bool result;
  1408. if (SecurityInfo.IsPasswordChanged)
  1409. {
  1410. string openPassword = null;
  1411. string permissionsPassword = null;
  1412. CPDFPermissionsInfo cPDFPermissionsInfo = CreateDefaultPermissionsInfo();
  1413. if (SecurityInfo.NeedOpenPassword)
  1414. {
  1415. openPassword = SecurityInfo.OpenPassword;
  1416. }
  1417. if (SecurityInfo.NeedPermissionsPassword)
  1418. {
  1419. permissionsPassword = SecurityInfo.PermissionsPassword;
  1420. cPDFPermissionsInfo = SecurityInfo.CPDFPermissionsInfo;
  1421. }
  1422. PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
  1423. }
  1424. //result = PDFViewer.Document.WriteToLoadedPath();
  1425. result = PDFViewer.Document.WriteToFilePath(PDFViewer.Document.FilePath);
  1426. if (result)
  1427. {
  1428. PDFViewer.UndoManager.CanSave = false;
  1429. App.Current.Dispatcher.Invoke(() =>
  1430. {
  1431. //保存时更新缩略图
  1432. OpenFileInfo info = SettingHelper.GetFileInfo(PDFViewer.Document.FilePath);
  1433. try
  1434. {
  1435. if (!string.IsNullOrEmpty(info.ThumbImgPath) && !PDFViewer.Document.IsEncrypted)//加密的文档不获取缩略图
  1436. {
  1437. var size = PDFViewer.Document.GetPageSize(0);
  1438. System.Drawing.Bitmap bitmap = ToolMethod.RenderPageBitmapNoWait(PDFViewer.Document, (int)size.Width, (int)size.Height, 0, true, true);
  1439. string folderPath = System.IO.Path.Combine(App.CurrentPath, "CoverImage");
  1440. if (File.Exists(folderPath))
  1441. File.Delete(folderPath);
  1442. DirectoryInfo folder = new DirectoryInfo(folderPath);
  1443. if (!folder.Exists)
  1444. folder.Create();
  1445. string imagePath = info.ThumbImgPath;
  1446. if (!File.Exists(imagePath))//由加密文档变为非加密文档时 新建一个路径
  1447. {
  1448. string imageName = Guid.NewGuid().ToString();
  1449. imagePath = System.IO.Path.Combine(folderPath, imageName);
  1450. using (FileStream stream = new FileStream(imagePath, FileMode.Create))
  1451. {
  1452. bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
  1453. }
  1454. }
  1455. else
  1456. {
  1457. using (FileStream stream = new FileStream(imagePath, FileMode.Open))
  1458. {
  1459. bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
  1460. }
  1461. }
  1462. info.ThumbImgPath = imagePath;
  1463. SettingHelper.SetFileInfo(info);
  1464. }
  1465. }
  1466. catch
  1467. {
  1468. info.ThumbImgPath = null;
  1469. SettingHelper.SetFileInfo(info);
  1470. }
  1471. });
  1472. PDFViewer.ReloadDocument();
  1473. }
  1474. else
  1475. {
  1476. //文件被占用 保存失败时
  1477. AlertsMessage alertsMessage = new AlertsMessage();
  1478. alertsMessage.ShowDialog("", "文件被占用,需要另存为", "Cancel", "OK");
  1479. if (alertsMessage.result == ContentResult.Ok)
  1480. return saveAsFile();
  1481. else
  1482. return false;
  1483. }
  1484. return result;
  1485. }
  1486. catch { return false; }
  1487. }
  1488. /// <summary>
  1489. /// 另存为或新文档保存逻辑
  1490. /// </summary>
  1491. public bool saveAsFile(Action RedactionAction = null)
  1492. {
  1493. var dlg = new Microsoft.Win32.SaveFileDialog();
  1494. dlg.Filter = Properties.Resources.OpenDialogFilter;
  1495. dlg.FileName = PDFViewer.Document.FileName;
  1496. if (dlg.ShowDialog() == true && !string.IsNullOrEmpty(dlg.FileName))
  1497. {
  1498. bool result = false;
  1499. if (RedactionAction != null)
  1500. {
  1501. //保存前进行标记密文处理应用或擦除
  1502. RedactionAction.Invoke();
  1503. }
  1504. if (App.OpenedFileList.Contains(dlg.FileName))
  1505. {
  1506. //提示文件已经被打开
  1507. }
  1508. else
  1509. {
  1510. result = PDFViewer.Document.WriteToFilePath(dlg.FileName);
  1511. if (result)
  1512. {
  1513. DoAfterSaveAs(dlg.FileName);
  1514. }
  1515. else
  1516. {
  1517. //提示文件被其他软件占用 无法保存
  1518. //MessageBoxEx.Show(App.MainPageLoader.GetString("Main_TheFileOccupiedWarning"), "", Winform.MessageBoxButtons.OKCancel, new string[] { App.MainPageLoader.GetString("Main_SaveAs"), App.MainPageLoader.GetString("Main_Cancel") })
  1519. }
  1520. ;
  1521. }
  1522. return result;
  1523. }
  1524. else
  1525. return false;
  1526. }
  1527. /// <summary>
  1528. /// 另存为Flatten
  1529. /// </summary>
  1530. private void saveAsFlatten()
  1531. {
  1532. var dlg = new SaveFileDialog();
  1533. dlg.Filter = Properties.Resources.OpenDialogFilter;
  1534. dlg.FileName = PDFViewer.Document.FileName.Substring(0, PDFViewer.Document.FileName.LastIndexOf(".")) + "_Flatten.pdf";
  1535. if (dlg.ShowDialog() == true && !string.IsNullOrEmpty(dlg.FileName))
  1536. {
  1537. saveFile();
  1538. CPDFDocument kmdoc = CPDFDocument.InitWithFilePath(PDFViewer.Document.FileName);
  1539. if (kmdoc == null)
  1540. return;
  1541. bool result = kmdoc.WriteFlattenToFilePath(dlg.FileName);
  1542. if (result)
  1543. System.Diagnostics.Process.Start("explorer", "/select,\"" + dlg.FileName + "\"");
  1544. kmdoc.Release();
  1545. }
  1546. }
  1547. /// <summary>
  1548. /// 另存为后进行的操作
  1549. /// 重新打开新文档
  1550. /// </summary>
  1551. /// <param name="targetPath"></param>
  1552. public void DoAfterSaveAs(string targetPath)
  1553. {
  1554. App.OpenedFileList.Remove(targetPath);
  1555. string oldFilePath = targetPath;
  1556. PDFViewer.UndoManager.CanSave = false;
  1557. mainViewModel.OpenFile(targetPath);
  1558. //TODO:通知各模块更新PDFview对象
  1559. //var result = OpenFile(targetPath, true);
  1560. //if (result)
  1561. //{
  1562. // FileChanged.Invoke(this, null);
  1563. // Zoomer.PdfViewer = PdfViewer;
  1564. // PageSelector.PdfViewer = PdfViewer;
  1565. // ViewModeSelector.PdfViewer = PdfViewer;
  1566. // OpenFileInfo fileInfo = SettingHelper.GetFileInfo(oldFilePath);
  1567. // if (fileInfo != null)
  1568. // {
  1569. // PdfViewer.ChangeViewMode(fileInfo.LastViewMode);
  1570. // PdfViewer.ChangeFitMode(fileInfo.LastFitMode);
  1571. // if (fileInfo.LastFitMode == FitMode.FitFree)
  1572. // PdfViewer.Zoom(fileInfo.LastZoom);
  1573. // PdfViewer.GoToPage(fileInfo.LastPageIndex);
  1574. // if (fileInfo.LastDrawMode == DrawModes.Draw_Mode_Custom && fileInfo.LastFillColor != 0)
  1575. // PdfViewer.SetDrawMode(fileInfo.LastDrawMode, fileInfo.LastFillColor);
  1576. // else
  1577. // PdfViewer.SetDrawMode(fileInfo.LastDrawMode);
  1578. // }
  1579. //}
  1580. }
  1581. /// <summary>
  1582. /// 显示前添加内容到Region
  1583. /// </summary>
  1584. /// <param name="isPageEdit"></param>
  1585. private void ShowContent(string currentBar, bool isToolMode = false)
  1586. {
  1587. GridVisibility = Visibility.Visible;
  1588. //显示页面编辑或其他工具
  1589. if (currentBar == "TabItemPageEdit" || isToolMode)
  1590. {
  1591. if (currentBar == "TabItemPageEdit")//进入页面编辑
  1592. {
  1593. if (GridToolRow != 1)
  1594. {
  1595. GridToolRow = 1;
  1596. }
  1597. if (GridToolRowSpan != 3)
  1598. {
  1599. GridToolRowSpan = 3;
  1600. }
  1601. }
  1602. else//进入水印等其他工具模式
  1603. {
  1604. GridVisibility = Visibility.Collapsed;
  1605. if (GridToolRow != 0)
  1606. {
  1607. GridToolRow = 0;
  1608. }
  1609. if (GridToolRowSpan != 4)
  1610. {
  1611. GridToolRowSpan = 4;
  1612. }
  1613. }
  1614. //ToolContent的visible跟toolsbarContent 的visible是互斥的
  1615. UpdateShowContent(currentBar);
  1616. }
  1617. else
  1618. {
  1619. if (GridToolRow != 1)
  1620. {
  1621. GridToolRow = 1;
  1622. }
  1623. UpdateShowContent(currentBar);
  1624. }
  1625. }
  1626. /// <summary>
  1627. /// 从二级工具栏进入需要修改界面布局的场景
  1628. /// </summary>
  1629. /// <param name="EditToolName"></param>
  1630. private void EnterEditTools(StringWithUnicode EditToolName)
  1631. {
  1632. EnterSelectedEditTool(EditToolName);
  1633. }
  1634. private void CloseEditTool(EnumCloseModeUnicode enumCloseModeunicode)
  1635. {
  1636. EnumCloseMode enumCloseMode = enumCloseModeunicode.Status;
  1637. if (enumCloseMode == EnumCloseMode.StatusConfirm)
  1638. {
  1639. PDFViewer.Document.ReleasePages();
  1640. PDFViewer.ReloadDocument();
  1641. }
  1642. //如果是其他工具共用一个PDFview,退出工具模式后,需要重新添加到Region,否则不会显示
  1643. if (!region.Regions[ViwerRegionName].Views.Contains(PDFViewer))
  1644. {
  1645. region.AddToRegion(ViwerRegionName, PDFViewer);
  1646. }
  1647. CurrentBar = "TabItemTool";
  1648. EnterSelectedBar(CurrentBar);
  1649. }
  1650. /// <summary>
  1651. /// 二级菜单指定目标处理
  1652. /// </summary>
  1653. /// <param name="e"></param>
  1654. private void EnterSelectedEditTool(StringWithUnicode EditToolName)
  1655. {
  1656. CurrentBar = EditToolName.EditToolsContentName;
  1657. EnterToolMode(CurrentBar);
  1658. }
  1659. /// <summary>
  1660. /// 进入工具编辑(如页面编辑、水印、密文等)模式
  1661. /// </summary>
  1662. /// <param name="targetToolMode">要导航过去的控件名称</param>
  1663. /// <param name="valuePairs">导航需要传送的参数,为空时,默认传送PDFView和ViewContentViewModel</param>
  1664. private async void EnterToolMode(string targetToolMode, NavigationParameters valuePairs = null)
  1665. {
  1666. IsLoading = Visibility.Visible;
  1667. await Task.Delay(3);
  1668. NavigationParameters param = new NavigationParameters();
  1669. if (valuePairs == null)
  1670. {
  1671. param.Add(ParameterNames.PDFViewer, PDFViewer);
  1672. param.Add(ParameterNames.ViewContentViewModel, this);
  1673. }
  1674. else//有传入其他内容的参数时
  1675. {
  1676. param = valuePairs;
  1677. }
  1678. region.RequestNavigate(ToolContentRegionName, targetToolMode, param);
  1679. ShowContent(CurrentBar, true);
  1680. IsLoading = Visibility.Collapsed;
  1681. }
  1682. private void EnterSelectedBar(string currentBar)
  1683. {
  1684. NavigationParameters param = new NavigationParameters();
  1685. param.Add(ParameterNames.PDFViewer, PDFViewer);
  1686. param.Add(ParameterNames.ViewContentViewModel, this);
  1687. region.RequestNavigate(regionNameByTabItem[currentBar], barContentByTabItem[currentBar], param);
  1688. if (currentBar == "TabItemScan")
  1689. {
  1690. region.RequestNavigate(RegionNames.OCRViewerRegionName, "ScanViwer", param);
  1691. }
  1692. ShowContent(currentBar);
  1693. }
  1694. /// <summary>
  1695. /// 退出工具(水印、密文等)编辑模式,隐藏ToolContent
  1696. /// </summary>
  1697. public void ExitToolMode()
  1698. {
  1699. ToolContentVisible = Visibility.Collapsed;
  1700. if (isInPageEdit)
  1701. {
  1702. TabSelectedIndex = 0;
  1703. isInPageEdit = false;
  1704. }
  1705. }
  1706. #endregion 方法
  1707. }
  1708. }