AnnotToolContentViewModel.cs 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703
  1. using ComPDFKit.PDFAnnotation;
  2. using ComPDFKit.PDFDocument;
  3. using ComPDFKitViewer;
  4. using ComPDFKitViewer.AnnotEvent;
  5. using ComPDFKitViewer.PdfViewer;
  6. using ImTools;
  7. using Microsoft.Win32;
  8. using PDF_Master.CustomControl;
  9. using PDF_Master.EventAggregators;
  10. using PDF_Master.Helper;
  11. using PDF_Master.Model;
  12. using PDF_Master.Model.BOTA;
  13. using PDF_Master.Properties;
  14. using PDF_Master.ViewModels.BOTA;
  15. using PDF_Master.ViewModels.PropertyPanel;
  16. using PDF_Master.ViewModels.PropertyPanel.AnnotPanel;
  17. using PDF_Master.ViewModels.Tools.AnnotManager;
  18. using PDF_Master.Views.BOTA;
  19. using PDF_Master.Views.PropertyPanel.AnnotPanel;
  20. using PDFSettings;
  21. using PDFSettings.Settings;
  22. using Prism.Commands;
  23. using Prism.Events;
  24. using Prism.Mvvm;
  25. using Prism.Regions;
  26. using Prism.Services.Dialogs;
  27. using System;
  28. using System.Collections.Generic;
  29. using System.IO;
  30. using System.Linq;
  31. using System.Reflection;
  32. using System.Text;
  33. using System.Threading.Tasks;
  34. using System.Windows;
  35. using System.Windows.Annotations;
  36. using System.Windows.Controls;
  37. using System.Windows.Controls.Primitives;
  38. using System.Windows.Forms;
  39. using System.Windows.Input;
  40. using System.Windows.Media;
  41. using System.Windows.Media.Imaging;
  42. using ContextMenu = System.Windows.Controls.ContextMenu;
  43. using KeyEventArgs = System.Windows.Input.KeyEventArgs;
  44. using MenuItem = System.Windows.Controls.MenuItem;
  45. namespace PDF_Master.ViewModels.Tools
  46. {
  47. public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
  48. {
  49. #region 初始化
  50. public AnnotToolContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IDialogService dialogService)
  51. {
  52. region = regionManager;
  53. events = eventAggregator;
  54. dialogs = dialogService;
  55. InitCommand();
  56. InitDefaultValue();
  57. InitToolDict();
  58. InitToolTipDict();
  59. InitPopMenu();
  60. SubscribeEvent();
  61. AnnotContainerBorderColor();
  62. }
  63. //注释容器选中边框的颜色
  64. private void AnnotContainerBorderColor()
  65. {
  66. var pen = new Pen(new SolidColorBrush(Color.FromArgb(0xFF, 0x17, 0x70, 0xF4)), 1);
  67. CommonDrawData.ActiveBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x17, 0x70, 0xF4));
  68. CommonDrawData.ActivePen = pen;
  69. }
  70. //事件聚合器
  71. private void SubscribeEvent()
  72. {
  73. Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
  74. events.GetEvent<FillAndSignEvent>().Subscribe(FromFillAndSign, e => e.AppUnicode == Unicode);
  75. }
  76. private void InitPopMenu()
  77. {
  78. InitSelectHightAnnotMenu();
  79. InitSelectFreeHandAnnotMenu();
  80. InitSelectFreeTextAnnotMenu();
  81. InitSelectStrickNoteAnnotMenu();
  82. InitSelectShapeAnnotMenu();
  83. InitSelectLinkAnnotMenu();
  84. InitSelectStampAnnotMenu();
  85. InitSelectMultiAnnotMenu();
  86. }
  87. private void InitCommand()
  88. {
  89. MyToolsCommand = new DelegateCommand<CustomIconToggleBtn>(BtnMyTools_Click);
  90. SetAddAnnotationCommand = new DelegateCommand<object>(AddAnnotation_Click);
  91. AddBookMarkCommand = new DelegateCommand(AddBookMark_Click);
  92. PropertyRegionName = Guid.NewGuid().ToString();
  93. HandCommand = new DelegateCommand(Hand_Click);
  94. #region 注释 - 右键菜单
  95. //公共command
  96. AnnotDefaultValue_MenuCommand = new DelegateCommand<object>(AnnotDefaultValues_Menu);
  97. AnnotColorPalette_MenuCommand = new DelegateCommand<object>(AnnotColorPalette_Menu);
  98. AnnotAddNoteText_MenuCommand = new DelegateCommand<object>(AnnotAddNoteText_Menu);
  99. //高亮、下划线、删除
  100. HightAnnotCopyText_MenuCommand = new DelegateCommand<object>(HightAnnotCopyText_Menu);
  101. //手绘
  102. FreeHandLineStyle_MenuCommand = new DelegateCommand<object>(FreeHandLineStyle_Menu);
  103. //文本
  104. FreeTextFontFamily_MenuCommand = new DelegateCommand<object>(FreeTextFontFamily_Menu);
  105. FreeTextAglin_MenuCommand = new DelegateCommand<object>(FreeTextAglin_Menu);
  106. //便签
  107. StrikeNoteEditStrike_MenuCommand = new DelegateCommand<object>(StrikeNoteEditStrike_Menu);
  108. //形状
  109. ShapeLineStyle_MenuCommand = new DelegateCommand<object>(ShapeLineStyle_Menu);
  110. ShapeLineDirect_MenuCommand = new DelegateCommand<object>(ShapeLineDirect_Menu);
  111. //图章
  112. StampExportPicture_MenuCommand = new DelegateCommand<object>(StampExportPicture_Menu);
  113. //链接
  114. Link_MenuCommand = new DelegateCommand<object>(Link_Menu);
  115. #endregion 注释 - 右键菜单
  116. }
  117. #endregion 初始化
  118. #region 注释工具栏 -》Command实现
  119. //手型工具
  120. private void Hand_Click()
  121. {
  122. HandToolIsCheckedEvent(BtnHandIsChecked);
  123. if (BtnHandIsChecked)
  124. {
  125. //其余注释工具 取消选中
  126. StrAnnotToolChecked = "";
  127. BtnLinkIsChecked = false;
  128. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  129. }
  130. }
  131. //手型工具按钮选中或取消
  132. private void HandToolIsCheckedEvent(bool isChecked)
  133. {
  134. if (isChecked == false)
  135. {
  136. //鼠标框选多选注释
  137. if (PDFViewer.MouseMode != MouseModes.AnnotCreate)
  138. {
  139. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  140. var annotArgs = new SelectToolArgs();
  141. PDFViewer.SetToolParam(annotArgs);
  142. }
  143. else
  144. {
  145. PDFViewer.SetMouseMode(MouseModes.PanTool);
  146. }
  147. }
  148. else
  149. {
  150. //鼠标滚动页面
  151. PDFViewer.SetMouseMode(MouseModes.Scroll);
  152. PDFViewer.SetToolParam(new AnnotHandlerEventArgs());
  153. }
  154. }
  155. //点击注释工具
  156. private void BtnMyTools_Click(CustomIconToggleBtn annotBtn)
  157. {
  158. if (annotBtn == null || annotBtn.Tag == null) return;
  159. //不创建注释,属于注释模板
  160. Dictionary<string, bool> dictVar = new Dictionary<string, bool>();
  161. dictVar.Add("isTemplateAnnot", false);
  162. dictVar.Add("isSnapshotEdit", false);
  163. AnnotHandlerEventArgs annotArgs = null;
  164. var tag = annotBtn.Tag.ToString();
  165. if (annotBtn.Name == "BtnShowAnnot")
  166. {
  167. //显示/隐藏注释
  168. PDFViewer.SetDrawAnnot((bool)annotBtn.IsChecked);
  169. return;
  170. }
  171. if (annotBtn.IsChecked == true)
  172. {
  173. propertyPanel.SaveLastAnnot();
  174. MyToolCheckedDoing(dictVar, tag);
  175. FindAnnotTypeKey(tag, ref annotArgs);
  176. if (annotArgs != null)
  177. {
  178. //设置点击页面会创建对应选中注释工具的注释
  179. annotArgs.Author = Settings.Default.AppProperties.Description.Author;
  180. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  181. PDFViewer.SetToolParam(annotArgs);
  182. }
  183. }
  184. else
  185. {
  186. //取消选中注释工具按钮后,恢复到未编辑注释的状态
  187. propertyPanel.IsAddLink = false;
  188. propertyPanel.IsLocationLink = false;
  189. PDFViewer.ToolManager.EnableClickCreate = false;
  190. ShowPropertyPanel(false);
  191. }
  192. if (dictVar["isTemplateAnnot"] == false && annotArgs == null)
  193. {
  194. //当不是注释模板,且无创建注释时,属性面板显示为空内容
  195. HandToolIsCheckedEvent(false);
  196. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  197. }
  198. else
  199. {
  200. if (dictVar["isSnapshotEdit"] == true)
  201. {
  202. ShowPropertyPanel(false);
  203. }
  204. else
  205. {
  206. ShowPropertyPanel((bool)annotBtn.IsChecked);
  207. }
  208. }
  209. }
  210. //选中注释工具按钮时,处理的一些系列事情
  211. private void MyToolCheckedDoing(Dictionary<string, bool> dict, string tag)
  212. {
  213. if (BtnHandIsChecked)
  214. BtnHandIsChecked = false;
  215. PDFViewer.ClearSelectAnnots();
  216. //选中内容选择工具按钮
  217. if (tag == "SnapshotEdit")
  218. {
  219. dict["isSnapshotEdit"] = true;
  220. }
  221. else if (tag == "Signature" || tag == "Stamp")
  222. {
  223. //选中签名、图章工具按钮
  224. dict["isTemplateAnnot"] = true;
  225. }
  226. //超链接工具
  227. //if (tag != "Link")
  228. // BtnLinkIsChecked = false;
  229. //else
  230. // StrAnnotToolChecked = "Link";
  231. if (tag != "Link")
  232. {
  233. events.GetEvent<LinkAnnotTipCloseEvent>().Publish(new LinkAnnotTipCloseArgs() { UniCode = App.mainWindowViewModel.SelectedItem.Unicode });
  234. //if (region.Regions.ContainsRegionWithName(viewContentViewModel.TipContentRegionName))
  235. //{
  236. // var views = region.Regions[viewContentViewModel.TipContentRegionName].Views;
  237. // Views.TipContent.LinkAnnotTip isHas = (Views.TipContent.LinkAnnotTip)views.FindFirst(q => q is Views.TipContent.LinkAnnotTip);
  238. // if (isHas != null)
  239. // {
  240. // viewContentViewModel.TipVisible = System.Windows.Visibility.Collapsed;
  241. // (isHas.DataContext as LinkAnnotPropertyViewModel).BtnLocationIsChecked = false;
  242. // }
  243. //}
  244. }
  245. if (tag == "Rect" || tag == "Circle" || tag == "Arrow" || tag == "Line")
  246. {
  247. //新建形状注释,设置默认大小
  248. PDFViewer.ToolManager.EnableClickCreate = true;
  249. PDFViewer.ToolManager.ClickCreateWidth = 140;
  250. PDFViewer.ToolManager.ClickCreateHeight = 140;
  251. }
  252. else
  253. {
  254. PDFViewer.ToolManager.EnableClickCreate = false;
  255. }
  256. }
  257. #endregion 注释工具栏 -》Command实现
  258. #region BOTA
  259. private AnnotationContentViewModel GetAnnotationContentViewModel(BOTAContentViewModel bOTAContentViewModel, out AnnotationContent annotation)
  260. {
  261. AnnotationContentViewModel viewModel = null;
  262. annotation = null;
  263. if (bOTAContentViewModel != null)
  264. {
  265. if (region.Regions.ContainsRegionWithName(bOTAContentViewModel.BOTAContentRegionName))
  266. {
  267. var views = region.Regions[bOTAContentViewModel.BOTAContentRegionName].Views;
  268. foreach (var item in views)
  269. {
  270. if (item is AnnotationContent annotation1)
  271. {
  272. annotation = annotation1;
  273. viewModel = annotation1.DataContext as AnnotationContentViewModel;
  274. break;
  275. }
  276. }
  277. }
  278. }
  279. return viewModel;
  280. }
  281. /// <summary>
  282. /// 判断Bota的TabItem是否已显示
  283. /// </summary>
  284. /// <param name="bOTAContentViewModel"></param>
  285. /// <param name="bOTAContent"></param>
  286. /// <param name="tabItemText"></param>
  287. /// <returns></returns>
  288. private bool IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, string tabItemText)
  289. {
  290. bool isTabItem = false;
  291. bOTAContentViewModel = null;
  292. bOTAContent = null;
  293. if (region.Regions.ContainsRegionWithName(viewContentViewModel.BOTARegionName))
  294. {
  295. var views = region.Regions[viewContentViewModel.BOTARegionName].Views;
  296. var model = views.FirstOrDefault(q => q is BOTAContent);
  297. if (model is BOTAContent bOTAContent1)
  298. {
  299. bOTAContent = bOTAContent1;
  300. bOTAContentViewModel = bOTAContent.DataContext as BOTAContentViewModel;
  301. if (bOTAContentViewModel.CurrentBar == tabItemText)
  302. {
  303. isTabItem = true;
  304. }
  305. }
  306. }
  307. return isTabItem;
  308. }
  309. private void Select_Click(object sender, RoutedEventArgs e)
  310. {
  311. if (viewContentViewModel.OpenBOTA == false)
  312. {
  313. viewContentViewModel.OpenBOTA = true;
  314. }
  315. bool isBook = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemSearch");
  316. if (isBook == false)
  317. {
  318. bOTAContent.TabItemSearch.IsSelected = true;
  319. }
  320. }
  321. #endregion BOTA
  322. #region 阅读页右键菜单
  323. /// <summary>
  324. /// 空白处-右键菜单-添加注释
  325. /// </summary>
  326. /// <param name="sender"></param>
  327. private void AddAnnotation_Click(object sender)
  328. {
  329. if (sender is MenuItem menuItem)
  330. {
  331. AnnotHandlerEventArgs annotHandler = null;
  332. string str = menuItem.Tag.ToString();
  333. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  334. propertyPanel.IsAddLink = false;
  335. propertyPanel.IsLocationLink = false;
  336. if (str == AddAnnotType.AnnotFreehand.ToString())
  337. {
  338. annotHandler = GetFreehand();
  339. }
  340. if (str == AddAnnotType.AnnotFreeText.ToString())
  341. {
  342. annotHandler = GetFreetext();
  343. }
  344. if (str == AddAnnotType.AnnotSticky.ToString())
  345. {
  346. annotHandler = GetStickyNote();
  347. }
  348. if (str == AddAnnotType.AnnotSquare.ToString())
  349. {
  350. annotHandler = GetRect();
  351. }
  352. if (str == AddAnnotType.AnnotCircle.ToString())
  353. {
  354. annotHandler = GetCircle();
  355. }
  356. if (str == AddAnnotType.AnnotArrow.ToString())
  357. {
  358. annotHandler = GetArrowLine("Arrow");
  359. }
  360. if (str == AddAnnotType.AnnotLine.ToString())
  361. {
  362. annotHandler = GetArrowLine("Line");
  363. }
  364. if (str == AddAnnotType.AnnotLink.ToString())
  365. {
  366. propertyPanel.IsAddLink = true;
  367. annotHandler = GetLink();
  368. }
  369. if (str == AddAnnotType.AnnotStamp.ToString())
  370. {
  371. annotHandler = GetStamp();
  372. }
  373. if (str == AddAnnotType.AnnotAutograph.ToString())
  374. {
  375. annotHandler = GetSignature();
  376. }
  377. if (annotHandler != null)
  378. {
  379. annotHandler.Author = Settings.Default.AppProperties.Description.Author;
  380. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  381. PDFViewer.SetToolParam(annotHandler);
  382. //是否展开右侧面板 =>否(链接、图章、签名除外)
  383. ShowPropertyPanel(false);
  384. if (str == AddAnnotType.AnnotLink.ToString()
  385. || str == AddAnnotType.AnnotStamp.ToString()
  386. || str == AddAnnotType.AnnotAutograph.ToString()
  387. )
  388. {
  389. ShowPropertyPanel(true);
  390. }
  391. IsNoSelectMenu = true;
  392. }
  393. }
  394. }
  395. /// <summary>
  396. /// 选择文本、图片,右键菜单
  397. /// </summary>
  398. /// <param name="sender"></param>
  399. /// <param name="e"></param>
  400. private void AnnotToolMenu_Click(object sender, RoutedEventArgs e)
  401. {
  402. if (sender is MenuItem clickMenu && clickMenu.CommandParameter is AnnotCommandArgs)
  403. {
  404. AnnotCommandArgs annotCommand = clickMenu.CommandParameter as AnnotCommandArgs;
  405. switch (clickMenu.Tag.ToString())
  406. {
  407. case "HighLight"://字体高亮
  408. TextHighlightAnnotArgs highlightArgs = (TextHighlightAnnotArgs)GetHighLight();
  409. highlightArgs.ClientRect = annotCommand.TextRect;
  410. highlightArgs.Content = annotCommand.Text;
  411. highlightArgs.Author = Settings.Default.AppProperties.Description.Author;
  412. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  413. PDFViewer.SetToolParam(highlightArgs);
  414. PDFViewer.SetMouseMode(MouseModes.PanTool);
  415. break;
  416. case "UnderLine"://下划线
  417. TextUnderlineAnnotArgs underlineArgs = (TextUnderlineAnnotArgs)GetUnderLine();
  418. underlineArgs.ClientRect = annotCommand.TextRect;
  419. underlineArgs.Content = annotCommand.Text;
  420. underlineArgs.Author = Settings.Default.AppProperties.Description.Author;
  421. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  422. PDFViewer.SetToolParam(underlineArgs);
  423. PDFViewer.SetMouseMode(MouseModes.PanTool);
  424. break;
  425. case "Strikeout"://删除线
  426. TextStrikeoutAnnotArgs strikeoutArgs = (TextStrikeoutAnnotArgs)GetStrikeout();
  427. strikeoutArgs.ClientRect = annotCommand.TextRect;
  428. strikeoutArgs.Content = annotCommand.Text;
  429. strikeoutArgs.Author = Settings.Default.AppProperties.Description.Author;
  430. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  431. PDFViewer.SetToolParam(strikeoutArgs);
  432. PDFViewer.SetMouseMode(MouseModes.PanTool);
  433. break;
  434. case "Freetext"://文本
  435. FreeTextAnnotArgs textArgs = (FreeTextAnnotArgs)GetFreetext();
  436. textArgs.ClientRect = annotCommand.TextRect;
  437. //textArgs.Transparency = 1;
  438. //textArgs.BgColor = Colors.Transparent;
  439. //textArgs.LineColor = Colors.Red;
  440. //textArgs.LineWidth = 2;
  441. textArgs.TextContent = annotCommand.Text;
  442. PDFViewer.CreatePageAnnot(annotCommand.PageIndex, textArgs);
  443. break;
  444. case "StickyNote"://便签
  445. StickyAnnotArgs stickyAnnotArgs = (StickyAnnotArgs)GetStickyNote();
  446. //stickyAnnotArgs.ClientRect = annotCommand.TextRect;
  447. List<TextSelectNode> textSelectNodes = PDFViewer.GetSelectTextInfo();
  448. //stickyAnnotArgs.ClientRect = new Rect(textSelectNodes[0].StartPoint.X, annotCommand.TextRect.Y - annotCommand.TextRect.Height, annotCommand.TextRect.Width, annotCommand.TextRect.Height);
  449. Rect rect = annotCommand.TextRectList[0];
  450. #region to do 转dpi
  451. //int dpi = DpiHelpers.Dpi;
  452. //double x = rect.X / 72D * dpi;
  453. //double y = (rect.Y - rect.Height) / 72D * dpi;
  454. //double width = rect.Width / 72D * dpi;
  455. //double height = rect.Height / 72D * dpi;
  456. #endregion to do 转dpi
  457. //stickyAnnotArgs.ClientRect = new Rect(x, y, width, height);
  458. //stickyAnnotArgs.ClientRect = new Rect(rect.X, rect.Y - rect.Height, rect.Width, rect.Height);
  459. stickyAnnotArgs.ClientRect = rect;
  460. //PDFViewer.CreatePageAnnot(annotCommand.PageIndex, stickyAnnotArgs);
  461. NavigationParameters param = new NavigationParameters();
  462. param.Add(ParameterNames.PDFViewer, PDFViewer);
  463. param.Add(ParameterNames.StickyAnnotArgs, stickyAnnotArgs);
  464. param.Add(ParameterNames.ViewContentViewModel, viewContentViewModel);
  465. param.Add(ParameterNames.AnnotCommandArgs, annotCommand);
  466. System.Windows.Controls.ContentControl window = null;
  467. if (PDFViewer.Parent as ContentControl != null)
  468. {
  469. window = PDFViewer.Parent as ContentControl;
  470. }
  471. else
  472. {
  473. window = App.Current.MainWindow;
  474. }
  475. var point = Mouse.GetPosition(window);
  476. viewContentViewModel.NotePopupVisible = Visibility.Visible;
  477. viewContentViewModel.CanvasNoteLeft = point.X;
  478. viewContentViewModel.CanvasNoteBottom = point.Y;
  479. if (point.Y > window.ActualHeight / 2)
  480. {
  481. viewContentViewModel.CanvasNoteBottom = point.Y - window.ActualHeight / 2;
  482. }
  483. viewContentViewModel.IsNoteAdd = true;
  484. region.RequestNavigate(viewContentViewModel.NotePopupRegionName, "StickyNotePopup", param);
  485. //stickyAnnotArgs.Author = Settings.Default.AppProperties.Description.Author;
  486. //PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  487. //PDFViewer.SetToolParam(stickyAnnotArgs);
  488. //PDFViewer.SetMouseMode(MouseModes.PanTool);
  489. break;
  490. case "Rect"://矩形
  491. SquareAnnotArgs squareAnnotArgs = (SquareAnnotArgs)GetRect();
  492. squareAnnotArgs.ClientRect = annotCommand.TextRect;
  493. PDFViewer.CreatePageAnnot(annotCommand.PageIndex, squareAnnotArgs);
  494. break;
  495. case "Circle"://圆
  496. CircleAnnotArgs circleAnnotArgs = (CircleAnnotArgs)GetCircle();
  497. circleAnnotArgs.ClientRect = annotCommand.TextRect;
  498. PDFViewer.CreatePageAnnot(annotCommand.PageIndex, circleAnnotArgs);
  499. break;
  500. case "Line"://线
  501. LineAnnotArgs lineAnnotArgs = (LineAnnotArgs)GetArrowLine(clickMenu.Tag.ToString());
  502. lineAnnotArgs.ClientRect = annotCommand.TextRect;
  503. lineAnnotArgs.LinePoints.Add(new Point(annotCommand.TextRect.Left, annotCommand.TextRect.Top));
  504. lineAnnotArgs.LinePoints.Add(new Point(annotCommand.TextRect.Right, annotCommand.TextRect.Bottom));
  505. PDFViewer.CreatePageAnnot(annotCommand.PageIndex, lineAnnotArgs);
  506. break;
  507. case "Link"://链接
  508. LinkAnnotArgs linkArgs = new LinkAnnotArgs();
  509. linkArgs.ClientRect = annotCommand.TextRect;
  510. linkArgs.URI = string.Empty;
  511. linkArgs.LinkType = LINK_TYPE.GOTO;
  512. linkArgs.DestIndex = annotCommand.PageIndex;
  513. PDFViewer.CreatePageAnnot(annotCommand.PageIndex, linkArgs);
  514. //BtnLinkIsChecked = true;
  515. StrAnnotToolChecked = "Link";
  516. List<AnnotHandlerEventArgs> lists = new List<AnnotHandlerEventArgs>();
  517. lists.Add(linkArgs);
  518. propertyPanel.IsAddLink = true;
  519. AnnotHandlerEventArgs annotArgs = GetLink(lists);
  520. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  521. PDFViewer.SetToolParam(annotArgs);
  522. viewContentViewModel.IsPropertyOpen = true;
  523. break;
  524. case "OutLine":
  525. bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemOutLine");
  526. if (isTabItemAnnotation == false)
  527. {
  528. bOTAContent.TabItemOutLine.IsSelected = true;
  529. }
  530. OutLineControlViewModel outLineControlViewModel = GetOutLineControlViewModel(bOTAContentViewModel, out OutLineControl outLineControl);
  531. if (outLineControlViewModel != null && outLineControl != null)
  532. {
  533. string str = null;
  534. if (string.IsNullOrEmpty(annotCommand.Text))
  535. {
  536. str = (annotCommand.PageIndex + 1).ToString();
  537. }
  538. else
  539. {
  540. str = annotCommand.Text;
  541. }
  542. outLineControl.AddOutlineNode(str);
  543. }
  544. break;
  545. case "ExportPicture":
  546. ExportPicture_MenuItemClick();
  547. break;
  548. }
  549. //ShowPropertyPanel(false);
  550. }
  551. }
  552. private void PageDisplay(ItemCollection items)
  553. {
  554. foreach (var item in items)
  555. {
  556. if (item is MenuItem menuItem)
  557. {
  558. menuItem.IsCheckable = false;
  559. menuItem.Click -= PageDisplay_Click;
  560. menuItem.Click += PageDisplay_Click;
  561. }
  562. }
  563. }
  564. private void PageDisplay_Click(object sender, RoutedEventArgs e)
  565. {
  566. if (sender is MenuItem menuItem)
  567. {
  568. switch (menuItem.Tag.ToString())
  569. {
  570. case "SingleView":
  571. PDFViewer.ChangeViewMode(ViewMode.Single);
  572. break;
  573. case "SingleContinueView":
  574. PDFViewer.ChangeViewMode(ViewMode.SingleContinuous);
  575. break;
  576. case "DoubleView":
  577. PDFViewer.ChangeViewMode(ViewMode.Double);
  578. break;
  579. case "DoubleContinueView":
  580. PDFViewer.ChangeViewMode(ViewMode.DoubleContinuous);
  581. break;
  582. case "BookMode":
  583. PDFViewer.ChangeViewMode(ViewMode.Book);
  584. break;
  585. }
  586. }
  587. }
  588. private void ViewZoom(ItemCollection items)
  589. {
  590. foreach (var item in items)
  591. {
  592. if (item is MenuItem menuItem)
  593. {
  594. //switch (PDFViewer.ModeFit)
  595. //{
  596. // case FitMode.FitWidth:
  597. // break;
  598. // case FitMode.FitHeight:
  599. // break;
  600. // case FitMode.FitSize:
  601. // break;
  602. // case FitMode.FitFree:
  603. // break;
  604. // default:
  605. // break;
  606. //}
  607. menuItem.IsCheckable = false;
  608. menuItem.Click -= ViewZoom_Click;
  609. menuItem.Click += ViewZoom_Click;
  610. }
  611. }
  612. }
  613. private void ViewZoom_Click(object sender, RoutedEventArgs e)
  614. {
  615. if (sender is MenuItem menuItem)
  616. {
  617. switch (menuItem.Tag.ToString())
  618. {
  619. case "FitWidth":
  620. PDFViewer.ChangeFitMode(FitMode.FitWidth);
  621. break;
  622. case "FitHeight":
  623. PDFViewer.ChangeFitMode(FitMode.FitHeight);
  624. break;
  625. case "FitSize":
  626. PDFViewer.ChangeFitMode(FitMode.FitSize);
  627. break;
  628. case "enlarge":
  629. double newZoom = viewContentViewModel.CheckZoomLevel((PDFViewer.ZoomFactor + 0.01), true);
  630. PDFViewer.Zoom(newZoom);
  631. break;
  632. case "narrow":
  633. newZoom = viewContentViewModel.CheckZoomLevel((PDFViewer.ZoomFactor + -0.01), false);
  634. PDFViewer.Zoom(newZoom);
  635. break;
  636. }
  637. }
  638. }
  639. private void UnReadModel_Click(object sender, RoutedEventArgs e)
  640. {
  641. viewContentViewModel.Off_ReadModel();
  642. }
  643. private void ReadModel_Click(object sender, RoutedEventArgs e)
  644. {
  645. viewContentViewModel.On_ReadMode();
  646. }
  647. private void SetToolMode(ItemCollection items)
  648. {
  649. foreach (var item in items)
  650. {
  651. if (item is MenuItem menuItem)
  652. {
  653. menuItem.IsCheckable = false;
  654. menuItem.Click -= ToolMode_Click;
  655. menuItem.Click += ToolMode_Click;
  656. }
  657. }
  658. }
  659. private void ToolMode_Click(object sender, RoutedEventArgs e)
  660. {
  661. if (sender is MenuItem menuItem)
  662. {
  663. switch (menuItem.Tag.ToString())
  664. {
  665. case "default":
  666. HandToolIsCheckedEvent(false);
  667. BtnHandIsChecked = false;
  668. ShowPropertyPanel(false);
  669. break;
  670. case "roll":
  671. HandToolIsCheckedEvent(true);
  672. BtnHandIsChecked = true;
  673. ShowPropertyPanel(false);
  674. break;
  675. case "content":
  676. AnnotHandlerEventArgs annotHandler = GetSnapshotEdit();
  677. BtnSelecttoolIsChecked = true;
  678. if (annotHandler != null)
  679. {
  680. annotHandler.Author = Settings.Default.AppProperties.Description.Author;
  681. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  682. PDFViewer.SetToolParam(annotHandler);
  683. ShowPropertyPanel(false);
  684. }
  685. break;
  686. default:
  687. break;
  688. }
  689. }
  690. }
  691. private void DelBookMark_Click(object sender, RoutedEventArgs e)
  692. {
  693. CheckBOTAState(out BOTAContentViewModel bOTAContentVM, out BOTAContent bOTA);
  694. if (bOTAContentVM != null && bOTA != null)
  695. {
  696. BookmarkContentViewModel bookmarkContentViewModel = GetBookmarkContentViewModel(bOTAContentVM, out BookmarkContent bookmark);
  697. int index = PDFViewer.CurrentIndex;
  698. //检测是否已存在相同数据
  699. CPDFBookmark list = PDFViewer.Document.GetBookmarkList().FirstOrDefault(q => q.PageIndex == index);
  700. if (bookmarkContentViewModel != null && bookmark != null && bOTA != null && list != null)
  701. {
  702. bookmarkContentViewModel.DeleteCommand.Execute(list);
  703. isAddBookMark = bookmarkContentViewModel.isAddBookMark;
  704. }
  705. }
  706. }
  707. private void CheckBOTAState(out BOTAContentViewModel bOTAContentVM, out BOTAContent bOTA)
  708. {
  709. if (viewContentViewModel.OpenBOTA == false)
  710. {
  711. viewContentViewModel.OpenBOTA = true;
  712. }
  713. bool isBook = IsBOTATabItemShow(out bOTAContentVM, out bOTA, "TabItemBookMark");
  714. if (isBook == false)
  715. {
  716. bOTA.TabItemBookMark.IsSelected = true;
  717. }
  718. }
  719. private void AddBookMark_Click()
  720. {
  721. CheckBOTAState(out BOTAContentViewModel bOTAContentVM, out BOTAContent bOTA);
  722. //if (viewContentViewModel.mainViewModel.IsBookMode)
  723. //{
  724. // this.events.GetEvent<ReadModeBOTAShowEvent>().Publish(new ReadModeBOTAShowArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, IsBOTAShow = true });
  725. //}
  726. if (bOTAContentVM != null && bOTA != null)
  727. {
  728. BookmarkContentViewModel bookmarkContentViewModel = GetBookmarkContentViewModel(bOTAContentVM, out BookmarkContent bookmark);
  729. if (bookmarkContentViewModel != null && bookmark != null && bOTA != null)
  730. {
  731. //bookmarkContentViewModel.AddBookmarkCommand.Execute(bookmark.BookMarkListView);
  732. bookmark.BtnAddBookmark_Click(null, null);
  733. isAddBookMark = bookmarkContentViewModel.isAddBookMark;
  734. return;
  735. }
  736. }
  737. }
  738. private BookmarkContentViewModel GetBookmarkContentViewModel(BOTAContentViewModel bOTAContentViewModel, out BookmarkContent bookmark)
  739. {
  740. BookmarkContentViewModel viewModel = null;
  741. bookmark = null;
  742. if (bOTAContentViewModel != null)
  743. {
  744. if (region.Regions.ContainsRegionWithName(bOTAContentViewModel.BOTAContentRegionName))
  745. {
  746. var views = region.Regions[bOTAContentViewModel.BOTAContentRegionName].Views;
  747. foreach (var item in views)
  748. {
  749. if (item is BookmarkContent bookmark1)
  750. {
  751. bookmark = bookmark1;
  752. viewModel = bookmark1.DataContext as BookmarkContentViewModel;
  753. break;
  754. }
  755. }
  756. }
  757. }
  758. return viewModel;
  759. }
  760. private OutLineControlViewModel GetOutLineControlViewModel(BOTAContentViewModel bOTAContentViewModel, out OutLineControl outLineControl)
  761. {
  762. OutLineControlViewModel viewModel = null;
  763. outLineControl = null;
  764. if (bOTAContentViewModel != null)
  765. {
  766. if (region.Regions.ContainsRegionWithName(bOTAContentViewModel.BOTAContentRegionName))
  767. {
  768. var views = region.Regions[bOTAContentViewModel.BOTAContentRegionName].Views;
  769. foreach (var item in views)
  770. {
  771. if (item is OutLineControl outLineControl1)
  772. {
  773. outLineControl = outLineControl1;
  774. viewModel = outLineControl1.DataContext as OutLineControlViewModel;
  775. break;
  776. }
  777. }
  778. }
  779. }
  780. return viewModel;
  781. }
  782. private void DisplayAnnot_Click(object sender, RoutedEventArgs e)
  783. {
  784. PDFViewer.SetDrawAnnot(true);
  785. BtnShowAnnotIsChecked = true;
  786. bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  787. if (viewContentViewModel.OpenBOTA == true && isTabItemAnnotation == true)
  788. {
  789. AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
  790. viewModel.DisplayAnnot();
  791. }
  792. }
  793. private void HiddenAnnot_Click(object sender, RoutedEventArgs e)
  794. {
  795. PDFViewer.SetDrawAnnot(false);
  796. BtnShowAnnotIsChecked = false;
  797. bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  798. if (viewContentViewModel.OpenBOTA == true && isTabItemAnnotation == true)
  799. {
  800. AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
  801. viewModel.HiddenAnnot();
  802. }
  803. }
  804. private void SetAddAnnotation(ItemCollection items)
  805. {
  806. foreach (var item in items)
  807. {
  808. if (item is MenuItem menuItem)
  809. {
  810. string str = menuItem.Tag.ToString();
  811. //if (str == AddAnnotType.AnnotLink.ToString()
  812. //|| str == AddAnnotType.AnnotStamp.ToString()
  813. //|| str == AddAnnotType.AnnotAutograph.ToString()
  814. //)
  815. //{
  816. // InBookModeSetIsEnabled(menuItem);
  817. //}
  818. menuItem.CommandParameter = item;
  819. menuItem.Command = SetAddAnnotationCommand;
  820. }
  821. }
  822. }
  823. //private void AddLink_Click(object sender, RoutedEventArgs e)
  824. //{
  825. // var args = PDFViewer.ToolManager.CurrentAnnotArgs;
  826. // BtnLinkIsChecked = true;
  827. //}
  828. #endregion 阅读页右键菜单
  829. #region 注释右键菜单事件
  830. //高亮、下划线、删除
  831. private void HightAnnotCopyText_Menu(object obj)
  832. {
  833. if (obj as CusMenuItem != null)
  834. {
  835. var menu = obj as CusMenuItem;
  836. var annot = menu.Parameter as AnnotHandlerEventArgs;
  837. if (annot != null)
  838. {
  839. System.Windows.Clipboard.SetText(annot.Content);
  840. }
  841. }
  842. }
  843. //更改为当前注释属性默认值
  844. private void AnnotDefaultValues_Menu(object obj)
  845. {
  846. if (obj as CusMenuItem != null)
  847. {
  848. var menu = obj as CusMenuItem;
  849. var annot = menu.Parameter as AnnotHandlerEventArgs;
  850. if (annot != null)
  851. {
  852. if (annot is TextHighlightAnnotArgs)
  853. {
  854. var color = (annot as TextHighlightAnnotArgs).Color;
  855. HighLightColor = new SolidColorBrush(color);
  856. Settings.Default.AppProperties.Annotate.HighLightColor = color;
  857. var hightlight = GetAnnotDefault(AnnotArgsType.AnnotHighlight);
  858. hightlight.ForgoundColor = color;
  859. hightlight.Opacity = (annot as TextHighlightAnnotArgs).Transparency;
  860. SettingHelper.SetAnnotDefaultProperty(hightlight);
  861. }
  862. else if (annot is TextUnderlineAnnotArgs)
  863. {
  864. var color = (annot as TextUnderlineAnnotArgs).Color;
  865. UnderLineColor = new SolidColorBrush(color);
  866. Settings.Default.AppProperties.Annotate.UnderLineColor = color;
  867. var Underline = GetAnnotDefault(AnnotArgsType.AnnotUnderline);
  868. Underline.ForgoundColor = color;
  869. Underline.Opacity = (annot as TextUnderlineAnnotArgs).Transparency;
  870. SettingHelper.SetAnnotDefaultProperty(Underline);
  871. }
  872. else if (annot is TextStrikeoutAnnotArgs)
  873. {
  874. var color = (annot as TextStrikeoutAnnotArgs).Color;
  875. StrikeoutColor = new SolidColorBrush(color);
  876. Settings.Default.AppProperties.Annotate.StrikethroughColor = color;
  877. var Strikeout = GetAnnotDefault(AnnotArgsType.AnnotStrikeout);
  878. Strikeout.ForgoundColor = color;
  879. Strikeout.Opacity = (annot as TextStrikeoutAnnotArgs).Transparency;
  880. SettingHelper.SetAnnotDefaultProperty(Strikeout);
  881. }
  882. else if (annot is FreehandAnnotArgs)
  883. {
  884. var freeHand = annot as FreehandAnnotArgs;
  885. var color = freeHand.InkColor;
  886. Settings.Default.AppProperties.Annotate.FreeHandColor = color;
  887. var FreehandDefault = GetAnnotDefault(AnnotArgsType.AnnotFreehand);
  888. FreehandDefault.ForgoundColor = color;
  889. FreehandDefault.Opacity = freeHand.Transparency;
  890. FreehandDefault.Thickness = freeHand.LineWidth;
  891. var isSolid = AnnotTransfer.IsSolidStyle(freeHand.LineDash);
  892. if (isSolid)
  893. {
  894. FreehandDefault.DashArray = null;
  895. }
  896. else
  897. {
  898. FreehandDefault.DashArray = new List<double>();
  899. foreach (var item in freeHand.LineDash.Dashes)
  900. {
  901. FreehandDefault.DashArray.Add(item);
  902. }
  903. }
  904. SettingHelper.SetAnnotDefaultProperty(FreehandDefault);
  905. }
  906. else if (annot is FreeTextAnnotArgs)
  907. {
  908. var freeText = annot as FreeTextAnnotArgs;
  909. Settings.Default.AppProperties.Annotate.TextAnnoteColor = freeText.FontColor;
  910. Settings.Default.AppProperties.Annotate.TextFontFamaily = freeText.FontFamily.ToString();
  911. Settings.Default.AppProperties.Annotate.TextAlign = freeText.Align;
  912. var FreeTextDefalut = GetAnnotDefault(AnnotArgsType.AnnotFreeText);
  913. FreeTextDefalut.ForgoundColor = freeText.FontColor;
  914. FreeTextDefalut.FontFamily = freeText.FontFamily.ToString();
  915. FreeTextDefalut.TextAlign = freeText.Align;
  916. FreeTextDefalut.FontSize = freeText.FontSize;
  917. FreeTextDefalut.FontWeight = freeText.FontWeight;
  918. FreeTextDefalut.FontStyle = freeText.FontStyle;
  919. FreeTextDefalut.BackgroundColor = freeText.BgColor;
  920. FreeTextDefalut.Opacity = (annot as FreeTextAnnotArgs).Transparency;
  921. SettingHelper.SetAnnotDefaultProperty(FreeTextDefalut);
  922. }
  923. else if (annot is StickyAnnotArgs)
  924. {
  925. var color = (annot as StickyAnnotArgs).Color;
  926. Settings.Default.AppProperties.Annotate.NoteAnnoteColor = color;
  927. var StickyDefalut = GetAnnotDefault(AnnotArgsType.AnnotSticky);
  928. StickyDefalut.ForgoundColor = color;
  929. SettingHelper.SetAnnotDefaultProperty(StickyDefalut);
  930. }
  931. else if (annot is SquareAnnotArgs)
  932. {
  933. var square = annot as SquareAnnotArgs;
  934. var bgColor = square.BgColor;
  935. Settings.Default.AppProperties.Annotate.RectangleFillColor = bgColor;
  936. var borderColor = square.LineColor;
  937. Settings.Default.AppProperties.Annotate.RectangleBorderColor = borderColor;
  938. var SquareDefalut = GetAnnotDefault(AnnotArgsType.AnnotSquare);
  939. SquareDefalut.BorderColor = borderColor;
  940. SquareDefalut.BackgroundColor = bgColor;
  941. SquareDefalut.Opacity = square.Transparency;
  942. SquareDefalut.Thickness = square.LineWidth;
  943. var isSolid = AnnotTransfer.IsSolidStyle(square.LineDash);
  944. if (isSolid)
  945. {
  946. SquareDefalut.DashArray = null;
  947. }
  948. else
  949. {
  950. SquareDefalut.DashArray = new List<double>();
  951. foreach (var item in square.LineDash.Dashes)
  952. {
  953. SquareDefalut.DashArray.Add(item);
  954. }
  955. }
  956. SettingHelper.SetAnnotDefaultProperty(SquareDefalut);
  957. }
  958. else if (annot is CircleAnnotArgs)
  959. {
  960. var circle = annot as CircleAnnotArgs;
  961. var bgColor = circle.BgColor;
  962. Settings.Default.AppProperties.Annotate.CircleFillColor = bgColor;
  963. var borderColor = circle.LineColor;
  964. Settings.Default.AppProperties.Annotate.CircleBorderColor = borderColor;
  965. var CircleDefalut = GetAnnotDefault(AnnotArgsType.AnnotCircle);
  966. CircleDefalut.BorderColor = borderColor;
  967. CircleDefalut.BackgroundColor = bgColor;
  968. CircleDefalut.Opacity = circle.Transparency;
  969. CircleDefalut.Thickness = circle.LineWidth;
  970. var isSolid = AnnotTransfer.IsSolidStyle(circle.LineDash);
  971. if (isSolid)
  972. {
  973. CircleDefalut.DashArray = null;
  974. }
  975. else
  976. {
  977. CircleDefalut.DashArray = new List<double>();
  978. foreach (var item in circle.LineDash.Dashes)
  979. {
  980. CircleDefalut.DashArray.Add(item);
  981. }
  982. }
  983. SettingHelper.SetAnnotDefaultProperty(CircleDefalut);
  984. }
  985. else if (annot is LineAnnotArgs)
  986. {
  987. var line = (annot as LineAnnotArgs);
  988. var color = (annot as LineAnnotArgs).LineColor;
  989. Settings.Default.AppProperties.Annotate.LineColor = color;
  990. var lineDefalut = GetAnnotDefault(AnnotArgsType.AnnotLine);
  991. lineDefalut.BorderColor = color;
  992. lineDefalut.Opacity = (annot as LineAnnotArgs).Transparency;
  993. lineDefalut.Thickness = (annot as LineAnnotArgs).LineWidth;
  994. var isSolid = AnnotTransfer.IsSolidStyle(line.LineDash);
  995. if (isSolid)
  996. {
  997. lineDefalut.DashArray = null;
  998. }
  999. else
  1000. {
  1001. lineDefalut.DashArray = new List<double>();
  1002. foreach (var item in line.LineDash.Dashes)
  1003. {
  1004. lineDefalut.DashArray.Add(item);
  1005. }
  1006. }
  1007. SettingHelper.SetAnnotDefaultProperty(lineDefalut);
  1008. }
  1009. Settings.Default.Save();
  1010. }
  1011. }
  1012. }
  1013. private DefaultAnnotProperty GetAnnotDefault(AnnotArgsType annotArgsType)
  1014. {
  1015. var Annot = SettingHelper.GetAnnotDefaultProperty(annotArgsType);
  1016. if (Annot == null)
  1017. {
  1018. Annot = new DefaultAnnotProperty();
  1019. Annot.AnnotToolType = annotArgsType;
  1020. }
  1021. return Annot;
  1022. }
  1023. private System.Windows.Controls.Primitives.Popup popup = null;
  1024. //更改颜色
  1025. private async void AnnotColorPalette_Menu(object obj)
  1026. {
  1027. if (obj as CusMenuItem != null)
  1028. {
  1029. var menu = obj as CusMenuItem;
  1030. var annot = menu.Parameter as AnnotHandlerEventArgs;
  1031. if (annot != null)
  1032. {
  1033. var item = new ColorDropBoxPop();
  1034. item.DataContext = menu;
  1035. item.ColorSelected -= AnnotMenu_ColorSelected;
  1036. item.ColorSelected += AnnotMenu_ColorSelected;
  1037. if (popup == null)
  1038. popup = new System.Windows.Controls.Primitives.Popup();
  1039. ContentControl window = null;
  1040. if (PDFViewer.Parent as ContentControl != null)
  1041. window = PDFViewer.Parent as ContentControl;
  1042. else
  1043. window = App.Current.MainWindow;
  1044. popup.Child = item;
  1045. popup.PlacementRectangle = new Rect(Mouse.GetPosition(window), new Size(item.Width, item.Height));
  1046. popup.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
  1047. popup.PlacementTarget = window;
  1048. popup.IsOpen = true;
  1049. Window parentWnd = Window.GetWindow(App.Current.MainWindow);
  1050. if (parentWnd != null)
  1051. {
  1052. parentWnd.MouseDown -= parentWnd_MouseDown;
  1053. parentWnd.MouseDown += parentWnd_MouseDown;
  1054. }
  1055. while (popup.IsOpen)
  1056. await Task.Delay(20);
  1057. parentWnd.MouseDown -= parentWnd_MouseDown;
  1058. popup = null;
  1059. }
  1060. }
  1061. }
  1062. private void parentWnd_MouseDown(object sender, MouseButtonEventArgs e)
  1063. {
  1064. var ui = Mouse.DirectlyOver as FrameworkElement;
  1065. if (ui != null)
  1066. {
  1067. if (popup != null)
  1068. {
  1069. popup.IsOpen = false;
  1070. }
  1071. }
  1072. }
  1073. private void AnnotMenu_ColorSelected(object sender, Color e)
  1074. {
  1075. if (sender != null)
  1076. {
  1077. var menu = (sender as FrameworkElement).DataContext as CusMenuItem;
  1078. if (menu == null) return;
  1079. var annot = menu.Parameter as AnnotHandlerEventArgs;
  1080. if (annot != null)
  1081. {
  1082. if (annot is FreehandAnnotArgs || annot is StickyAnnotArgs || annot is LineAnnotArgs)
  1083. {
  1084. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  1085. AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
  1086. AnnotEvent?.UpdateAnnot();
  1087. }
  1088. else if (annot is FreeTextAnnotArgs)
  1089. {
  1090. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  1091. if (menu.tag.ToString() == "FontColor")
  1092. AnnotEvent?.UpdateAttrib(AnnotAttrib.FontColor, e);
  1093. else
  1094. AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, e);
  1095. AnnotEvent?.UpdateAnnot();
  1096. }
  1097. else if (annot is SquareAnnotArgs || annot is CircleAnnotArgs)
  1098. {
  1099. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  1100. if (menu.tag.ToString() == "FillColor")
  1101. AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, e);
  1102. else
  1103. AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
  1104. AnnotEvent?.UpdateAnnot();
  1105. }
  1106. else if (annot is TextHighlightAnnotArgs || annot is TextUnderlineAnnotArgs || annot is TextStrikeoutAnnotArgs)
  1107. {
  1108. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  1109. AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
  1110. AnnotEvent?.UpdateAnnot();
  1111. }
  1112. }
  1113. }
  1114. }
  1115. //添加笔记
  1116. private void AnnotAddNoteText_Menu(object obj)
  1117. {
  1118. if (obj as CusMenuItem != null)
  1119. {
  1120. var menu = obj as CusMenuItem;
  1121. var annot = menu.Parameter as AnnotHandlerEventArgs;
  1122. PopAnnotNoteText(annot);
  1123. }
  1124. }
  1125. private void PopAnnotNoteText(AnnotHandlerEventArgs annot)
  1126. {
  1127. if (annot != null)
  1128. {
  1129. AnnotationHandlerEventArgs args = new AnnotationHandlerEventArgs();
  1130. args.ClientRect = annot.ClientRect;
  1131. args.AnnotHandlerEventArgs = annot;
  1132. args.PageIndex = annot.PageIndex;
  1133. args.AnnotIndex = annot.AnnotIndex;
  1134. args.EventType = annot.EventType;
  1135. args.CreateTime = annot.CreateTime;
  1136. args.UpdateTime = annot.UpdateTime;
  1137. args.Content = annot.Content;
  1138. args.MarkupContent = annot.MarkupContent;
  1139. args.Author = annot.Author;
  1140. args.Locked = annot.Locked;
  1141. args.ReadOnly = annot.ReadOnly;
  1142. args.FormField = annot.FormField;
  1143. args.Document = PDFViewer.Document;
  1144. DialogParameters value = new DialogParameters();
  1145. value.Add(ParameterNames.Annotation, args);
  1146. dialogs.ShowDialog(DialogNames.AddAnnotationDialog, value, e =>
  1147. {
  1148. if (e.Result == ButtonResult.OK && e.Parameters != null)
  1149. {
  1150. PDFViewer.UndoManager.CanSave = true;
  1151. if (e.Parameters.ContainsKey(ParameterNames.Annotation) && e.Parameters.ContainsKey(ParameterNames.AnnotEvent))
  1152. {
  1153. AnnotationHandlerEventArgs annotation = e.Parameters.GetValue<AnnotationHandlerEventArgs>(ParameterNames.Annotation);
  1154. //RefreshOneListItem(annotation.AnnotHandlerEventArgs);
  1155. events.GetEvent<RefreshAnnotEvent>().Publish(new RefreshAnnotArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, Annotation = annotation });
  1156. }
  1157. }
  1158. });
  1159. }
  1160. }
  1161. //手绘
  1162. private void FreeHandLineStyle_Menu(object obj)
  1163. {
  1164. if (obj as CusMenuItem != null)
  1165. {
  1166. var menu = obj as CusMenuItem;
  1167. var annot = menu.Parameter as FreehandAnnotArgs;
  1168. if (annot != null)
  1169. {
  1170. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  1171. if (menu.tag.ToString() == "Solid")
  1172. {
  1173. AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, AnnotTransfer.GetLineDashStyle(true));
  1174. }
  1175. else
  1176. {
  1177. AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, AnnotTransfer.GetLineDashStyle(false));
  1178. }
  1179. AnnotEvent?.UpdateAnnot();
  1180. }
  1181. }
  1182. }
  1183. //文本
  1184. private void FreeTextFontFamily_Menu(object obj)
  1185. {
  1186. if (obj as CusMenuItem != null)
  1187. {
  1188. var menu = obj as CusMenuItem;
  1189. var annot = menu.Parameter as AnnotHandlerEventArgs;
  1190. if (annot != null)
  1191. {
  1192. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  1193. AnnotEvent?.UpdateAttrib(AnnotAttrib.FontFamily, new FontFamily(menu.tag.ToString()));
  1194. AnnotEvent?.UpdateAnnot();
  1195. }
  1196. }
  1197. }
  1198. private void FreeTextAglin_Menu(object obj)
  1199. {
  1200. if (obj as CusMenuItem != null)
  1201. {
  1202. var menu = obj as CusMenuItem;
  1203. var annot = menu.Parameter as AnnotHandlerEventArgs;
  1204. var tag = menu.control.Tag;
  1205. if (annot != null && tag != null)
  1206. {
  1207. var strTag = tag.ToString();
  1208. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  1209. if (strTag == "Left")
  1210. {
  1211. AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Left);
  1212. }
  1213. else if (strTag == "Center")
  1214. {
  1215. AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Center);
  1216. }
  1217. else if (strTag == "Right")
  1218. {
  1219. AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Right);
  1220. }
  1221. else if (strTag == "Justify")
  1222. {
  1223. AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Justify);
  1224. }
  1225. AnnotEvent?.UpdateAnnot();
  1226. }
  1227. }
  1228. }
  1229. //便签
  1230. private void StrikeNoteEditStrike_Menu(object obj)
  1231. {
  1232. if (obj as CusMenuItem != null)
  1233. {
  1234. var menu = obj as CusMenuItem;
  1235. var annot = menu.Parameter as AnnotHandlerEventArgs;
  1236. if (annot != null)
  1237. {
  1238. var sticky = annot as StickyAnnotArgs;
  1239. sticky.PopupEditWnd();
  1240. #region 设计重新调整,阅读页空白处,右键菜单,添加链接需要显示,其他和pro mac一样的效果,不显示属性栏
  1241. //isRightMenuAddAnnot = false;
  1242. #endregion 设计重新调整,阅读页空白处,右键菜单,添加链接需要显示,其他和pro mac一样的效果,不显示属性栏
  1243. }
  1244. }
  1245. }
  1246. //形状
  1247. private void ShapeLineStyle_Menu(object obj)
  1248. {
  1249. if (obj as CusMenuItem != null)
  1250. {
  1251. var menu = obj as CusMenuItem;
  1252. var annot = menu.Parameter as AnnotHandlerEventArgs;
  1253. var tag = menu.control.Tag;
  1254. if (annot != null && tag != null)
  1255. {
  1256. var strTag = tag.ToString();
  1257. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  1258. if (strTag == "Solid")
  1259. {
  1260. var dashStyle = AnnotTransfer.GetLineDashStyle(true);
  1261. AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, dashStyle);
  1262. }
  1263. else
  1264. {
  1265. var dashStyle = AnnotTransfer.GetLineDashStyle(false);
  1266. AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, dashStyle);
  1267. }
  1268. AnnotEvent?.UpdateAnnot();
  1269. }
  1270. }
  1271. }
  1272. private void ShapeLineDirect_Menu(object obj)
  1273. {
  1274. if (obj as CusMenuItem != null)
  1275. {
  1276. var menu = obj as CusMenuItem;
  1277. var annot = menu.Parameter as LineAnnotArgs;
  1278. var tag = menu.control.Tag;
  1279. if (annot != null && tag != null)
  1280. {
  1281. var strTag = tag.ToString();
  1282. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  1283. if (strTag == "Ver")
  1284. {
  1285. annot.SetLineVertical();
  1286. }
  1287. else
  1288. {
  1289. annot.SetLineHorizontal();
  1290. }
  1291. }
  1292. }
  1293. }
  1294. private void Link_Menu(object obj)
  1295. {
  1296. if (obj is CusMenuItem menuItem)
  1297. {
  1298. if (menuItem.Parameter is LinkAnnotArgs linkAnnotArgs)
  1299. {
  1300. var result = PDFViewer.RemovePageAnnot(linkAnnotArgs.PageIndex, linkAnnotArgs.AnnotIndex);
  1301. if (result)
  1302. {
  1303. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  1304. bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  1305. if (isTabItemAnnotation)
  1306. {
  1307. AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
  1308. if (viewModel != null)
  1309. {
  1310. viewModel.UpdateModifiedAnnot(linkAnnotArgs.PageIndex, linkAnnotArgs.AnnotIndex, true);
  1311. }
  1312. }
  1313. }
  1314. }
  1315. }
  1316. }
  1317. //图章
  1318. private void StampExportPicture_Menu(object obj)
  1319. {
  1320. if (obj as CusMenuItem != null)
  1321. {
  1322. var menu = obj as CusMenuItem;
  1323. var annot = menu.Parameter as StampAnnotArgs;
  1324. if (annot != null)
  1325. {
  1326. Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
  1327. var format = menu.tag.ToString();
  1328. if (format == "PDF")
  1329. dlg.Filter = "PDF|*.pdf";
  1330. else
  1331. dlg.Filter = format + "|*." + format.ToLower();
  1332. dlg.DefaultExt = "." + menu.tag.ToString().ToLower();
  1333. dlg.FileName = PDFViewer.Document.FileName;
  1334. if (dlg.ShowDialog() == true)
  1335. {
  1336. var stampPicture = dlg.FileName;
  1337. if (menu.tag.ToString() == "PDF")
  1338. {
  1339. var writeStamp = annot.GetStampDrawing();
  1340. var tempDoc = new CPDFViewer();
  1341. tempDoc.CreateDocument();
  1342. if (tempDoc.Document == null)
  1343. {
  1344. AlertsMessage alertsMessage = new AlertsMessage();
  1345. alertsMessage.ShowDialog("", "创建文件失败.", "OK");
  1346. return;
  1347. }
  1348. byte[] buffer;
  1349. var encoder = new PngBitmapEncoder();
  1350. encoder.Frames.Add(BitmapFrame.Create(writeStamp));
  1351. using (var memoryStream = new MemoryStream())
  1352. {
  1353. encoder.Save(memoryStream);
  1354. buffer = memoryStream.ToArray();
  1355. }
  1356. tempDoc.Document.InsertPage(0, writeStamp.PixelWidth, writeStamp.PixelHeight, buffer, CPDFDocumentImageMode.CPDFDocumentImageModeScaleAspectFit);
  1357. var result = tempDoc.Document.WriteToFilePath(dlg.FileName);
  1358. if (result)
  1359. {
  1360. }
  1361. }
  1362. else
  1363. {
  1364. var writeStamp = annot.GetStampDrawing();
  1365. using (FileStream stream5 = new FileStream(stampPicture, FileMode.Create))
  1366. {
  1367. PngBitmapEncoder encoder5 = new PngBitmapEncoder();
  1368. encoder5.Frames.Add(BitmapFrame.Create(writeStamp));
  1369. encoder5.Save(stream5);
  1370. }
  1371. }
  1372. }
  1373. }
  1374. }
  1375. }
  1376. #endregion 注释右键菜单事件
  1377. #region 快捷键
  1378. private void ShortCut_KeyDown(object sender, KeyEventArgs e)
  1379. {
  1380. if (KeyEventsHelper.IsSingleKey(Key.Escape))
  1381. {
  1382. //BtnHandIsChecked = true;
  1383. PDFViewer.SetMouseMode(MouseModes.PanTool);
  1384. PDFViewer.ClearSelectAnnots();
  1385. StrAnnotToolChecked = "";
  1386. ShowPropertyPanel(false);
  1387. }
  1388. else if (KeyEventsHelper.IsModifierKey(ModifierKeys.Shift, Key.None))
  1389. {
  1390. //按住Shift等比缩放
  1391. }
  1392. AnnotToolCtrlAltKey();
  1393. }
  1394. /// <summary>
  1395. /// 按下Ctrl + Alt + 序列键,响应注释工具
  1396. /// </summary>
  1397. private void AnnotToolCtrlAltKey()
  1398. {
  1399. var tuple = GetCtrlAltKey();
  1400. if (tuple != null)
  1401. {
  1402. if (tuple.Item1 == Key.L)
  1403. BtnLinkIsChecked = false;
  1404. if (tuple.Item2 == "Eraser")
  1405. {
  1406. CreateEraseArgs();
  1407. StrAnnotToolChecked = "Freehand";
  1408. return;
  1409. }
  1410. AnnotHandlerEventArgs annotArgs = null;
  1411. StrAnnotToolChecked = tuple.Item2;
  1412. FindAnnotTypeKey(tuple.Item2, ref annotArgs);
  1413. if (annotArgs != null)
  1414. {
  1415. annotArgs.Author = Settings.Default.AppProperties.Description.Author;
  1416. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  1417. PDFViewer.SetToolParam(annotArgs);
  1418. PDFViewer.ToolManager.EnableClickCreate = false;
  1419. }
  1420. }
  1421. }
  1422. private Tuple<Key, string> GetCtrlAltKey()
  1423. {
  1424. Dictionary<Key, bool> AnnotToolDir = new Dictionary<Key, bool>();
  1425. AnnotToolDir.Add(Key.H, KeyEventsHelper.IsModifierKey(ModifierKeys.Control | ModifierKeys.Alt, Key.H));
  1426. AnnotToolDir.Add(Key.U, KeyEventsHelper.IsModifierKey(ModifierKeys.Control | ModifierKeys.Alt, Key.U));
  1427. AnnotToolDir.Add(Key.S, KeyEventsHelper.IsModifierKey(ModifierKeys.Control | ModifierKeys.Alt, Key.S));
  1428. AnnotToolDir.Add(Key.P, KeyEventsHelper.IsModifierKey(ModifierKeys.Control | ModifierKeys.Alt, Key.P));
  1429. AnnotToolDir.Add(Key.E, KeyEventsHelper.IsModifierKey(ModifierKeys.Control | ModifierKeys.Alt, Key.E));
  1430. AnnotToolDir.Add(Key.T, KeyEventsHelper.IsModifierKey(ModifierKeys.Control | ModifierKeys.Alt, Key.T));
  1431. AnnotToolDir.Add(Key.N, KeyEventsHelper.IsModifierKey(ModifierKeys.Control | ModifierKeys.Alt, Key.N));
  1432. AnnotToolDir.Add(Key.R, KeyEventsHelper.IsModifierKey(ModifierKeys.Control | ModifierKeys.Alt, Key.R));
  1433. AnnotToolDir.Add(Key.O, KeyEventsHelper.IsModifierKey(ModifierKeys.Control | ModifierKeys.Alt, Key.O));
  1434. AnnotToolDir.Add(Key.A, KeyEventsHelper.IsModifierKey(ModifierKeys.Control | ModifierKeys.Alt, Key.A));
  1435. AnnotToolDir.Add(Key.L, KeyEventsHelper.IsModifierKey(ModifierKeys.Control | ModifierKeys.Alt, Key.L));
  1436. Key key = Key.None;
  1437. foreach (var item in AnnotToolDir.Keys)
  1438. {
  1439. if (AnnotToolDir[item] == true)
  1440. {
  1441. key = item;
  1442. break;
  1443. }
  1444. }
  1445. if (key == Key.None)
  1446. return null;
  1447. var tag = "";
  1448. if (key == Key.H || key == Key.U || key == Key.S)
  1449. {
  1450. var str = PDFViewer.GetSelectedText();
  1451. if (string.IsNullOrEmpty(str) == false)
  1452. {
  1453. if (key == Key.H)
  1454. tag = "HighLight";
  1455. else if (key == Key.U)
  1456. tag = "UnderLine";
  1457. else if (key == Key.S)
  1458. tag = "Strikeout";
  1459. }
  1460. else
  1461. {
  1462. return null;
  1463. }
  1464. }
  1465. else
  1466. {
  1467. if (AnnotToolDir[Key.P])
  1468. tag = "Freehand";
  1469. else if (AnnotToolDir[Key.T])
  1470. tag = "Freetext";
  1471. else if (AnnotToolDir[Key.N])
  1472. tag = "StickyNote";
  1473. else if (AnnotToolDir[Key.R])
  1474. tag = "Rect";
  1475. else if (AnnotToolDir[Key.O])
  1476. tag = "Circle";
  1477. else if (AnnotToolDir[Key.A])
  1478. tag = "Arrow";
  1479. else if (AnnotToolDir[Key.L])
  1480. tag = "Line";
  1481. else if (AnnotToolDir[Key.E])
  1482. tag = "Eraser";
  1483. }
  1484. if (tag == "")
  1485. return null;
  1486. return new Tuple<Key, string>(key, tag);
  1487. }
  1488. #endregion 快捷键
  1489. #region Navigation
  1490. public bool IsNavigationTarget(NavigationContext navigationContext)
  1491. {
  1492. return true;
  1493. }
  1494. public void OnNavigatedFrom(NavigationContext navigationContext)
  1495. {
  1496. StrAnnotToolChecked = "";
  1497. UnBindingPDFViewerHandler();
  1498. UnBindingEvent();
  1499. }
  1500. public void OnNavigatedTo(NavigationContext navigationContext)
  1501. {
  1502. navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
  1503. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  1504. if (viewContentViewModel != null)
  1505. {
  1506. OpenFileInfo = viewContentViewModel.OpenFileInfo;
  1507. }
  1508. BindingPDFViewerHandler();
  1509. BindingEvent();
  1510. LoaedStickyNotePopup();
  1511. //获取当前是否为滚动状态
  1512. // BtnHandIsChecked = (PDFViewer.MouseMode == MouseModes.Scroll ? true : false);
  1513. BtnHandIsChecked = false;
  1514. HandToolIsCheckedEvent(false);
  1515. }
  1516. #endregion Navigation
  1517. }
  1518. }