ViewContentViewModel.cs 93 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555
  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_Master.CustomControl;
  11. using PDF_Master.Model;
  12. using System.Windows;
  13. using System.Windows.Controls;
  14. using System.IO;
  15. using ComPDFKitViewer.AnnotEvent;
  16. using PDF_Master.ViewModels.Tools;
  17. using Prism.Events;
  18. using PDF_Master.EventAggregators;
  19. using PDF_Master.Helper;
  20. using ComPDFKit.PDFDocument;
  21. using PDFSettings.Settings;
  22. using PDF_Master.Model.Dialog.ToolsDialogs.SaftyDialogs;
  23. using static PDF_Master.Model.Dialog.ToolsDialogs.SaftyDialogs.SetPasswordDialogModel;
  24. using PDF_Master.Model.Dialog.ToolsDialogs;
  25. using DryIoc;
  26. using PDF_Master.Model.Dialog.ConverterDialogs;
  27. using static PDF_Master.Model.Dialog.ToolsDialogs.SaftyDialogs.DeleteSafetySettintgsModel;
  28. using PDF_Master.Views.PropertyPanel.AnnotPanel;
  29. using System.Linq;
  30. using System.Text;
  31. using PDF_Master.Views.Tools;
  32. using System.Windows.Input;
  33. using PDF_Master.ViewModels.PropertyPanel.AnnotPanel;
  34. using ImTools;
  35. using PDF_Master.Properties;
  36. using PDF_Master.ViewModels.BOTA;
  37. using PDF_Master.Views.BOTA;
  38. using System.Drawing;
  39. using PDF_Master.ViewModels.Tools.AnnotManager;
  40. using PDF_Master.Model.FillAndSign;
  41. using PDF_Master.Views.PropertyPanel.ViewModular;
  42. using PDF_Master.Views.PropertyPanel;
  43. using System.Windows.Threading;
  44. namespace PDF_Master.ViewModels
  45. {
  46. public class ViewContentViewModel : BindableBase, INavigationAware
  47. {
  48. #region 文案
  49. private string T_file;
  50. public string T_File
  51. {
  52. get { return T_file; }
  53. set
  54. {
  55. SetProperty(ref T_file, value);
  56. }
  57. }
  58. private string T_save;
  59. public string T_Save
  60. {
  61. get { return T_save; }
  62. set
  63. {
  64. SetProperty(ref T_save, value);
  65. }
  66. }
  67. private string T_undo;
  68. public string T_Undo
  69. {
  70. get { return T_undo; }
  71. set
  72. {
  73. SetProperty(ref T_undo, value);
  74. }
  75. }
  76. private string T_redo;
  77. public string T_Redo
  78. {
  79. get { return T_redo; }
  80. set
  81. {
  82. SetProperty(ref T_redo, value);
  83. }
  84. }
  85. private string T_annotation;
  86. public string T_Annotation
  87. {
  88. get { return T_annotation; }
  89. set
  90. {
  91. SetProperty(ref T_annotation, value);
  92. }
  93. }
  94. private string T_pageEdit;
  95. public string T_PageEdit
  96. {
  97. get { return T_pageEdit; }
  98. set
  99. {
  100. SetProperty(ref T_pageEdit, value);
  101. }
  102. }
  103. private string T_converter;
  104. public string T_Converter
  105. {
  106. get { return T_converter; }
  107. set
  108. {
  109. SetProperty(ref T_converter, value);
  110. }
  111. }
  112. private string T_fillSign;
  113. public string T_FillSign
  114. {
  115. get { return T_fillSign; }
  116. set
  117. {
  118. SetProperty(ref T_fillSign, value);
  119. }
  120. }
  121. private string T_tools;
  122. public string T_Tools
  123. {
  124. get { return T_tools; }
  125. set
  126. {
  127. SetProperty(ref T_tools, value);
  128. }
  129. }
  130. private string T_print;
  131. public string T_Print
  132. {
  133. get { return T_print; }
  134. set
  135. {
  136. SetProperty(ref T_print, value);
  137. }
  138. }
  139. private string T_share;
  140. public string T_Share
  141. {
  142. get { return T_share; }
  143. set
  144. {
  145. SetProperty(ref T_share, value);
  146. }
  147. }
  148. private string T_properties;
  149. public string T_Properties
  150. {
  151. get { return T_properties; }
  152. set
  153. {
  154. SetProperty(ref T_properties, value);
  155. }
  156. }
  157. private void InitStirng()
  158. {
  159. T_File = App.MainPageLoader.GetString("ViewTopToolbar_File");
  160. T_Save = App.MainPageLoader.GetString("ViewTopToolbar_Save");
  161. T_Undo = App.MainPageLoader.GetString("ViewTopToolbar_Undo");
  162. T_Redo = App.MainPageLoader.GetString("ViewTopToolbar_Redo");
  163. T_Annotation = App.MainPageLoader.GetString("ViewTopToolbar_Annotation");
  164. T_PageEdit = App.MainPageLoader.GetString("ViewTopToolbar_PageEdit");
  165. T_Converter = App.MainPageLoader.GetString("ViewTopToolbar_Converter");
  166. T_FillSign = App.MainPageLoader.GetString("ViewTopToolbar_Fill&Sign");
  167. T_Tools = App.MainPageLoader.GetString("ViewTopToolbar_Tools");
  168. T_Print = App.MainPageLoader.GetString("ViewTopToolbar_Print");
  169. T_Share = App.MainPageLoader.GetString("ViewTopToolbar_Share");
  170. T_Properties = App.MainPageLoader.GetString("ViewTopToolbar_Properties");
  171. }
  172. #endregion 文案
  173. #region 属性、变量
  174. public OpenFileInfo OpenFileInfo = null;
  175. public CPDFViewer PDFViewer { get; set; }
  176. public MainContentViewModel mainViewModel { get; set; }
  177. public IRegionManager region;
  178. public IDialogService dialogs;
  179. public IEventAggregator events;
  180. public bool IsRightMenuCreateLink { get => isCreateLink; set => isCreateLink = value; }
  181. public string ViwerRegionName { get; set; }
  182. /// <summary>
  183. /// 分屏视图的region名称
  184. /// </summary>
  185. public string SplitViewerRegionName { get; set; }
  186. /// <summary>
  187. /// OCR视图名称
  188. /// </summary>
  189. public string OCRViewerRegionName { get; set; }
  190. public string BOTARegionName { get; set; }
  191. public string PropertyRegionName { get; set; }
  192. public string ToolContentRegionName { get; set; }
  193. public string ToolsBarContentRegionName { get; set; }
  194. /// <summary>
  195. /// 顶部提示的Content
  196. /// </summary>
  197. public string TipContentRegionName { get; set; }
  198. public string LeftTipContentRegionName { get; set; }
  199. //便签弹窗
  200. public string NotePopupRegionName { get; set; }
  201. public string ReadModeRegionName { get; set; }
  202. public string ConverterBarContentRegionName { get; set; }
  203. public string TextEditContentRegionName { get; set; }
  204. public string BackgroundContentRegionName { get; set; }
  205. public PasswordInfo PasswordInfo = new PasswordInfo();
  206. //若point不赋值或从列表中找不到point,系统会提供默认值为(0,0)的新point,所以改用Tuple<int,int>
  207. public List<FillAndSignIsShape> FillAndSign = new List<FillAndSignIsShape>();
  208. /// <summary>
  209. /// 签名列表
  210. /// </summary>
  211. public List<Tuple<int, int>> AnnotSignatures = new List<Tuple<int, int>>();
  212. /// <summary>
  213. /// 文档的密码
  214. /// </summary>
  215. public string PassWord { get; set; }
  216. public PasswordInfo passwordInfo = new PasswordInfo();
  217. private Visibility tipVisible = Visibility.Collapsed;
  218. /// <summary>
  219. /// 顶部提示栏的显示状态
  220. /// </summary>
  221. public Visibility TipVisible
  222. {
  223. get { return tipVisible; }
  224. set
  225. {
  226. SetProperty(ref tipVisible, value);
  227. }
  228. }
  229. private Visibility leftTipVisible = Visibility.Collapsed;
  230. public Visibility LeftTipVisible
  231. {
  232. get { return leftTipVisible; }
  233. set
  234. {
  235. SetProperty(ref leftTipVisible, value);
  236. }
  237. }
  238. private Visibility notePopupVisible = Visibility.Collapsed;
  239. public Visibility NotePopupVisible
  240. {
  241. get { return notePopupVisible; }
  242. set
  243. {
  244. SetProperty(ref notePopupVisible, value);
  245. }
  246. }
  247. public bool IsNoteAdd = false;
  248. private double canvasNoteLeft;
  249. public double CanvasNoteLeft
  250. {
  251. get { return canvasNoteLeft; }
  252. set
  253. {
  254. SetProperty(ref canvasNoteLeft, value);
  255. }
  256. }
  257. private double canvasNoteBottom;
  258. public double CanvasNoteBottom
  259. {
  260. get { return canvasNoteBottom; }
  261. set
  262. {
  263. SetProperty(ref canvasNoteBottom, value);
  264. }
  265. }
  266. /// <summary>
  267. /// 底部工具栏 RegionName
  268. /// </summary>
  269. public string BottomToolRegionName { get; set; }
  270. private bool _isInPageEdit = false;
  271. /// <summary>
  272. /// 是否处于页面编辑模式,用于执行undo redo 的具体操作
  273. /// </summary>
  274. public bool isInPageEdit
  275. {
  276. get { return _isInPageEdit; }
  277. set
  278. {
  279. SetProperty(ref _isInPageEdit, value);
  280. //if (!value)
  281. //{
  282. // CanRedo = PDFViewer.UndoManager.CanRedo;
  283. // CanUndo = PDFViewer.UndoManager.CanUndo;
  284. //}
  285. }
  286. }
  287. public Action PageEditUndo { get; set; }
  288. public Action PageEditRedo { get; set; }
  289. /// <summary>
  290. ///工具条
  291. ///0:收起
  292. ///40:显示
  293. /// </summary>
  294. private int toolRowHeight = 40;
  295. public int ToolRowHeight
  296. {
  297. get { return toolRowHeight; }
  298. set
  299. {
  300. SetProperty(ref toolRowHeight, value);
  301. }
  302. }
  303. /// <summary>
  304. /// 水印,背景侧边栏宽度
  305. /// 0:收起
  306. /// 260:显示
  307. /// </summary>
  308. private int propertyColumnWidth = 0;
  309. public int PropertyColumnWidth
  310. {
  311. get { return propertyColumnWidth; }
  312. set
  313. {
  314. SetProperty(ref propertyColumnWidth, value);
  315. }
  316. }
  317. private int gridToolRow = 1;
  318. /// <summary>
  319. /// 控制ToolContent的Row
  320. /// </summary>
  321. public int GridToolRow
  322. {
  323. get { return gridToolRow; }
  324. set
  325. {
  326. SetProperty(ref gridToolRow, value);
  327. }
  328. }
  329. private int gridToolRowSpan = 3;
  330. /// <summary>
  331. /// 控制ToolContent的RowSpan
  332. /// </summary>
  333. public int GridToolRowSpan
  334. {
  335. get { return gridToolRowSpan; }
  336. set
  337. {
  338. SetProperty(ref gridToolRowSpan, value);
  339. }
  340. }
  341. private Visibility toolContentVisible = Visibility.Collapsed;
  342. /// <summary>
  343. /// 控制Content的显示 用于显示水印、贝茨码、密文等功能模块
  344. /// 留意:显示前需要先注入内容、设置好行和跨行数
  345. /// </summary>
  346. public Visibility ToolContentVisible
  347. {
  348. get { return toolContentVisible; }
  349. set
  350. {
  351. SetProperty(ref toolContentVisible, value);
  352. }
  353. }
  354. private Visibility gridVisibility = Visibility.Visible;
  355. /// <summary>
  356. /// 是否正在加载中
  357. /// </summary>
  358. public Visibility GridVisibility
  359. {
  360. get { return gridVisibility; }
  361. set
  362. {
  363. SetProperty(ref gridVisibility, value);
  364. }
  365. }
  366. private Visibility isLoading = Visibility.Collapsed;
  367. private Visibility ocrContentVisible = Visibility.Collapsed;
  368. public Visibility OCRContentVisible
  369. {
  370. get { return ocrContentVisible; }
  371. set
  372. {
  373. SetProperty(ref ocrContentVisible, value);
  374. }
  375. }
  376. /// <summary>
  377. /// 是否正在加载中
  378. /// </summary>
  379. public Visibility IsLoading
  380. {
  381. get { return isLoading; }
  382. set
  383. {
  384. SetProperty(ref isLoading, value);
  385. }
  386. }
  387. private Visibility converterBarContentVisible = Visibility.Collapsed;
  388. private Visibility toolsbarContentVisible = Visibility.Collapsed;
  389. /// <summary>
  390. /// 控制ToolsBarContent的显示
  391. /// 留意:显示前需要先注入内容、设置好行和跨行数
  392. /// </summary>
  393. public Visibility ConverterBarContentVisible
  394. {
  395. get { return converterBarContentVisible; }
  396. set
  397. {
  398. SetProperty(ref converterBarContentVisible, value);
  399. }
  400. }
  401. private Visibility toolsBarContentVisible = Visibility.Collapsed;
  402. /// <summary>
  403. /// 控制ToolsBarContent的显示
  404. /// 留意:显示前需要先注入内容、设置好行和跨行数
  405. /// </summary>
  406. public Visibility ToolsBarContentVisible
  407. {
  408. get { return toolsBarContentVisible; }
  409. set
  410. {
  411. SetProperty(ref toolsBarContentVisible, value);
  412. }
  413. }
  414. private Visibility textEditToolContentVisible = Visibility.Collapsed;
  415. /// <summary>
  416. /// 控制ToolsBarContent的显示
  417. /// 留意:显示前需要先注入内容、设置好行和跨行数
  418. /// </summary>
  419. public Visibility TextEditToolContentVisible
  420. {
  421. get { return textEditToolContentVisible; }
  422. set
  423. {
  424. SetProperty(ref textEditToolContentVisible, value);
  425. }
  426. }
  427. private bool isPorpertyOpen = false;
  428. /// <summary>
  429. /// 属性栏是否展开
  430. /// </summary>
  431. public bool IsPropertyOpen
  432. {
  433. get { return isPorpertyOpen; }
  434. set
  435. {
  436. //如果设置为手动展开属性面板时,则不响应代码控制的展开
  437. if (Settings.Default.AppProperties.InitialVIew.AutoExpandProperty)
  438. {
  439. if (mainViewModel.IsBookMode)
  440. {
  441. this.events.GetEvent<ReadModePropertyOpenEvent>().Publish(new ReadModePropertyOpenArgs() { Unicode = unicode });
  442. }
  443. SetProperty(ref isPorpertyOpen, value);
  444. }
  445. }
  446. }
  447. private Visibility isReadMode = Visibility.Visible;
  448. /// <summary>
  449. ///是否为阅读模式
  450. /// </summary>
  451. public Visibility IsReadMode
  452. {
  453. get { return isReadMode; }
  454. set
  455. {
  456. SetProperty(ref isReadMode, value);
  457. }
  458. }
  459. private bool canSave;
  460. /// <summary>
  461. /// 是否可以保存
  462. /// </summary>
  463. public bool CanSave
  464. {
  465. get { return canSave; }
  466. set
  467. {
  468. if (events != null && canSave == false)
  469. this.events.GetEvent<FillAndSignEvent>().Publish(new FillAndSigntEventArgs { Action = "Clear", AppUnicode = unicode });
  470. SetProperty(ref canSave, value);
  471. }
  472. }
  473. private bool canUndo;
  474. /// <summary>
  475. /// 是否可以进行Undo
  476. /// </summary>
  477. public bool CanUndo
  478. {
  479. get { return canUndo; }
  480. set
  481. {
  482. SetProperty(ref canUndo, value);
  483. }
  484. }
  485. private bool canRedo;
  486. /// <summary>
  487. /// 是否可以进行Redo
  488. /// </summary>
  489. public bool CanRedo
  490. {
  491. get { return canRedo; }
  492. set
  493. {
  494. SetProperty(ref canRedo, value);
  495. }
  496. }
  497. private GridLength botaWidth = new GridLength(48);
  498. /// <summary>
  499. /// BOTA栏的宽度
  500. /// </summary>
  501. public GridLength BOTAWidth
  502. {
  503. get { return botaWidth; }
  504. set
  505. {
  506. SetProperty(ref botaWidth, value);
  507. if (botaWidth.Value <= 48)
  508. {
  509. OpenBOTA = false;
  510. }
  511. }
  512. }
  513. private int selectedIndex;
  514. /// <summary>
  515. /// 工具栏选中项的索引
  516. /// </summary>
  517. public int TabSelectedIndex
  518. {
  519. get { return selectedIndex; }
  520. set
  521. {
  522. SetProperty(ref selectedIndex, value);
  523. }
  524. }
  525. private bool openBOTA = false;
  526. /// <summary>
  527. /// 是否展开BOTA
  528. /// </summary>
  529. public bool OpenBOTA
  530. {
  531. get { return openBOTA; }
  532. set
  533. {
  534. SetProperty(ref openBOTA, value);
  535. if (openBOTA && BOTAWidth.Value <= 48)
  536. {
  537. BOTAWidth = new GridLength(260);
  538. }
  539. //关闭BOTA的逻辑在xaml.cs代码里控制,无法绑定后台
  540. }
  541. }
  542. public SecurityInfo SecurityInfo = new SecurityInfo();
  543. private Dictionary<string, string> regionNameByTabItem;
  544. private Dictionary<string, string> barContentByTabItem;
  545. private string previousBar = "";
  546. public string CurrentBar = "";
  547. public string unicode = null;
  548. /// <summary>
  549. /// 自动保存的定时器
  550. /// </summary>
  551. private DispatcherTimer autoSaveTimer = new DispatcherTimer();
  552. /// <summary>
  553. /// 用来避免重复触发导航事件的标志符
  554. /// </summary>
  555. private bool isOpenFile = false;
  556. /// <summary>
  557. /// 鼠标滚轮缩放的缩放值
  558. /// </summary>
  559. private double[] zoomLevel = { 1.00f, 10, 25, 50, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
  560. /// <summary>
  561. /// 注释-链接,提示语
  562. /// </summary>
  563. private Visibility linkAnnotTipVisibility = Visibility.Collapsed;
  564. public Visibility LinkAnnotTipVisibility
  565. {
  566. get { return linkAnnotTipVisibility; }
  567. set
  568. {
  569. SetProperty(ref linkAnnotTipVisibility, value);
  570. }
  571. }
  572. 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";
  573. private bool isCreateLink = false;
  574. public string LinkAnnotTipText
  575. {
  576. get { return linkAnnotTipText; }
  577. set
  578. {
  579. SetProperty(ref linkAnnotTipText, value);
  580. }
  581. }
  582. #endregion 属性、变量
  583. #region 命令
  584. public DelegateCommand Load { get; set; }
  585. public DelegateCommand MouseDown { get; set; }
  586. public DelegateCommand<object> TabControlSelectionChangedCommand { get; set; }
  587. public DelegateCommand SaveFile { get; set; }
  588. public DelegateCommand SaveAsFile { get; set; }
  589. public DelegateCommand SaveAsFlattenCommand { get; set; }
  590. public DelegateCommand UndoCommand { get; set; }
  591. public DelegateCommand RedoCommand { get; set; }
  592. public DelegateCommand<object> MenuEnterReadMode { get; set; }
  593. public DelegateCommand PrintCommand { get; set; }
  594. public DelegateCommand SelectCommand { get; set; }
  595. public DelegateCommand SettingsCommand { get; set; }
  596. public DelegateCommand ShareCommand { get; set; }
  597. public DelegateCommand<object> CreateLinkCommand { get; set; }
  598. public DelegateCommand PropertyCommand { get; set; }
  599. public DelegateCommand ShowInFolderCommand { get; set; }
  600. public DelegateCommand CompressCommand { get; set; }
  601. public DelegateCommand MergeFileCommand { get; set; }
  602. public DelegateCommand EncryptCommand { get; set; }
  603. public DelegateCommand DecryptCommand { get; set; }
  604. public DelegateCommand<string> ConvertCommand { get; set; }
  605. public DelegateCommand CloseWindowCommand { get; set; }
  606. public DelegateCommand OpenFileCommand { get; set; }
  607. public DelegateCommand<string> HelpCommand { get; set; }
  608. public DelegateCommand CreateBlankFileCommand { get; set; }
  609. public DelegateCommand CreateFromFile { get; set; }
  610. public DelegateCommand ClosePropertyCommand { get; set; }
  611. #endregion 命令
  612. public ViewContentViewModel(IRegionManager regionManager, IDialogService dialogService, IEventAggregator eventAggregator)
  613. {
  614. InitStirng();
  615. region = regionManager;
  616. dialogs = dialogService;
  617. events = eventAggregator;
  618. unicode = App.mainWindowViewModel.SelectedItem.Unicode;
  619. Load = new DelegateCommand(LoadControl);
  620. MouseDown = new DelegateCommand(MouseDownEvent);
  621. SaveFile = new DelegateCommand(() => { saveFile(); }, CanSaveExcute).ObservesProperty(() => CanSave);
  622. SaveAsFlattenCommand = new DelegateCommand(saveAsFlatten);
  623. SaveAsFile = new DelegateCommand(() => { saveAsFile(); });
  624. UndoCommand = new DelegateCommand(Undo);
  625. RedoCommand = new DelegateCommand(Redo);
  626. ShareCommand = new DelegateCommand(share);
  627. PropertyCommand = new DelegateCommand(property);
  628. ShowInFolderCommand = new DelegateCommand(ShowInFolder);
  629. TabControlSelectionChangedCommand = new DelegateCommand<object>(TabControlSelectonChangedEvent);
  630. CompressCommand = new DelegateCommand(compress);
  631. MergeFileCommand = new DelegateCommand(mergeFile);
  632. EncryptCommand = new DelegateCommand(encrypt);
  633. DecryptCommand = new DelegateCommand(decrypt);
  634. ConvertCommand = new DelegateCommand<string>(convert);
  635. CloseWindowCommand = new DelegateCommand(closeWindow);
  636. OpenFileCommand = new DelegateCommand(openfile);
  637. HelpCommand = new DelegateCommand<string>(help);
  638. CreateBlankFileCommand = new DelegateCommand(createBlankFile);
  639. CreateFromFile = new DelegateCommand(createfromFile);
  640. ViwerRegionName = RegionNames.ViwerRegionName;
  641. SplitViewerRegionName = RegionNames.Viewer_SplitRegionName;
  642. BOTARegionName = RegionNames.BOTARegionName;
  643. PropertyRegionName = RegionNames.PropertyRegionName;
  644. BottomToolRegionName = RegionNames.BottomToolRegionName;
  645. ReadModeRegionName = RegionNames.ReadModeRegionName;
  646. MenuEnterReadMode = new DelegateCommand<object>(MenuEnterReadModeEvent);
  647. PrintCommand = new DelegateCommand(ShowPrintDialog);
  648. SelectCommand = new DelegateCommand(SelectClick);
  649. SettingsCommand = new DelegateCommand(SettingsEvent);
  650. CreateLinkCommand = new DelegateCommand<object>(CreateLinkEvent);
  651. ClosePropertyCommand = new DelegateCommand(CloseProperty);
  652. //未显示时无法注册上Region名称
  653. ToolContentVisible = Visibility.Visible;
  654. ToolsBarContentVisible = Visibility.Visible;
  655. OCRContentVisible = Visibility.Visible;
  656. TipVisible = Visibility.Visible;
  657. TipContentRegionName = RegionNames.TipContentRegionName;
  658. LeftTipContentRegionName = RegionNames.LeftTipContentRegionName;
  659. NotePopupRegionName = RegionNames.NotePopupRegionName;
  660. OCRViewerRegionName = RegionNames.OCRViewerRegionName;
  661. ToolContentRegionName = Guid.NewGuid().ToString();
  662. ToolsBarContentRegionName = Guid.NewGuid().ToString();
  663. ConverterBarContentRegionName = Guid.NewGuid().ToString();
  664. TextEditContentRegionName = Guid.NewGuid().ToString();
  665. ToolContentVisible = Visibility.Collapsed;
  666. ToolsBarContentVisible = Visibility.Collapsed;
  667. OCRContentVisible = Visibility.Collapsed;
  668. TipVisible = Visibility.Collapsed;
  669. regionNameByTabItem = new Dictionary<string, string>();
  670. barContentByTabItem = new Dictionary<string, string>();
  671. InitialregionNameByTabItem(ref regionNameByTabItem);
  672. InitialbarContentByTabItem(ref barContentByTabItem);
  673. eventAggregator.GetEvent<EnterSelectedEditToolEvent>().Subscribe(EnterEditTools, e => e.Unicode == unicode);
  674. eventAggregator.GetEvent<CloseEditToolEvent>().Subscribe(CloseEditTool, e => e.Unicode == unicode);
  675. eventAggregator.GetEvent<ShowTipEvent>().Subscribe(ShowSelectedTipAsync, e => e.Unicode == unicode);
  676. //TODO:根据缓存 选择用户上次选择的菜单
  677. CurrentBar = "TabItemAnnotation";
  678. EnterSelectedBar("TabItemAnnotation");
  679. StartAutoSave();
  680. }
  681. /// <summary>
  682. /// 开始自动保存
  683. /// </summary>
  684. public void StartAutoSave()
  685. {
  686. var autoSave = Settings.Default.AppProperties.Description.AutoSave;
  687. if(autoSave)
  688. {
  689. var interval = Settings.Default.AppProperties.Description.AutoSaveInterval;
  690. if(autoSaveTimer==null)
  691. {
  692. autoSaveTimer = new DispatcherTimer();
  693. }
  694. autoSaveTimer.Stop();
  695. autoSaveTimer.Interval = TimeSpan.FromMinutes(interval);
  696. autoSaveTimer.Tick -= AutoSaveTimer_Tick;
  697. autoSaveTimer.Tick += AutoSaveTimer_Tick;
  698. autoSaveTimer.Start();
  699. }
  700. }
  701. /// <summary>
  702. /// 释放定时器
  703. /// 不释放定时器可能会一直运行并占用内存,导致内存泄露
  704. /// </summary>
  705. public void CloseAutoSave()
  706. {
  707. autoSaveTimer.Stop();
  708. autoSaveTimer.Tick -= AutoSaveTimer_Tick;
  709. autoSaveTimer = null;
  710. }
  711. private void AutoSaveTimer_Tick(object sender, EventArgs e)
  712. {
  713. var autoSave = Settings.Default.AppProperties.Description.AutoSave;
  714. if (autoSave&&!mainViewModel.NewFile)
  715. {
  716. //自动保存仅针对已经有文件路径的文档
  717. saveFile();
  718. }
  719. }
  720. private void MouseDownEvent()
  721. {
  722. if (NotePopupVisible == Visibility.Visible && IsNoteAdd == false)
  723. {
  724. NotePopupVisible = Visibility.Collapsed;
  725. if (region.Regions.ContainsRegionWithName(NotePopupRegionName))
  726. {
  727. var views = region.Regions[NotePopupRegionName].Views;
  728. foreach (var item in views)
  729. {
  730. if (item is StickyNotePopup sticky)
  731. {
  732. var contentRegion = region.Regions[NotePopupRegionName];
  733. contentRegion.Remove(sticky);
  734. break;
  735. }
  736. }
  737. }
  738. }
  739. }
  740. private async void createfromFile()
  741. {
  742. string txt = Properties.Resources.txtex;
  743. string word = Properties.Resources.wordex;
  744. string ppt = Properties.Resources.pptex;
  745. string excel = Properties.Resources.excelex;
  746. string html = Properties.Resources.htmlex;
  747. string image = Properties.Resources.imageex;
  748. string allfiles = txt + word + excel + ppt + image + html;
  749. OpenFileDialog dialog = new OpenFileDialog();
  750. dialog.Multiselect = true;
  751. dialog.Filter = string.Format($"Files({allfiles.Replace(";", ",")}|{allfiles})|" +
  752. $"Microsoft Office Word({word})|{word}|" +
  753. $"Microsoft Office Excel({excel})|{excel}|" +
  754. $"Microsoft Office PowerPoint({ppt})|{ppt}|" +
  755. $"Txt({txt})|{txt}|" +
  756. $"Picture({image})|{image}|" +
  757. $"Html({html})|{html}");
  758. if ((bool)dialog.ShowDialog())
  759. {
  760. for (int i = 0; i < dialog.FileNames.Length; i++)
  761. {
  762. if (App.OpenedFileList.Contains(dialog.FileNames[i]))
  763. {
  764. App.mainWindowViewModel.SelectItem(dialog.FileNames[i]);
  765. }
  766. else
  767. {
  768. System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
  769. {
  770. App.mainWindowViewModel.AddTabItem(dialog.FileNames[i]);
  771. }));
  772. await Task.Delay(20);
  773. ToolMethod.SetFileThumbImg(dialog.FileNames[i]);
  774. }
  775. }
  776. }
  777. }
  778. /// <summary>
  779. ///创建空白文档
  780. /// </summary>
  781. private async void createBlankFile()
  782. {
  783. App.mainWindowViewModel.AddTab.Execute();
  784. await Task.Delay(30);
  785. (App.mainWindowViewModel.SelectedItem.DataContext as MainContentViewModel).CreateFile();
  786. }
  787. private void help(string args)
  788. {
  789. string url = "";
  790. switch (args)
  791. {
  792. case "Guid":
  793. //打开内嵌文档
  794. if (App.OpenedFileList.Contains(App.GuidPDFPath))
  795. {
  796. //如果已经打开时,则选中内嵌文档
  797. App.mainWindowViewModel.SelectItem(App.GuidPDFPath);
  798. return;
  799. }
  800. if (File.Exists(App.GuidPDFPath))
  801. {
  802. App.mainWindowViewModel.AddTabItem(App.GuidPDFPath);
  803. }
  804. break;
  805. case "Online":
  806. url = @"https://www.pdfreaderpro.com/windows/help";
  807. break;
  808. case "More":
  809. url = @"https://www.pdfreaderpro.com/product?utm_source=MacApp&utm_campaign=ProductLink&utm_medium=PdfProduct";
  810. break;
  811. case "Template":
  812. url = @"https://www.pdfreaderpro.com/templates?utm_source=MacApp&utm_campaign=TemplatesLink&utm_medium=PdfTemplates";
  813. break;
  814. case "Blog":
  815. //TODO:显示订阅电子报弹窗
  816. break;
  817. case "ComPDF":
  818. url = @"https://www.compdf.com/?utm_source=macapp&utm_medium=pdfmac&utm_campaign=compdfkit-promp";
  819. break;
  820. case "FeedBack":
  821. //调用邮箱 发送邮件
  822. StringBuilder sr = new StringBuilder();
  823. sr.AppendFormat("{0} - {1};{2};{3} - {4}", App.Name, App.Version, "Propose a New Feature", ServiceHelper.ComputerInfo, ServiceHelper.SystemInfo);
  824. System.Diagnostics.Process.Start(string.Format("mailto:support@pdfreaderpro.com?subject={0}", sr));
  825. break;
  826. default:
  827. break;
  828. }
  829. if (!string.IsNullOrEmpty(url))
  830. {
  831. //需要跳转网页的情况
  832. System.Diagnostics.Process.Start(url);
  833. }
  834. }
  835. /// <summary>
  836. /// 打开文件,跟首页的打开文件有区别,需要新开一个页签
  837. /// </summary>
  838. private void openfile()
  839. {
  840. OpenFileDialog openFileDialog = new OpenFileDialog();
  841. openFileDialog.Filter = Properties.Resources.OpenDialogFilter;
  842. openFileDialog.Multiselect = true;
  843. if ((bool)openFileDialog.ShowDialog())
  844. {
  845. if (openFileDialog.FileNames.Count() == 1)
  846. {
  847. if (App.OpenedFileList.Contains(openFileDialog.FileName))
  848. {
  849. App.mainWindowViewModel.SelectItem(openFileDialog.FileName);
  850. }
  851. else
  852. {
  853. App.mainWindowViewModel.AddTabItem(openFileDialog.FileName);
  854. }
  855. ToolMethod.SetFileThumbImg(openFileDialog.FileName);
  856. }
  857. else
  858. {
  859. var fileList = openFileDialog.FileNames.ToList().Where(x => !App.OpenedFileList.Exists(y => y == x)).ToList();
  860. if (fileList.Count <= 0)
  861. {
  862. App.mainWindowViewModel.SelectItem(openFileDialog.FileName);
  863. return;
  864. }
  865. mainViewModel.OpenFile(fileList[0]);
  866. for (int i = 1; i < fileList.Count(); i++)
  867. {
  868. if (!App.OpenedFileList.Contains(fileList[i]))
  869. {
  870. App.mainWindowViewModel.AddTabItem(fileList[i]);
  871. }
  872. ToolMethod.SetFileThumbImg(fileList[i]);
  873. }
  874. }
  875. }
  876. }
  877. /// <summary>
  878. /// 关闭当前窗体
  879. /// </summary>
  880. private void closeWindow()
  881. {
  882. App.Current.MainWindow.Close();
  883. }
  884. /// <summary>
  885. /// 转档
  886. /// </summary>
  887. /// <param name="obj"></param>
  888. private void convert(string obj)
  889. {
  890. if (!string.IsNullOrEmpty(obj))
  891. {
  892. DialogParameters value = new DialogParameters();
  893. value.Add(ParameterNames.PDFViewer, PDFViewer);
  894. switch (obj)
  895. {
  896. case "Word":
  897. dialogs.ShowDialog(DialogNames.ConverterWordDialog, value, e =>
  898. {
  899. ConverterDialogsModel converterDialogsModel = new ConverterDialogsModel();
  900. converterDialogsModel.OnOpened((DialogResult)e);
  901. });
  902. break;
  903. case "Excel":
  904. dialogs.ShowDialog(DialogNames.ConverterExcelDialog, value, e =>
  905. {
  906. ConverterDialogsModel converterDialogsModel = new ConverterDialogsModel();
  907. converterDialogsModel.OnOpened((DialogResult)e);
  908. });
  909. break;
  910. case "PPT":
  911. dialogs.ShowDialog(DialogNames.ConverterPPTDialog, value, e =>
  912. {
  913. ConverterDialogsModel converterDialogsModel = new ConverterDialogsModel();
  914. converterDialogsModel.OnOpened((DialogResult)e);
  915. });
  916. break;
  917. case "RTF":
  918. dialogs.ShowDialog(DialogNames.ConverterRTFDialog, value, e =>
  919. {
  920. ConverterDialogsModel converterDialogsModel = new ConverterDialogsModel();
  921. converterDialogsModel.OnOpened((DialogResult)e);
  922. });
  923. break;
  924. case "CSV":
  925. dialogs.ShowDialog(DialogNames.ConverterCSVDialog, value, e =>
  926. {
  927. ConverterDialogsModel converterDialogsModel = new ConverterDialogsModel();
  928. converterDialogsModel.OnOpened((DialogResult)e);
  929. });
  930. break;
  931. case "HTML":
  932. dialogs.ShowDialog(DialogNames.ConverterHTMLDialog, value, e =>
  933. {
  934. ConverterDialogsModel converterDialogsModel = new ConverterDialogsModel();
  935. converterDialogsModel.OnOpened((DialogResult)e);
  936. });
  937. break;
  938. case "Text":
  939. dialogs.ShowDialog(DialogNames.ConverterTextDialog, value, e =>
  940. {
  941. ConverterDialogsModel converterDialogsModel = new ConverterDialogsModel();
  942. converterDialogsModel.OnOpened((DialogResult)e);
  943. });
  944. break;
  945. case "Image":
  946. dialogs.ShowDialog(DialogNames.ConverterImgDialog, value, e =>
  947. {
  948. ConverterDialogsModel converterDialogsModel = new ConverterDialogsModel();
  949. converterDialogsModel.OnOpened((DialogResult)e);
  950. });
  951. break;
  952. default:
  953. break;
  954. }
  955. }
  956. }
  957. /// <summary>
  958. /// 解密
  959. /// </summary>
  960. private void decrypt()
  961. {
  962. if (!PDFViewer.Document.IsEncrypted)
  963. {
  964. MessageBoxEx.Show("No security settings available ");
  965. }
  966. else
  967. {
  968. VerifyPasswordResult result = SecurityHelper.VerifyPasswordByPasswordKind(PDFViewer.Document, EnumPasswordKind.StatusPermissionsPassword, dialogs);
  969. if (result.IsDiscryptied)
  970. {
  971. if (result.Password != null)
  972. {
  973. string filePath = PDFViewer.Document.FilePath;
  974. PDFViewer.Document.Release();
  975. PDFViewer.InitDocument(filePath);
  976. PDFViewer.Document.UnlockWithPassword(result.Password);
  977. }
  978. DialogParameters value = new DialogParameters();
  979. value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
  980. dialogs.ShowDialog(DialogNames.DeleteSafetySettingsDialog, value, e => { });
  981. }
  982. }
  983. }
  984. /// <summary>
  985. /// 加密
  986. /// </summary>
  987. private void encrypt()
  988. {
  989. if (!this.SecurityInfo.IsPasswordChanged)
  990. {
  991. VerifyPasswordResult result = SecurityHelper.VerifyPasswordByPasswordKind(PDFViewer.Document, EnumPasswordKind.StatusPermissionsPassword, dialogs);
  992. if (result.IsDiscryptied)
  993. {
  994. if (result.Password != null)
  995. {
  996. string filePath = PDFViewer.Document.FilePath;
  997. PDFViewer.Document.Release();
  998. PDFViewer.InitDocument(filePath);
  999. PDFViewer.Document.UnlockWithPassword(result.Password);
  1000. }
  1001. }
  1002. }
  1003. DialogParameters value = new DialogParameters();
  1004. value.Add(ParameterNames.PDFViewer, this.PDFViewer);
  1005. value.Add(ParameterNames.ViewContentViewModel, this);
  1006. dialogs.ShowDialog(DialogNames.SetPasswordDialog, value, e =>
  1007. {
  1008. if (e.Result == ButtonResult.OK)
  1009. {
  1010. SecurityHelper.IsPasswordChanged = true;
  1011. if (this.SecurityInfo.IsPasswordChanged)
  1012. {
  1013. this.PDFViewer.UndoManager.CanSave = true;
  1014. }
  1015. this.events.GetEvent<ShowTipEvent>().Publish(new ShowTipEventArgs() { enumTipKind = EnumTipKind.StatusSetPasswordSuccessfully, Unicode = unicode });
  1016. }
  1017. });
  1018. }
  1019. /// <summary>
  1020. /// 合并
  1021. /// </summary>
  1022. private void mergeFile()
  1023. {
  1024. DialogParameters value = new DialogParameters();
  1025. value.Add(ParameterNames.PDFViewer, PDFViewer);
  1026. dialogs.ShowDialog(DialogNames.MergeDialog, value, e => { });
  1027. }
  1028. /// <summary>
  1029. /// 压缩
  1030. /// </summary>
  1031. private void compress()
  1032. {
  1033. DialogParameters value = new DialogParameters();
  1034. value.Add(ParameterNames.PDFViewer, PDFViewer);
  1035. dialogs.ShowDialog(DialogNames.CompressDialog, value, e =>
  1036. {
  1037. CompressDialogModel compressDialogModel = new CompressDialogModel();
  1038. compressDialogModel.OnOpened((Prism.Services.Dialogs.DialogResult)e);
  1039. });
  1040. }
  1041. /// <summary>
  1042. /// 设置Tip状态栏的显示状态
  1043. /// </summary>
  1044. /// <param name="show">是否显示</param>
  1045. public void ShowTip(bool show)
  1046. {
  1047. if (show)
  1048. {
  1049. TipVisible = Visibility.Visible;
  1050. }
  1051. else
  1052. {
  1053. TipVisible = Visibility.Collapsed;
  1054. }
  1055. }
  1056. /// <summary>
  1057. /// 设置LeftTip状态栏的显示状态
  1058. /// </summary>
  1059. /// <param name="show">是否显示</param>
  1060. public void ShowLeftTip(bool show)
  1061. {
  1062. if (show)
  1063. {
  1064. LeftTipVisible = Visibility.Visible;
  1065. }
  1066. else
  1067. {
  1068. LeftTipVisible = Visibility.Collapsed;
  1069. }
  1070. }
  1071. public void CheckHaveAllPermission()
  1072. {
  1073. if (!SecurityHelper.CheckHaveAllPermissions(PDFViewer.Document))
  1074. {
  1075. ShowLeftTip(true);
  1076. NavigationParameters param = new NavigationParameters();
  1077. param.Add(ParameterNames.PDFViewer, PDFViewer);
  1078. region.RequestNavigate(LeftTipContentRegionName, "FileRestrictedTip", param);
  1079. }
  1080. }
  1081. public async void ShowSelectedTipAsync(ShowTipEventArgs showTipEventArgs)
  1082. {
  1083. switch (showTipEventArgs.enumTipKind)
  1084. {
  1085. case EnumTipKind.StatusNone:
  1086. ShowLeftTip(false);
  1087. break;
  1088. case EnumTipKind.StatusSetPasswordSuccessfully:
  1089. ShowLeftTip(true);
  1090. region.RequestNavigate(LeftTipContentRegionName, "SetPasswordSuccessfullyTip");
  1091. break;
  1092. case EnumTipKind.StatusRemoveSecuritySuccessfully:
  1093. ShowLeftTip(false);
  1094. region.RequestNavigate(TipContentRegionName, "RemoveSecuritySuccessTip");
  1095. IsLoading = Visibility.Collapsed;
  1096. ShowTip(true);
  1097. await Task.Delay(3000);
  1098. //ReadModelTip = Visibility.Collapsed;
  1099. TipVisible = Visibility.Collapsed;
  1100. break;
  1101. default: break;
  1102. }
  1103. }
  1104. /// <summary>
  1105. /// 右键菜单创建链接
  1106. /// </summary>
  1107. /// <param name="obj"></param>
  1108. private void CreateLinkEvent(object obj)
  1109. {
  1110. if (obj is object[] objArry)
  1111. {
  1112. if (objArry[0] is AnnotToolContentViewModel toolContentViewModel && objArry[1] is AnnotCommandArgs annotCommand)
  1113. {
  1114. LinkAnnotArgs linkArgs = new LinkAnnotArgs();
  1115. linkArgs.URI = string.Empty;
  1116. linkArgs.LinkType = LINK_TYPE.GOTO;
  1117. linkArgs.PageIndex = annotCommand.PageIndex;
  1118. //linkArgs.InvokeLinkSaveCalled(this, EventArgs.Empty);
  1119. this.IsRightMenuCreateLink = true;
  1120. List<AnnotHandlerEventArgs> lists = new List<AnnotHandlerEventArgs>();
  1121. lists.Add(linkArgs);
  1122. AnnotHandlerEventArgs annotArgs = toolContentViewModel.GetLink(lists);
  1123. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  1124. PDFViewer.SetToolParam(annotArgs);
  1125. this.IsPropertyOpen = true;
  1126. }
  1127. }
  1128. }
  1129. private void CloseProperty()
  1130. {
  1131. IsPropertyOpen = false;
  1132. }
  1133. /// <summary>
  1134. /// 在文件资源管理器中显示
  1135. /// </summary>
  1136. private void ShowInFolder()
  1137. {
  1138. CommonHelper.ShowFileBrowser(PDFViewer.Document.FilePath);
  1139. }
  1140. private void property()
  1141. {
  1142. DialogParameters valuePairs = new DialogParameters();
  1143. valuePairs.Add(ParameterNames.PDFDocument, PDFViewer.Document);
  1144. dialogs.ShowDialog(DialogNames.PropertyDialog, valuePairs, null);
  1145. }
  1146. private void share()
  1147. {
  1148. try
  1149. {
  1150. var path = PDFViewer.Document.FilePath;
  1151. string subject = "分享至" + " " + PDFViewer.Document.FileName;
  1152. System.Diagnostics.Process.Start("outlook", "/a,\"" + path + "\"" + "/m \"" + "&subject=" + subject + "\"");
  1153. }
  1154. catch
  1155. {
  1156. AlertsMessage alertsMessage = new AlertsMessage();
  1157. alertsMessage.ShowDialog("", "未检测到Ooutlook软件,请先安装Outlook", "OK");
  1158. }
  1159. }
  1160. private void SettingsEvent()
  1161. {
  1162. dialogs.ShowDialog(DialogNames.SettingsDialog, null, null);
  1163. if (PDFViewer != null)
  1164. {
  1165. PDFViewer.SetBackgroundBrush(new System.Windows.Media.SolidColorBrush(Settings.Default.AppProperties.InitialVIew.BackGround));
  1166. }
  1167. if(Settings.Default.AppProperties.Description.AutoSave)
  1168. {
  1169. StartAutoSave();
  1170. }
  1171. else
  1172. {
  1173. CloseAutoSave();
  1174. }
  1175. }
  1176. private bool CanSaveExcute()
  1177. {
  1178. return CanSave;
  1179. }
  1180. private void MenuEnterReadModeEvent(object obj)
  1181. {
  1182. }
  1183. public void ShowPrintDialog()
  1184. {
  1185. DialogParameters printValue = new DialogParameters();
  1186. printValue.Add(ParameterNames.PDFViewer, PDFViewer);
  1187. printValue.Add(ParameterNames.FilePath, PDFViewer.Document.FileName);
  1188. printValue.Add(ParameterNames.PrintCurrentPage, PDFViewer.CurrentIndex);
  1189. printValue.Add(ParameterNames.Unicode, unicode);
  1190. dialogs.ShowDialog(DialogNames.HomePagePrinterDialog, printValue, e => { });
  1191. }
  1192. public void SelectClick()
  1193. {
  1194. if (OpenBOTA == false)
  1195. {
  1196. OpenBOTA = true;
  1197. }
  1198. bool isBook = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemSearch");
  1199. if (isBook == false)
  1200. {
  1201. bOTAContent.TabItemSearch.IsSelected = true;
  1202. }
  1203. }
  1204. private bool IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, string tabItemText)
  1205. {
  1206. bool isTabItem = false;
  1207. bOTAContentViewModel = null;
  1208. bOTAContent = null;
  1209. if (region.Regions.ContainsRegionWithName(this.BOTARegionName))
  1210. {
  1211. var views = region.Regions[this.BOTARegionName].Views;
  1212. var model = views.FirstOrDefault(q => q is BOTAContent);
  1213. if (model is BOTAContent bOTAContent1)
  1214. {
  1215. bOTAContent = bOTAContent1;
  1216. bOTAContentViewModel = bOTAContent.DataContext as BOTAContentViewModel;
  1217. if (bOTAContentViewModel.CurrentBar == tabItemText)
  1218. {
  1219. isTabItem = true;
  1220. }
  1221. }
  1222. }
  1223. return isTabItem;
  1224. }
  1225. private void InitialregionNameByTabItem(ref Dictionary<string, string> dictionary)
  1226. {
  1227. dictionary.Add("TabItemPageEdit", ToolContentRegionName);
  1228. dictionary.Add("TabItemTool", ToolsBarContentRegionName);
  1229. //其他工具菜单栏共用一个ToolsBarContentRegionName
  1230. dictionary.Add("TabItemAnnotation", ToolsBarContentRegionName);
  1231. dictionary.Add("TabItemConvert", ConverterBarContentRegionName);
  1232. dictionary.Add("TabItemScan", ToolsBarContentRegionName);
  1233. dictionary.Add("TabItemEdit", TextEditContentRegionName);
  1234. dictionary.Add("TabItemForm", ToolsBarContentRegionName);
  1235. dictionary.Add("TabItemFill", ToolsBarContentRegionName);
  1236. }
  1237. private void InitialbarContentByTabItem(ref Dictionary<string, string> dictionary)
  1238. {
  1239. dictionary.Add("TabItemPageEdit", "PageEditContent");
  1240. dictionary.Add("TabItemTool", "ToolsBarContent");
  1241. dictionary.Add("TabItemAnnotation", "AnnotToolContent");
  1242. dictionary.Add("TabItemConvert", "ConverterBarContent");
  1243. dictionary.Add("TabItemScan", "ScanContent");
  1244. dictionary.Add("TabItemEdit", "TextEditToolContent");
  1245. dictionary.Add("TabItemForm", "FormsToolContent");
  1246. dictionary.Add("TabItemFill", "FillAndSignContent");
  1247. }
  1248. private void UpdateShowContent(string currentBar)
  1249. {
  1250. ToolContentVisible = Visibility.Collapsed;
  1251. ToolsBarContentVisible = Visibility.Collapsed;
  1252. ConverterBarContentVisible = Visibility.Collapsed;
  1253. TextEditToolContentVisible = Visibility.Collapsed;
  1254. OCRContentVisible = Visibility.Collapsed;
  1255. switch (currentBar)
  1256. {
  1257. case "TabItemAnnotation":
  1258. case "TabItemTool":
  1259. case "TabItemForm":
  1260. case "TabItemFill":
  1261. ToolsBarContentVisible = Visibility.Visible;
  1262. break;
  1263. case "TabItemScan":
  1264. ToolsBarContentVisible = Visibility.Visible;
  1265. OCRContentVisible = Visibility.Visible;
  1266. break;
  1267. case "TabItemEdit":
  1268. TextEditToolContentVisible = Visibility.Visible;
  1269. break;
  1270. case "TabItemConvert":
  1271. ConverterBarContentVisible = Visibility.Visible;
  1272. break;
  1273. case "TabItemPageEdit":
  1274. case "HeaderFooterContent":
  1275. case "BatesContent":
  1276. case "WatermarkContent":
  1277. case "BackgroundContent":
  1278. case "RedactionContent":
  1279. ToolContentVisible = Visibility.Visible;
  1280. break;
  1281. default:
  1282. break;
  1283. }
  1284. PDFEditMode(currentBar);
  1285. FormMode(currentBar);
  1286. }
  1287. private void PDFEditMode(string currentBar)
  1288. {
  1289. if (currentBar == "TabItemEdit")
  1290. {
  1291. if (PDFViewer != null)
  1292. {
  1293. PDFViewer.SetMouseMode(MouseModes.PDFEdit);
  1294. //SelectedPrpoertyPanel("TextEditProperty", null);
  1295. //IsPropertyOpen = true;
  1296. }
  1297. }
  1298. else
  1299. {
  1300. if (PDFViewer != null && PDFViewer.MouseMode == MouseModes.PDFEdit)
  1301. {
  1302. IsPropertyOpen = false;
  1303. PDFViewer.SetMouseMode(MouseModes.PanTool);
  1304. }
  1305. }
  1306. }
  1307. private void FormMode(string currentBar)
  1308. {
  1309. if (currentBar == "TabItemForm")
  1310. {
  1311. if (PDFViewer != null)
  1312. {
  1313. PDFViewer.SetMouseMode(MouseModes.FormEditTool);
  1314. }
  1315. }
  1316. else
  1317. {
  1318. if (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool)
  1319. {
  1320. PDFViewer.SetMouseMode(MouseModes.PanTool);
  1321. }
  1322. }
  1323. }
  1324. private void UndoManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  1325. {
  1326. //不处于页面编辑模式下时,根据PDFVIewer的undo redo状态来更新按钮状态
  1327. if (e.PropertyName == "CanUndo")
  1328. {
  1329. CanUndo = PDFViewer.UndoManager.CanUndo;
  1330. }
  1331. if (e.PropertyName == "CanRedo")
  1332. {
  1333. CanRedo = PDFViewer.UndoManager.CanRedo;
  1334. }
  1335. if (e.PropertyName == "CanSave")
  1336. {
  1337. CanSave = PDFViewer.UndoManager.CanSave;
  1338. }
  1339. }
  1340. /// <summary>
  1341. /// 选项卡切换事件
  1342. /// </summary>
  1343. /// <param name="e"></param>
  1344. private void TabControlSelectonChangedEvent(object e)
  1345. {
  1346. var args = e as SelectionChangedEventArgs;
  1347. if (args != null)
  1348. {
  1349. var item = args.AddedItems[0] as TabItem;
  1350. CurrentBar = item.Name;
  1351. if (previousBar != CurrentBar)
  1352. {
  1353. if (CurrentBar == "TabItemPageEdit")//如果是页面编辑则进入页面编辑模式
  1354. {
  1355. EnterPageEdit();
  1356. }
  1357. else//其余情况直接导航至对应的工具栏即可,不需要清空之前的content,region里是单例模式
  1358. {
  1359. EnterSelectedBar(CurrentBar);
  1360. isInPageEdit = false;
  1361. }
  1362. previousBar = CurrentBar;
  1363. }
  1364. }
  1365. }
  1366. /// <summary>
  1367. /// 进入页面编辑模式
  1368. /// </summary>
  1369. public void EnterPageEdit()
  1370. {
  1371. if (TabSelectedIndex != 1)
  1372. {
  1373. TabSelectedIndex = 1;
  1374. }
  1375. CurrentBar = "TabItemPageEdit";
  1376. EnterToolMode(barContentByTabItem[CurrentBar]);
  1377. isInPageEdit = true;
  1378. }
  1379. /// <summary>
  1380. /// 阅读模式
  1381. /// </summary>
  1382. /// <param name="viewContent"></param>
  1383. public async void On_ReadMode()
  1384. {
  1385. App.mainWindowViewModel.SelectedItem.IsInReadctonMode = true;
  1386. mainViewModel.IsBookMode = true;
  1387. IsLoading = Visibility.Visible;
  1388. await Task.Delay(1);
  1389. PDFViewer.SetMouseMode(MouseModes.PanTool);
  1390. #region 旧版本
  1391. //NavigationParameters param = new NavigationParameters();
  1392. //param.Add(ParameterNames.PDFViewer, PDFViewer);
  1393. //param.Add(ParameterNames.ViewContentViewModel, this);
  1394. //region.RequestNavigate(ToolContentRegionName, "ReadViewContent", param);
  1395. ////ShowContent(CurrentBar, true);
  1396. //if (GridToolRow != 0)
  1397. //{
  1398. // GridToolRow = 0;
  1399. //}
  1400. //if (GridToolRowSpan != 4)
  1401. //{
  1402. // GridToolRowSpan = 4;
  1403. //}
  1404. ////isInPageEdit = true;
  1405. //UpdateShowContent("TabItemPageEdit");
  1406. #endregion 旧版本
  1407. this.events.GetEvent<ReadModeEvent>().Publish(new ReadModeArgs() { Unicode = unicode, IsReadMode = true });
  1408. if (region.Regions.ContainsRegionWithName(TipContentRegionName))
  1409. {
  1410. var views = region.Regions[TipContentRegionName].Views;
  1411. var isHasView = views.FindFirst(q => q is Views.TipContent.EnterReadModeTip);
  1412. if (isHasView == null)
  1413. {
  1414. region.RequestNavigate(TipContentRegionName, "EnterReadModeTip");
  1415. }
  1416. else
  1417. {
  1418. region.Regions[TipContentRegionName].Activate(isHasView);
  1419. }
  1420. }
  1421. IsLoading = Visibility.Collapsed;
  1422. ShowTip(true);
  1423. await Task.Delay(3000);
  1424. TipVisible = Visibility.Collapsed;
  1425. }
  1426. /// <summary>
  1427. /// 退出阅读模式
  1428. /// </summary>
  1429. public async void Off_ReadModel()
  1430. {
  1431. App.mainWindowViewModel.SelectedItem.IsInReadctonMode = false;
  1432. mainViewModel.IsBookMode = false;
  1433. IsLoading = Visibility.Visible;
  1434. await Task.Delay(1);
  1435. //PDFViewer.MouseMode = MouseModes.None;
  1436. #region 旧版本
  1437. //if (region.Regions.ContainsRegionWithName(ViwerRegionName))
  1438. //{
  1439. // if (region.Regions[ViwerRegionName].Views.Contains(PDFViewer))
  1440. // {
  1441. // var contentRegion = region.Regions[ViwerRegionName];
  1442. // contentRegion.Remove(PDFViewer);
  1443. // }
  1444. // //还原背景色
  1445. // PDFViewer.SetBackgroundBrush(new System.Windows.Media.SolidColorBrush(Settings.Default.AppProperties.InitialVIew.BackGround));
  1446. // region.AddToRegion(ViwerRegionName, PDFViewer);
  1447. //}
  1448. //if (string.IsNullOrEmpty(CurrentBar) || CurrentBar.Equals("TabItemPageEdit", StringComparison.OrdinalIgnoreCase))
  1449. //{
  1450. // EnterSelectedBar("TabItemAnnotation");
  1451. //}
  1452. //else
  1453. //{
  1454. // EnterSelectedBar(CurrentBar);
  1455. //}
  1456. #endregion 旧版本
  1457. //还原背景色
  1458. PDFViewer.SetBackgroundBrush(new System.Windows.Media.SolidColorBrush(Settings.Default.AppProperties.InitialVIew.BackGround));
  1459. this.events.GetEvent<ReadModeEvent>().Publish(new ReadModeArgs() { Unicode = unicode, IsReadMode = false });
  1460. if (region.Regions.ContainsRegionWithName(TipContentRegionName))
  1461. {
  1462. var views = region.Regions[TipContentRegionName].Views;
  1463. var isHasView = views.FindFirst(q => q is Views.TipContent.ReadModelTip);
  1464. if (isHasView == null)
  1465. {
  1466. region.RequestNavigate(TipContentRegionName, "ReadModelTip");
  1467. }
  1468. else
  1469. {
  1470. region.Regions[TipContentRegionName].Activate(isHasView);
  1471. }
  1472. }
  1473. IsLoading = Visibility.Collapsed;
  1474. ShowTip(true);
  1475. await Task.Delay(3000);
  1476. //ReadModelTip = Visibility.Collapsed;
  1477. TipVisible = Visibility.Collapsed;
  1478. }
  1479. #region PDFViewer鼠标滚轮缩放事件
  1480. public void PdfViewer_MouseWheelZoomHandler(object sender, bool e)
  1481. {
  1482. double newZoom = CheckZoomLevel(PDFViewer.ZoomFactor + (e ? 0.01 : -0.01), e);
  1483. PDFViewer.Zoom(newZoom);
  1484. }
  1485. public double CheckZoomLevel(double zoom, bool IsGrowth)
  1486. {
  1487. double standardZoom = 100;
  1488. if (zoom <= 0.01)
  1489. {
  1490. return 0.01;
  1491. }
  1492. if (zoom >= 10)
  1493. {
  1494. return 10;
  1495. }
  1496. zoom *= 100;
  1497. for (int i = 0; i < zoomLevel.Length - 1; i++)
  1498. {
  1499. if (zoom > zoomLevel[i] && zoom <= zoomLevel[i + 1] && IsGrowth)
  1500. {
  1501. standardZoom = zoomLevel[i + 1];
  1502. break;
  1503. }
  1504. if (zoom >= zoomLevel[i] && zoom < zoomLevel[i + 1] && !IsGrowth)
  1505. {
  1506. standardZoom = zoomLevel[i];
  1507. break;
  1508. }
  1509. }
  1510. return standardZoom / 100;
  1511. }
  1512. #endregion PDFViewer鼠标滚轮缩放事件
  1513. #region Navigate
  1514. public void OnNavigatedTo(NavigationContext navigationContext)
  1515. {
  1516. App.mainWindowViewModel.OphVis = Visibility.Collapsed;
  1517. var mainVM = navigationContext.Parameters[ParameterNames.MainViewModel] as MainContentViewModel;
  1518. if (mainVM != null)
  1519. {
  1520. mainViewModel = mainVM;
  1521. mainViewModel.viewContentViewModel = this;
  1522. }
  1523. var pdfview = navigationContext.Parameters[ParameterNames.PDFViewer] as CPDFViewer;
  1524. if (pdfview != null)
  1525. {
  1526. PDFViewer = pdfview;
  1527. if (loadFile())
  1528. {
  1529. CheckHaveAllPermission();
  1530. }
  1531. }
  1532. navigationContext.Parameters.TryGetValue(ParameterNames.PasswordInfo, out PasswordInfo);
  1533. //快捷键
  1534. KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
  1535. KeyEventsHelper.KeyDown += ShortCut_KeyDown;
  1536. }
  1537. public bool IsNavigationTarget(NavigationContext navigationContext)
  1538. {
  1539. if (navigationContext != null)
  1540. {
  1541. //另存为打开导航进来时 不能新建一个实例
  1542. return true;
  1543. }
  1544. else
  1545. {
  1546. //一次性打开多个文件时,需要新建实例
  1547. return false;
  1548. }
  1549. }
  1550. public void OnNavigatedFrom(NavigationContext navigationContext)
  1551. {
  1552. KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
  1553. }
  1554. #endregion Navigate
  1555. #region 方法
  1556. /// <summary>
  1557. /// 快捷键
  1558. /// </summary>
  1559. /// <param name="sender"></param>
  1560. /// <param name="e"></param>
  1561. /// <exception cref="NotImplementedException"></exception>
  1562. private void ShortCut_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
  1563. {
  1564. if (KeyEventsHelper.IsSingleKey(System.Windows.Input.Key.Escape))
  1565. {
  1566. if (mainViewModel.IsBookMode == true)
  1567. {
  1568. Off_ReadModel();
  1569. }
  1570. //内容选择 退出
  1571. if (PDFViewer.MouseMode != MouseModes.PanTool)
  1572. {
  1573. AnnotToolContent annotToolContent = GetAnnotToolContent(out AnnotToolContentViewModel toolContentViewModel);
  1574. if (annotToolContent != null && toolContentViewModel != null)
  1575. {
  1576. if (annotToolContent.BtnSelecttool.IsChecked == true)
  1577. {
  1578. if (toolContentViewModel.SnapshotEditMenuViewModel.SnapToolArgs != null)
  1579. {
  1580. toolContentViewModel.SnapshotEditMenuViewModel.SnapToolArgs.ReSnapshot();
  1581. annotToolContent.BtnSelecttool.IsChecked = false;
  1582. PDFViewer.SetMouseMode(MouseModes.PanTool);
  1583. }
  1584. }
  1585. }
  1586. }
  1587. }
  1588. if (KeyEventsHelper.IsModifierKey(ModifierKeys.Control, Key.C))
  1589. {
  1590. //内容选择 复制 快捷键
  1591. AnnotToolContent annotToolContent = GetAnnotToolContent(out AnnotToolContentViewModel toolContentViewModel);
  1592. if (annotToolContent != null && toolContentViewModel != null)
  1593. {
  1594. if (annotToolContent.BtnSelecttool.IsChecked == true)
  1595. {
  1596. toolContentViewModel.SnapshotEditMenuViewModel.SnapCopyCommand.Execute();
  1597. }
  1598. }
  1599. }
  1600. if (KeyEventsHelper.IsModifierKey(ModifierKeys.Control, Key.P))
  1601. {
  1602. AnnotToolContent annotToolContent = GetAnnotToolContent(out AnnotToolContentViewModel toolContentViewModel);
  1603. if (annotToolContent != null && toolContentViewModel != null)
  1604. {
  1605. if (annotToolContent.BtnSelecttool.IsChecked == true)
  1606. {
  1607. toolContentViewModel.SnapshotEditMenuViewModel.PrintCommand.Execute();
  1608. }
  1609. }
  1610. }
  1611. }
  1612. private AnnotToolContent GetAnnotToolContent(out AnnotToolContentViewModel toolContentViewModel)
  1613. {
  1614. AnnotToolContent toolContent = null;
  1615. toolContentViewModel = null;
  1616. if (region.Regions.ContainsRegionWithName(ToolsBarContentRegionName))
  1617. {
  1618. var views = region.Regions[ToolsBarContentRegionName].Views;
  1619. var model = views.FirstOrDefault(q => q is AnnotToolContent);
  1620. if (model is AnnotToolContent annotToolContent)
  1621. {
  1622. toolContent = annotToolContent;
  1623. toolContentViewModel = annotToolContent.DataContext as AnnotToolContentViewModel;
  1624. }
  1625. }
  1626. return toolContent;
  1627. }
  1628. /// <summary>
  1629. /// 视图面板 切换分屏模式
  1630. /// </summary>
  1631. /// <param name="mode"></param>
  1632. public void EnterSplitMode(SplitMode mode)
  1633. {
  1634. ///通知UI层更改布局
  1635. this.events.GetEvent<SplitEvent>().Publish(new SplitEventArgs() { Unicode = unicode, Mode = mode });
  1636. }
  1637. private void Undo()
  1638. {
  1639. PDFViewer.UndoManager.Undo();
  1640. }
  1641. private void Redo()
  1642. {
  1643. PDFViewer.UndoManager.Redo();
  1644. }
  1645. private void LoadControl()
  1646. {
  1647. //在构造函数中使用Region需要借助Dispatcher 确保UI已经加载完成,加载BOTA区域
  1648. // 非必要情况不要使用该异步方法,可能会导致一次性加载多个文件时出现因异步引起的regionname 错乱问题
  1649. //System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
  1650. // {
  1651. NavigationParameters parameters = new NavigationParameters();
  1652. parameters.Add(ParameterNames.PDFViewer, PDFViewer);
  1653. parameters.Add(ParameterNames.ViewContentViewModel, this);
  1654. region.RequestNavigate(BOTARegionName, "BOTAContent", parameters);
  1655. region.RequestNavigate(BottomToolRegionName, "BottomToolContent", parameters);
  1656. region.RequestNavigate(ReadModeRegionName, "ReadModeContent", parameters);
  1657. region.RequestNavigate(SplitViewerRegionName, "SplitScreenContent", parameters);
  1658. //TODO 根据上一次关闭记录的菜单,选中TabItem
  1659. EnterSelectedBar("TabItemAnnotation");
  1660. //}
  1661. //));
  1662. //if (App.IsBookMode)
  1663. //{
  1664. // RbtnReadMode();
  1665. //}
  1666. //else
  1667. //{
  1668. // UnReadModel();
  1669. //}
  1670. }
  1671. /// <summary>
  1672. /// 各个注释(选中和创建注释)导航到对应注释的属性面板
  1673. /// </summary>
  1674. /// <param name="Content"></param>
  1675. /// <param name="annotPropertyPanel"></param>
  1676. public void SelectedPrpoertyPanel(string Content, AnnotTransfer annotPropertyPanel)
  1677. {
  1678. if (Content == "PropertyPanelContent")
  1679. {
  1680. IsPropertyOpen = false;
  1681. }
  1682. else
  1683. {
  1684. IsPropertyOpen = true;
  1685. }
  1686. NavigationParameters parameters = new NavigationParameters();
  1687. //传其他参数:文档类,空注释面板;
  1688. parameters.Add(ParameterNames.PDFViewer, PDFViewer);
  1689. parameters.Add(ParameterNames.PropertyPanelContentViewModel, annotPropertyPanel);
  1690. parameters.Add(ParameterNames.ViewContentViewModel, this);
  1691. region.RequestNavigate(PropertyRegionName, Content, parameters);
  1692. }
  1693. /// <summary>
  1694. /// 将PDFViwer添加到Region
  1695. /// </summary>
  1696. private bool loadFile()
  1697. {
  1698. PDFViewer.MouseWheelZoomHandler += PdfViewer_MouseWheelZoomHandler;
  1699. PDFViewer.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
  1700. CanSave = PDFViewer.UndoManager.CanSave;
  1701. CanUndo = PDFViewer.UndoManager.CanUndo;
  1702. CanRedo = PDFViewer.UndoManager.CanRedo;
  1703. if (passwordInfo != null && (!string.IsNullOrEmpty(passwordInfo.OpenPassword) || !string.IsNullOrEmpty(passwordInfo.PermissionsPassword)))
  1704. {
  1705. if (!string.IsNullOrEmpty(passwordInfo.OpenPassword))
  1706. {
  1707. PDFViewer.Document.UnlockWithPassword(passwordInfo.OpenPassword);
  1708. }
  1709. if (!string.IsNullOrEmpty(passwordInfo.PermissionsPassword))
  1710. {
  1711. PDFViewer.Document.UnlockWithPassword(passwordInfo.PermissionsPassword);
  1712. }
  1713. }
  1714. else
  1715. {
  1716. VerifyPasswordResult result = SecurityHelper.VerifyPasswordByPasswordKind(PDFViewer.Document, EnumPasswordKind.StatusOpenPassword, dialogs);
  1717. if (result.IsDiscryptied)
  1718. {
  1719. if (result.Password != null)
  1720. {
  1721. string filePath = PDFViewer.Document.FilePath;
  1722. PDFViewer.Document.UnlockWithPassword(result.Password);
  1723. PDFViewer.Tag = result.Password;
  1724. //记录密码到内存
  1725. this.PassWord = result.Password;
  1726. }
  1727. }
  1728. if (result.IsDiscryptied == false)
  1729. {
  1730. //未成功解密文档时,释放Document对象,返回
  1731. PDFViewer.Document.Release();
  1732. //取消解密时关闭当前页签
  1733. App.mainWindowViewModel.CloseTabItem(App.mainWindowViewModel.SelectedItem);
  1734. return false;
  1735. }
  1736. }
  1737. PDFViewer.Load();
  1738. PDFViewer.SetFormFieldHighlight(Settings.Default.AppProperties.InitialVIew.HighlightLink);
  1739. PDFViewer.SetBackgroundBrush(new System.Windows.Media.SolidColorBrush(Settings.Default.AppProperties.InitialVIew.BackGround));
  1740. //还原上一次关闭前的视图设置
  1741. GetOpenFileInfo();
  1742. region.AddToRegion(ViwerRegionName, PDFViewer);
  1743. if (!App.OpenedFileList.Contains(PDFViewer.Document.FilePath))
  1744. {
  1745. App.OpenedFileList.Add(PDFViewer.Document.FilePath);
  1746. }
  1747. return true;
  1748. }
  1749. /// <summary>
  1750. /// 还原上一次浏览的视图相关设置
  1751. /// </summary>
  1752. private void GetOpenFileInfo()
  1753. {
  1754. OpenFileInfo = SettingHelper.GetFileInfo(PDFViewer.Document.FilePath);
  1755. //偏好设置里设置了记录上次视图设置时
  1756. if (OpenFileInfo != null && Settings.Default.AppProperties.Description.RecoveryViewWhenOpen)
  1757. {
  1758. if (OpenFileInfo.LastViewMode != PDFViewer.ModeView)
  1759. {
  1760. PDFViewer.ChangeViewMode(OpenFileInfo.LastViewMode);
  1761. }
  1762. if (OpenFileInfo.LastFitMode != PDFViewer.ModeFit)
  1763. {
  1764. PDFViewer.ChangeFitMode(OpenFileInfo.LastFitMode);
  1765. }
  1766. if (OpenFileInfo.LastFitMode == ComPDFKitViewer.FitMode.FitFree)
  1767. {
  1768. PDFViewer.Zoom(OpenFileInfo.LastZoom);
  1769. }
  1770. if (OpenFileInfo.LastPageIndex != PDFViewer.CurrentIndex)
  1771. {
  1772. PDFViewer.GoToPage(OpenFileInfo.LastPageIndex);
  1773. }
  1774. PDFViewer.SetSplitMode(OpenFileInfo.LastSplitMode);
  1775. PDFViewer.SetShowLink(OpenFileInfo.ShowHighLightLink);
  1776. if (OpenFileInfo.LastPageSpace)
  1777. {
  1778. PDFViewer.SetPageSpacing(8);
  1779. }
  1780. else
  1781. {
  1782. PDFViewer.SetPageSpacing(0);
  1783. }
  1784. if (OpenFileInfo.LastDrawMode == ComPDFKitViewer.DrawModes.Draw_Mode_Custom && OpenFileInfo.LastFillColor != 0)
  1785. {
  1786. PDFViewer.SetDrawMode(OpenFileInfo.LastDrawMode, OpenFileInfo.LastFillColor);
  1787. }
  1788. else
  1789. {
  1790. PDFViewer.SetDrawMode(OpenFileInfo.LastDrawMode);
  1791. }
  1792. }
  1793. else
  1794. {
  1795. //新文档应用默认设置
  1796. PDFViewer.ChangeViewMode(Settings.Default.AppProperties.InitialVIew.PageView);
  1797. PDFViewer.ChangeFitMode(Settings.Default.AppProperties.InitialVIew.ZoomMode);
  1798. PDFViewer.SetShowLink(Settings.Default.AppProperties.InitialVIew.HighlightLink);
  1799. }
  1800. }
  1801. /// <summary>
  1802. /// 已有路径文档的保存逻辑
  1803. /// </summary>
  1804. public bool saveFile()
  1805. {
  1806. try
  1807. {
  1808. if (string.IsNullOrEmpty(PDFViewer.Document.FilePath) || mainViewModel.NewFile)
  1809. return saveAsFile();
  1810. //文档已被修复时 提示另存为
  1811. if (PDFViewer.Document.HasRepaired)
  1812. {
  1813. AlertsMessage alertsMessage = new AlertsMessage();
  1814. alertsMessage.ShowDialog("", "文件已被修复,建议另存为", "Cancel", "OK");
  1815. if (alertsMessage.result == ContentResult.Ok)
  1816. return saveAsFile();
  1817. else
  1818. return false;
  1819. }
  1820. //文件路径无法存在时
  1821. if (!File.Exists(PDFViewer.Document.FilePath))
  1822. {
  1823. AlertsMessage alertsMessage = new AlertsMessage();
  1824. alertsMessage.ShowDialog("", "文件路径不存在,需要另存为", "Cancel", "OK");
  1825. if (alertsMessage.result == ContentResult.Ok)
  1826. return saveAsFile();
  1827. else
  1828. return false;
  1829. }
  1830. //只读文件无法写入时,提示另存为
  1831. FileInfo fileInfo = new FileInfo(PDFViewer.Document.FilePath);
  1832. if (fileInfo.IsReadOnly)
  1833. {
  1834. AlertsMessage alertsMessage = new AlertsMessage();
  1835. alertsMessage.ShowDialog("", "文件为只读文件,需要另存为", "Cancel", "OK");
  1836. if (alertsMessage.result == ContentResult.Ok)
  1837. return saveAsFile();
  1838. else
  1839. return false;
  1840. }
  1841. //Security Fixed:
  1842. //修改密码后原文档保存的步骤:
  1843. //在设置密码窗口传出“已修改”信号,并允许延迟保存
  1844. //
  1845. if (SecurityInfo.IsPasswordChanged)
  1846. {
  1847. string currentFilePath = PDFViewer.Document.FilePath;
  1848. string tempFilePath = PDFViewer.Document.FilePath + ".temp.pdf";
  1849. string openPassword = string.Empty;
  1850. string permissionsPassword = string.Empty;
  1851. CPDFPermissionsInfo cPDFPermissionsInfo = CreateDefaultPermissionsInfo();
  1852. if (SecurityInfo.NeedOpenPassword)
  1853. {
  1854. openPassword = SecurityInfo.OpenPassword;
  1855. }
  1856. if (SecurityInfo.NeedPermissionsPassword)
  1857. {
  1858. permissionsPassword = SecurityInfo.PermissionsPassword;
  1859. cPDFPermissionsInfo = SecurityInfo.CPDFPermissionsInfo;
  1860. }
  1861. try
  1862. {
  1863. string currentPath = PDFViewer.Document.FilePath;
  1864. string tempPath = PDFViewer.Document.FilePath + ".temp.pdf";
  1865. if (PDFViewer.Document.Descrypt(tempPath))
  1866. {
  1867. PDFViewer.CloseDocument();
  1868. PDFViewer.InitDocument(tempPath);
  1869. PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
  1870. if (PDFViewer.Document.WriteToFilePath(currentPath))
  1871. {
  1872. PDFViewer.CloseDocument();
  1873. PDFViewer.InitDocument(currentPath);
  1874. if (!string.IsNullOrEmpty(openPassword))
  1875. {
  1876. PDFViewer.Document.UnlockWithPassword(openPassword);
  1877. }
  1878. if (!string.IsNullOrEmpty(permissionsPassword))
  1879. {
  1880. PDFViewer.Document.CheckOwnerPassword(permissionsPassword);
  1881. }
  1882. try
  1883. {
  1884. PDFViewer.Load();
  1885. }
  1886. catch
  1887. {
  1888. }
  1889. PDFViewer.UndoManager.CanSave = false;
  1890. SecurityInfo.IsPasswordChanged = false;
  1891. }
  1892. else
  1893. {
  1894. return false;
  1895. }
  1896. System.IO.File.Delete(tempPath);
  1897. }
  1898. else
  1899. {
  1900. return false;
  1901. }
  1902. return true;
  1903. }
  1904. catch
  1905. {
  1906. return false;
  1907. }
  1908. }
  1909. else if (SecurityInfo.IsPasswordRemoved)
  1910. {
  1911. try
  1912. {
  1913. string currentPath = PDFViewer.Document.FilePath;
  1914. string tempPath = PDFViewer.Document.FilePath + ".temp.pdf";
  1915. PDFViewer.Document.Descrypt(tempPath);
  1916. PDFViewer.CloseDocument();
  1917. PDFViewer.InitDocument(tempPath);
  1918. PDFViewer.Document.WriteToFilePath(currentPath);
  1919. PDFViewer.CloseDocument();
  1920. PDFViewer.InitDocument(currentPath);
  1921. PDFViewer.Load();
  1922. System.IO.File.Delete(tempPath);
  1923. }
  1924. catch
  1925. {
  1926. return false;
  1927. }
  1928. }
  1929. bool result = PDFViewer.Document.WriteToLoadedPath();
  1930. if (result)
  1931. {
  1932. PDFViewer.UndoManager.CanSave = false;
  1933. App.Current.Dispatcher.Invoke(() =>
  1934. {
  1935. //保存时更新缩略图
  1936. OpenFileInfo info = SettingHelper.GetFileInfo(PDFViewer.Document.FilePath);
  1937. try
  1938. {
  1939. if (!string.IsNullOrEmpty(info.ThumbImgPath) && !PDFViewer.Document.IsEncrypted)//加密的文档不获取缩略图
  1940. {
  1941. var size = PDFViewer.Document.GetPageSize(0);
  1942. System.Drawing.Bitmap bitmap = ToolMethod.RenderPageBitmapNoWait(PDFViewer.Document, (int)size.Width, (int)size.Height, 0, true, true);
  1943. string folderPath = System.IO.Path.Combine(App.CurrentPath, "CoverImage");
  1944. if (File.Exists(folderPath))
  1945. File.Delete(folderPath);
  1946. DirectoryInfo folder = new DirectoryInfo(folderPath);
  1947. if (!folder.Exists)
  1948. folder.Create();
  1949. string imagePath = info.ThumbImgPath;
  1950. if (!File.Exists(imagePath))//由加密文档变为非加密文档时 新建一个路径
  1951. {
  1952. string imageName = Guid.NewGuid().ToString();
  1953. imagePath = System.IO.Path.Combine(folderPath, imageName);
  1954. using (FileStream stream = new FileStream(imagePath, FileMode.Create))
  1955. {
  1956. bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
  1957. }
  1958. }
  1959. else
  1960. {
  1961. using (FileStream stream = new FileStream(imagePath, FileMode.Open))
  1962. {
  1963. bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
  1964. }
  1965. }
  1966. info.ThumbImgPath = imagePath;
  1967. SettingHelper.SetFileInfo(info);
  1968. }
  1969. }
  1970. catch
  1971. {
  1972. info.ThumbImgPath = null;
  1973. SettingHelper.SetFileInfo(info);
  1974. }
  1975. });
  1976. PDFViewer.ReloadDocument();
  1977. }
  1978. else
  1979. {
  1980. //文件被占用 保存失败时
  1981. AlertsMessage alertsMessage = new AlertsMessage();
  1982. alertsMessage.ShowDialog("", "文件被占用,需要另存为", "Cancel", "OK");
  1983. if (alertsMessage.result == ContentResult.Ok)
  1984. return saveAsFile();
  1985. else
  1986. return false;
  1987. }
  1988. return result;
  1989. }
  1990. catch { return false; }
  1991. finally
  1992. {
  1993. ShowLeftTip(false);
  1994. }
  1995. }
  1996. /// <summary>
  1997. /// 另存为或新文档保存逻辑
  1998. /// </summary>
  1999. public bool saveAsFile(Action RedactionAction = null)
  2000. {
  2001. var dlg = new Microsoft.Win32.SaveFileDialog();
  2002. dlg.Filter = Properties.Resources.OpenDialogFilter;
  2003. dlg.FileName = PDFViewer.Document.FileName;
  2004. if (dlg.ShowDialog() == true && !string.IsNullOrEmpty(dlg.FileName))
  2005. {
  2006. bool result = false;
  2007. if (RedactionAction != null)
  2008. {
  2009. //保存前进行标记密文处理应用或擦除
  2010. RedactionAction.Invoke();
  2011. }
  2012. if (App.OpenedFileList.Contains(dlg.FileName))
  2013. {
  2014. //提示文件已经被打开
  2015. }
  2016. else
  2017. {
  2018. string oldpath = PDFViewer.Document.FilePath;
  2019. string openPassword = string.Empty;
  2020. string permissionsPassword = string.Empty;
  2021. CPDFPermissionsInfo cPDFPermissionsInfo = CreateDefaultPermissionsInfo();
  2022. if (SecurityInfo.NeedOpenPassword)
  2023. {
  2024. openPassword = SecurityInfo.OpenPassword;
  2025. passwordInfo.OpenPassword = openPassword;
  2026. }
  2027. if (SecurityInfo.NeedPermissionsPassword)
  2028. {
  2029. permissionsPassword = SecurityInfo.PermissionsPassword;
  2030. cPDFPermissionsInfo = SecurityInfo.CPDFPermissionsInfo;
  2031. passwordInfo.PermissionsPassword = permissionsPassword;
  2032. }
  2033. PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
  2034. result = PDFViewer.Document.WriteToFilePath(dlg.FileName);
  2035. if (result)
  2036. {
  2037. mainViewModel.NewFile = false;
  2038. App.OpenedFileList.Remove(oldpath);
  2039. DoAfterSaveAs(dlg.FileName);
  2040. }
  2041. else
  2042. {
  2043. //提示文件被其他软件占用 无法保存
  2044. //MessageBoxEx.Show(App.MainPageLoader.GetString("Main_TheFileOccupiedWarning"), "", Winform.MessageBoxButtons.OKCancel, new string[] { App.MainPageLoader.GetString("Main_SaveAs"), App.MainPageLoader.GetString("Main_Cancel") });
  2045. }
  2046. }
  2047. return result;
  2048. }
  2049. else
  2050. return false;
  2051. }
  2052. /// <summary>
  2053. /// 另存为Flatten
  2054. /// </summary>
  2055. private void saveAsFlatten()
  2056. {
  2057. var dlg = new SaveFileDialog();
  2058. dlg.Filter = Properties.Resources.OpenDialogFilter;
  2059. dlg.FileName = PDFViewer.Document.FileName.Substring(0, PDFViewer.Document.FileName.LastIndexOf(".")) + "_Flatten.pdf";
  2060. if (dlg.ShowDialog() == true && !string.IsNullOrEmpty(dlg.FileName))
  2061. {
  2062. saveFile();
  2063. CPDFDocument kmdoc = CPDFDocument.InitWithFilePath(PDFViewer.Document.FileName);
  2064. if (kmdoc == null)
  2065. return;
  2066. bool result = kmdoc.WriteFlattenToFilePath(dlg.FileName);
  2067. if (result)
  2068. System.Diagnostics.Process.Start("explorer", "/select,\"" + dlg.FileName + "\"");
  2069. kmdoc.Release();
  2070. }
  2071. }
  2072. /// <summary>
  2073. /// 另存为后进行的操作
  2074. /// 重新打开新文档
  2075. /// </summary>
  2076. /// <param name="targetPath"></param>
  2077. public void DoAfterSaveAs(string targetPath)
  2078. {
  2079. string oldFilePath = targetPath;
  2080. PDFViewer.UndoManager.CanSave = false;
  2081. mainViewModel.OpenFile(targetPath, passwordInfo);
  2082. //TODO:通知各模块更新PDFview对象
  2083. //var result = OpenFile(targetPath, true);
  2084. //if (result)
  2085. //{
  2086. // FileChanged.Invoke(this, null);
  2087. // Zoomer.PdfViewer = PdfViewer;
  2088. // PageSelector.PdfViewer = PdfViewer;
  2089. // ViewModeSelector.PdfViewer = PdfViewer;
  2090. // OpenFileInfo fileInfo = SettingHelper.GetFileInfo(oldFilePath);
  2091. // if (fileInfo != null)
  2092. // {
  2093. // PdfViewer.ChangeViewMode(fileInfo.LastViewMode);
  2094. // PdfViewer.ChangeFitMode(fileInfo.LastFitMode);
  2095. // if (fileInfo.LastFitMode == FitMode.FitFree)
  2096. // PdfViewer.Zoom(fileInfo.LastZoom);
  2097. // PdfViewer.GoToPage(fileInfo.LastPageIndex);
  2098. // if (fileInfo.LastDrawMode == DrawModes.Draw_Mode_Custom && fileInfo.LastFillColor != 0)
  2099. // PdfViewer.SetDrawMode(fileInfo.LastDrawMode, fileInfo.LastFillColor);
  2100. // else
  2101. // PdfViewer.SetDrawMode(fileInfo.LastDrawMode);
  2102. // }
  2103. //}
  2104. }
  2105. /// <summary>
  2106. /// 显示前添加内容到Region
  2107. /// </summary>
  2108. /// <param name="isPageEdit"></param>
  2109. private void ShowContent(string currentBar, bool isToolMode = false)
  2110. {
  2111. GridVisibility = Visibility.Visible;
  2112. //显示页面编辑或其他工具
  2113. if (currentBar == "TabItemPageEdit" || isToolMode)
  2114. {
  2115. if (currentBar == "TabItemPageEdit")//进入页面编辑
  2116. {
  2117. if (GridToolRow != 1)
  2118. {
  2119. GridToolRow = 1;
  2120. }
  2121. if (GridToolRowSpan != 3)
  2122. {
  2123. GridToolRowSpan = 3;
  2124. }
  2125. }
  2126. else//进入水印等其他工具模式
  2127. {
  2128. GridVisibility = Visibility.Collapsed;
  2129. if (GridToolRow != 0)
  2130. {
  2131. GridToolRow = 0;
  2132. }
  2133. if (GridToolRowSpan != 4)
  2134. {
  2135. GridToolRowSpan = 4;
  2136. }
  2137. }
  2138. //ToolContent的visible跟toolsbarContent 的visible是互斥的
  2139. UpdateShowContent(currentBar);
  2140. }
  2141. else
  2142. {
  2143. if (GridToolRow != 1)
  2144. {
  2145. GridToolRow = 1;
  2146. }
  2147. UpdateShowContent(currentBar);
  2148. }
  2149. }
  2150. /// <summary>
  2151. /// 从二级工具栏进入需要修改界面布局的场景
  2152. /// </summary>
  2153. /// <param name="EditToolName"></param>
  2154. private void EnterEditTools(StringWithUnicode EditToolName)
  2155. {
  2156. EnterSelectedEditTool(EditToolName);
  2157. }
  2158. private void CloseEditTool(EnumCloseModeUnicode enumCloseModeunicode)
  2159. {
  2160. EnumCloseMode enumCloseMode = enumCloseModeunicode.Status;
  2161. if (enumCloseMode == EnumCloseMode.StatusConfirm)
  2162. {
  2163. PDFViewer.Document.ReleasePages();
  2164. PDFViewer.ReloadDocument();
  2165. }
  2166. //如果是其他工具共用一个PDFview,退出工具模式后,需要重新添加到Region,否则不会显示
  2167. if (!region.Regions[ViwerRegionName].Views.Contains(PDFViewer))
  2168. {
  2169. region.AddToRegion(ViwerRegionName, PDFViewer);
  2170. }
  2171. CurrentBar = "TabItemTool";
  2172. EnterSelectedBar(CurrentBar);
  2173. }
  2174. /// <summary>
  2175. /// 二级菜单指定目标处理
  2176. /// </summary>
  2177. /// <param name="e"></param>
  2178. private void EnterSelectedEditTool(StringWithUnicode EditToolName)
  2179. {
  2180. CurrentBar = EditToolName.EditToolsContentName;
  2181. EnterToolMode(CurrentBar);
  2182. }
  2183. /// <summary>
  2184. /// 进入工具编辑(如页面编辑、水印、密文等)模式
  2185. /// </summary>
  2186. /// <param name="targetToolMode">要导航过去的控件名称</param>
  2187. /// <param name="valuePairs">导航需要传送的参数,为空时,默认传送PDFView和ViewContentViewModel</param>
  2188. private async void EnterToolMode(string targetToolMode, NavigationParameters valuePairs = null)
  2189. {
  2190. IsLoading = Visibility.Visible;
  2191. await Task.Delay(3);
  2192. NavigationParameters param = new NavigationParameters();
  2193. if (valuePairs == null)
  2194. {
  2195. param.Add(ParameterNames.PDFViewer, PDFViewer);
  2196. param.Add(ParameterNames.ViewContentViewModel, this);
  2197. }
  2198. else//有传入其他内容的参数时
  2199. {
  2200. param = valuePairs;
  2201. }
  2202. region.RequestNavigate(ToolContentRegionName, targetToolMode, param);
  2203. ShowContent(CurrentBar, true);
  2204. IsLoading = Visibility.Collapsed;
  2205. }
  2206. private void EnterSelectedBar(string currentBar)
  2207. {
  2208. NavigationParameters param = new NavigationParameters();
  2209. param.Add(ParameterNames.PDFViewer, PDFViewer);
  2210. param.Add(ParameterNames.ViewContentViewModel, this);
  2211. region.RequestNavigate(regionNameByTabItem[currentBar], barContentByTabItem[currentBar], param);
  2212. if (currentBar == "TabItemScan")
  2213. {
  2214. region.RequestNavigate(RegionNames.OCRViewerRegionName, "ScanViwer", param);
  2215. }
  2216. ShowContent(currentBar);
  2217. }
  2218. /// <summary>
  2219. /// 退出工具(水印、密文等)编辑模式,隐藏ToolContent
  2220. /// </summary>
  2221. public void ExitToolMode()
  2222. {
  2223. ToolContentVisible = Visibility.Collapsed;
  2224. if (isInPageEdit)
  2225. {
  2226. TabSelectedIndex = 0;
  2227. isInPageEdit = false;
  2228. }
  2229. }
  2230. #endregion 方法
  2231. }
  2232. }