FillAndSignContentViewModel.cs 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688
  1. using ComPDFKitViewer.AnnotEvent;
  2. using ComPDFKitViewer.PdfViewer;
  3. using PDF_Office.Model;
  4. using Prism.Commands;
  5. using Prism.Mvvm;
  6. using Prism.Regions;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows;
  13. using System.Windows.Controls;
  14. using PDF_Office.ViewModels.Tools;
  15. using ComPDFKitViewer;
  16. using PDF_Office.Helper;
  17. using PDF_Office.Properties;
  18. using PDFSettings;
  19. using System.Windows.Media;
  20. using ComPDFKit.PDFDocument.Action;
  21. using ComPDFKit.PDFDocument;
  22. using System.Diagnostics;
  23. using ComPDFKit.PDFAnnotation;
  24. using PDF_Office.ViewModels.BOTA;
  25. using PDF_Office.Views.BOTA;
  26. using System.Windows.Forms;
  27. using Control = System.Windows.Controls.Control;
  28. using Microsoft.Office.Interop.Word;
  29. using Point = System.Windows.Point;
  30. using System.Windows.Ink;
  31. using PDF_Office.EventAggregators;
  32. using System.Management.Instrumentation;
  33. using Prism.Events;
  34. using System.Windows.Input;
  35. using ContextMenu = System.Windows.Controls.ContextMenu;
  36. using MenuItem = System.Windows.Controls.MenuItem;
  37. using System.Drawing;
  38. using Color = System.Windows.Media.Color;
  39. using Brush = System.Windows.Media.Brush;
  40. using FontFamily = System.Windows.Media.FontFamily;
  41. using ToolTip = System.Windows.Controls.ToolTip;
  42. using ContentControl = System.Windows.Controls.ContentControl;
  43. using MouseEventArgs = System.Windows.Input.MouseEventArgs;
  44. using Pen = System.Windows.Media.Pen;
  45. using PDF_Office.Model.PropertyPanel.AnnotPanel;
  46. using RadioButton = System.Windows.Controls.RadioButton;
  47. using Style = System.Windows.Style;
  48. using PDF_Office.CustomControl;
  49. using System.Windows.Controls.Primitives;
  50. using Window = System.Windows.Window;
  51. using Task = System.Threading.Tasks.Task;
  52. using Size = System.Windows.Size;
  53. using System.Windows.Markup;
  54. namespace PDF_Office.ViewModels.FillAndSign
  55. {
  56. public class FillAndSignContentViewModel : BindableBase, INavigationAware
  57. {
  58. #region
  59. private CPDFViewer PDFViewer;
  60. private AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
  61. private ViewContentViewModel viewContentViewModel;
  62. private bool isRightMenuAddAnnot = false;
  63. private IEventAggregator events;
  64. public List<List<Point>> ShapePoints = new List<List<Point>>();
  65. private string Shape = "HookShape";
  66. private PopMenu FreeHandAnnotPopMenu;
  67. private PopMenu FreeTextAnnotPopMenu;
  68. private PopMenu MultiAnnotPopMenu;
  69. public bool isFirst=true;
  70. private IRegionManager regions { get; set; }
  71. private Dictionary<string, AnnotArgsType> ToolExpandDict = new Dictionary<string, AnnotArgsType>();
  72. public static bool IsEdit = false;
  73. public static bool IsSignPoint = false;
  74. public Brush SelectColor = new SolidColorBrush(Colors.GreenYellow);
  75. public double FillOpacity = 1;
  76. public double LineWidth = 1;
  77. public double LineWidthMultiple = 1;
  78. private bool _HookShapeIsCheck = true;
  79. public bool HookShapeIsCheck
  80. {
  81. get { return _HookShapeIsCheck; }
  82. set { SetProperty(ref _HookShapeIsCheck, value); }
  83. }
  84. #endregion
  85. public DelegateCommand<object> AnnotDefaultValue_MenuCommand { get; set; }
  86. public DelegateCommand<object> FreeTextFontFamily_MenuCommand { get; set; }
  87. public DelegateCommand<object> AnnotColorPalette_MenuCommand { get; set; }
  88. public DelegateCommand<object> FreeTextAglin_MenuCommand { get; set; }
  89. #region Command
  90. public DelegateCommand<RoutedEventArgs> CheckCommand { get; set; }
  91. /// <summary>
  92. /// 按钮名称和属性面板映射字典
  93. /// </summary>
  94. public Dictionary<string, string> btnToProperty = new Dictionary<string, string>();
  95. #endregion
  96. public FillAndSignContentViewModel(IRegionManager regionManager, IEventAggregator events)
  97. {
  98. regions = regionManager;
  99. this.events = events;
  100. CheckCommand = new DelegateCommand<RoutedEventArgs>(CheckedEvent);
  101. ToolExpandDict.Add("Freetext", AnnotArgsType.AnnotFreeText);
  102. InitDictionary();
  103. AnnotDefaultValue_MenuCommand = new DelegateCommand<object>(AnnotDefaultValues_Menu);
  104. AnnotColorPalette_MenuCommand = new DelegateCommand<object>(AnnotColorPalette_Menu);
  105. FreeTextFontFamily_MenuCommand = new DelegateCommand<object>(FreeTextFontFamily_Menu);
  106. FreeTextAglin_MenuCommand = new DelegateCommand<object>(FreeTextAglin_Menu);
  107. InitSelectFreeHandAnnotMenu();
  108. InitSelectFreeTextAnnotMenu();
  109. InitSelectMultiAnnotMenu();
  110. SubscribeEvent();
  111. }
  112. #region 事件聚合器(来自AnnotToolContentViewModel)
  113. private void SubscribeEvent()
  114. {
  115. events.GetEvent<FillAndSignEvent>().Subscribe(FromFillAndSign);
  116. }
  117. private void FromFillAndSign(FillAndSigntEventArgs obj)
  118. {
  119. if(obj != null)
  120. {
  121. if(string.IsNullOrEmpty(obj.Unicode) == false)
  122. {
  123. AnnotHandlerEventArgs annotArgs = null;
  124. FindAnnotTypeKey(obj.Unicode, ref annotArgs);
  125. }
  126. }
  127. }
  128. #endregion 事件聚合器
  129. private void InitFillAndSignProperty()
  130. {
  131. var FreehandDefault = GetAnnotDefault(AnnotArgsType.AnnotFreehand, "FillAndSign");
  132. SelectColor = new SolidColorBrush(FreehandDefault.BorderColor != Color.FromArgb(0, 0, 0, 0) ? FreehandDefault.BorderColor : Colors.GreenYellow);
  133. FillOpacity = FreehandDefault.Opacity > 0 ? FreehandDefault.Opacity : 1;
  134. LineWidth = FreehandDefault.Thickness > 0 ? FreehandDefault.Thickness : 1;
  135. }
  136. private System.Windows.Controls.Primitives.Popup popup = null;
  137. private async void AnnotColorPalette_Menu(object obj)
  138. {
  139. if (obj as CusMenuItem != null)
  140. {
  141. var menu = obj as CusMenuItem;
  142. var annot = menu.Parameter as AnnotHandlerEventArgs;
  143. if (annot != null)
  144. {
  145. var item = new ColorDropBoxPop();
  146. item.DataContext = menu;
  147. item.ColorSelected -= AnnotMenu_ColorSelected;
  148. item.ColorSelected += AnnotMenu_ColorSelected;
  149. if (popup == null)
  150. popup = new System.Windows.Controls.Primitives.Popup();
  151. ContentControl window = null;
  152. if (PDFViewer.Parent as ContentControl != null)
  153. window = PDFViewer.Parent as ContentControl;
  154. else
  155. window = App.Current.MainWindow;
  156. popup.Child = item;
  157. popup.PlacementRectangle = new Rect(Mouse.GetPosition(window), new Size(item.Width, item.Height));
  158. popup.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
  159. popup.PlacementTarget = window;
  160. popup.IsOpen = true;
  161. Window parentWnd = Window.GetWindow(App.Current.MainWindow);
  162. if (parentWnd != null)
  163. {
  164. parentWnd.MouseDown -= parentWnd_MouseDown;
  165. parentWnd.MouseDown += parentWnd_MouseDown;
  166. }
  167. while (popup.IsOpen)
  168. await Task.Delay(20);
  169. parentWnd.MouseDown -= parentWnd_MouseDown;
  170. popup = null;
  171. }
  172. }
  173. }
  174. private void AnnotMenu_ColorSelected(object sender, Color e)
  175. {
  176. if (sender != null)
  177. {
  178. var menu = (sender as FrameworkElement).DataContext as CusMenuItem;
  179. if (menu == null) return;
  180. var annot = menu.Parameter as AnnotHandlerEventArgs;
  181. if (annot != null)
  182. {
  183. if (annot is FreehandAnnotArgs || annot is StickyAnnotArgs || annot is LineAnnotArgs)
  184. {
  185. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  186. AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
  187. AnnotEvent?.UpdateAnnot();
  188. }
  189. else if (annot is FreeTextAnnotArgs)
  190. {
  191. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  192. if (menu.tag.ToString() == "FontColor")
  193. AnnotEvent?.UpdateAttrib(AnnotAttrib.FontColor, e);
  194. else
  195. AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, e);
  196. AnnotEvent?.UpdateAnnot();
  197. }
  198. else if (annot is SquareAnnotArgs || annot is CircleAnnotArgs)
  199. {
  200. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  201. if (menu.tag.ToString() == "FillColor")
  202. AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, e);
  203. else
  204. AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
  205. AnnotEvent?.UpdateAnnot();
  206. }
  207. else if (annot is TextHighlightAnnotArgs || annot is TextUnderlineAnnotArgs || annot is TextStrikeoutAnnotArgs)
  208. {
  209. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  210. AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
  211. AnnotEvent?.UpdateAnnot();
  212. }
  213. }
  214. }
  215. }
  216. private void parentWnd_MouseDown(object sender, MouseButtonEventArgs e)
  217. {
  218. var ui = Mouse.DirectlyOver as FrameworkElement;
  219. if (ui != null)
  220. {
  221. if (popup != null)
  222. {
  223. popup.IsOpen = false;
  224. }
  225. }
  226. }
  227. private void FreeTextFontFamily_Menu(object obj)
  228. {
  229. if (obj as CusMenuItem != null)
  230. {
  231. var menu = obj as CusMenuItem;
  232. var annot = menu.Parameter as AnnotHandlerEventArgs;
  233. if (annot != null)
  234. {
  235. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  236. AnnotEvent?.UpdateAttrib(AnnotAttrib.FontFamily, new FontFamily(menu.tag.ToString()));
  237. AnnotEvent?.UpdateAnnot();
  238. }
  239. }
  240. }
  241. private void FreeTextAglin_Menu(object obj)
  242. {
  243. if (obj as CusMenuItem != null)
  244. {
  245. var menu = obj as CusMenuItem;
  246. var annot = menu.Parameter as AnnotHandlerEventArgs;
  247. var tag = menu.control.Tag;
  248. if (annot != null && tag != null)
  249. {
  250. var strTag = tag.ToString();
  251. var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
  252. if (strTag == "Left")
  253. {
  254. AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Left);
  255. }
  256. else if (strTag == "Center")
  257. {
  258. AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Center);
  259. }
  260. else if (strTag == "Right")
  261. {
  262. AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Right);
  263. }
  264. else if (strTag == "Justify")
  265. {
  266. AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Justify);
  267. }
  268. AnnotEvent?.UpdateAnnot();
  269. }
  270. }
  271. }
  272. private void AnnotDefaultValues_Menu(object obj)
  273. {
  274. if (obj as CusMenuItem != null)
  275. {
  276. var menu = obj as CusMenuItem;
  277. var annot = menu.Parameter as AnnotHandlerEventArgs;
  278. if (annot != null)
  279. {
  280. if (annot is FreehandAnnotArgs)
  281. {
  282. var freeHand = annot as FreehandAnnotArgs;
  283. var color = freeHand.InkColor;
  284. //Settings.Default.AppProperties.Annotate.FreeHandColor = color;
  285. var FreehandDefault = GetAnnotDefault(AnnotArgsType.AnnotFreehand, "FillAndSign");
  286. FreehandDefault.BorderColor = color;
  287. FreehandDefault.Opacity = freeHand.Transparency;
  288. FreehandDefault.Thickness = freeHand.LineWidth;
  289. FreehandDefault.SaveKey = "FillAndSign";
  290. var isSolid = AnnotPropertyPanel.IsSolidStyle(freeHand.LineDash);
  291. if (isSolid)
  292. {
  293. FreehandDefault.DashArray = null;
  294. }
  295. else
  296. {
  297. FreehandDefault.DashArray = new List<double>();
  298. foreach (var item in freeHand.LineDash.Dashes)
  299. {
  300. FreehandDefault.DashArray.Add(item);
  301. }
  302. }
  303. SettingHelper.SetAnnotDefaultProperty(FreehandDefault);
  304. }
  305. else if (annot is FreeTextAnnotArgs)
  306. {
  307. var freeText = annot as FreeTextAnnotArgs;
  308. Settings.Default.AppProperties.Annotate.TextAnnoteColor = freeText.FontColor;
  309. Settings.Default.AppProperties.Annotate.TextFontFamaily = freeText.FontFamily.ToString();
  310. Settings.Default.AppProperties.Annotate.TextAlign = freeText.Align;
  311. var FreeTextDefalut = GetAnnotDefault(AnnotArgsType.AnnotFreeText);
  312. FreeTextDefalut.ForgoundColor = freeText.FontColor;
  313. FreeTextDefalut.FontFamily = freeText.FontFamily.ToString();
  314. FreeTextDefalut.TextAlign = freeText.Align;
  315. FreeTextDefalut.FontSize = freeText.FontSize;
  316. FreeTextDefalut.FontWeight = freeText.FontWeight;
  317. FreeTextDefalut.FontStyle = freeText.FontStyle;
  318. FreeTextDefalut.BackgroundColor = freeText.BgColor;
  319. FreeTextDefalut.Opacity = (annot as FreeTextAnnotArgs).Transparency;
  320. SettingHelper.SetAnnotDefaultProperty(FreeTextDefalut);
  321. }
  322. }
  323. }
  324. }
  325. private DefaultAnnotProperty GetAnnotDefault(AnnotArgsType annotArgsType,string savaKey="")
  326. {
  327. var Annot = SettingHelper.GetAnnotDefaultProperty(annotArgsType, savaKey);
  328. if (Annot == null)
  329. {
  330. Annot = new DefaultAnnotProperty();
  331. Annot.AnnotToolType = annotArgsType;
  332. }
  333. return Annot;
  334. }
  335. private void CheckedEvent(RoutedEventArgs e)
  336. {
  337. IsEdit = false;
  338. var control = e.OriginalSource as Control;
  339. //NavigateToProperty(control.Name);
  340. //不创建注释,属于注释模板
  341. bool isTemplateAnnot = false;
  342. bool isSnapshotEdit = false;
  343. AnnotHandlerEventArgs annotArgs = null;
  344. var tag = control.Name;
  345. FindAnnotTypeKey(control.Name, ref annotArgs);
  346. if (control.Name == "RbtnSign") { isTemplateAnnot = true; }
  347. if (tag == "SnapshotEdit")
  348. {
  349. isSnapshotEdit = true;
  350. }
  351. else if (tag == "Signature" || tag == "Stamp")
  352. {
  353. isTemplateAnnot = true;
  354. }
  355. if (annotArgs != null)
  356. {
  357. annotArgs.Author = Settings.Default.AppProperties.Description.Author;
  358. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  359. PDFViewer.SetToolParam(annotArgs);
  360. isRightMenuAddAnnot = false;
  361. }
  362. //当不是注释模板,且无创建注释时,属性面板显示为空内容
  363. if (isTemplateAnnot == false && annotArgs == null)
  364. {
  365. PDFViewer.SetMouseMode(MouseModes.PanTool);
  366. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  367. }
  368. else
  369. {
  370. if (isSnapshotEdit == true)
  371. {
  372. ShowPropertyPanel(false);
  373. isSnapshotEdit = false;
  374. }
  375. else
  376. {
  377. ShowPropertyPanel(true);
  378. }
  379. }
  380. }
  381. private void InitCheckedEvent(string e)
  382. {
  383. IsEdit = false;
  384. //NavigateToProperty(control.Name);
  385. //不创建注释,属于注释模板
  386. bool isTemplateAnnot = false;
  387. bool isSnapshotEdit = false;
  388. AnnotHandlerEventArgs annotArgs = null;
  389. var tag = e;
  390. FindAnnotTypeKey(e, ref annotArgs);
  391. if (e == "RbtnSign") { isTemplateAnnot = true; }
  392. if (tag == "SnapshotEdit")
  393. {
  394. isSnapshotEdit = true;
  395. }
  396. else if (tag == "Signature" || tag == "Stamp")
  397. {
  398. isTemplateAnnot = true;
  399. }
  400. if (annotArgs != null)
  401. {
  402. annotArgs.Author = Settings.Default.AppProperties.Description.Author;
  403. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  404. PDFViewer.SetToolParam(annotArgs);
  405. isRightMenuAddAnnot = false;
  406. }
  407. //当不是注释模板,且无创建注释时,属性面板显示为空内容
  408. if (isTemplateAnnot == false && annotArgs == null)
  409. {
  410. PDFViewer.SetMouseMode(MouseModes.PanTool);
  411. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  412. }
  413. else
  414. {
  415. if (isSnapshotEdit == true)
  416. {
  417. ShowPropertyPanel(false);
  418. isSnapshotEdit = false;
  419. }
  420. else
  421. {
  422. ShowPropertyPanel(true);
  423. }
  424. }
  425. }
  426. //注释工具
  427. private void FindAnnotTypeKey(string tag, ref AnnotHandlerEventArgs annotArgs, bool isRightMenuAdd = false)
  428. {
  429. LineWidthMultiple = 1;
  430. IsSignPoint = false;
  431. switch (tag)
  432. {
  433. case "RbtnDate":
  434. case "RbtnText"://文本
  435. annotArgs = GetFreetext();
  436. break;
  437. case "Freetext"://文本
  438. annotArgs = GetFreetext();
  439. break;
  440. case "RbtnSign"://签名
  441. annotArgs = GetSignature();
  442. PDFViewer.SetMouseMode(MouseModes.PanTool);//清空其他注释
  443. break;
  444. case "RbtnTick"://勾
  445. Shape = "HookShape";
  446. ShapePoints = new List<List<Point>> { new List<Point> { new Point(0.599976, 7.0286), new Point(5.57775, 11.8), new Point(13.4, 1.40002) } };
  447. annotArgs = GetStamp();
  448. break;
  449. case "RbtnFork"://叉
  450. Shape = "ForkShape";
  451. ShapePoints = new List<List<Point>> { new List<Point> { new Point(3.19995, 3.20001), new Point(12.8, 12.8) }, new List<Point> { new Point(12.8, 3.20001), new Point(3.20005, 12.8) } };
  452. annotArgs = GetStamp();
  453. break;
  454. case "RbtnRectangle"://矩形
  455. Shape = "RectShape";
  456. ShapePoints = new List<List<Point>> { new List<Point> { new Point(5, 5), new Point(28, 5) }, new List<Point> { new Point(28, 5), new Point(28, 27) }, new List<Point> { new Point(28, 27), new Point(5, 27) }, new List<Point> { new Point(5, 27), new Point(5, 5) } };
  457. annotArgs = GetStamp();
  458. break;
  459. case "RbtnLine"://下划线
  460. Shape = "LineShape";
  461. ShapePoints = new List<List<Point>> { new List<Point> { new Point(3.19995, 3.20001), new Point(28, 3.20001) } };
  462. annotArgs = GetStamp();
  463. break;
  464. case "RbtnPoint":
  465. IsSignPoint = true;
  466. Shape = "DotShape";
  467. ShapePoints = new List<List<Point>> { new List<Point> { new Point(3.19995, 3.19995), new Point(3.19995, 3.19995) } };
  468. LineWidthMultiple = 5;
  469. annotArgs = GetStamp();
  470. break;
  471. default://图章
  472. break;
  473. }
  474. }
  475. /// <summary>
  476. /// 签名
  477. /// </summary>
  478. /// <returns></returns>
  479. private AnnotHandlerEventArgs GetSignature()
  480. {
  481. AddToPropertyPanel("SignatureAnnotProperty");
  482. return null;
  483. }
  484. /// <summary>
  485. /// 图章
  486. /// </summary>
  487. /// <returns></returns>
  488. private AnnotHandlerEventArgs GetStamp(List<AnnotHandlerEventArgs> selectedArgs = null)
  489. {
  490. StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
  491. stampAnnotArgs.SetInkData(ShapePoints, LineWidth * LineWidthMultiple, (SelectColor as SolidColorBrush).Color);
  492. //PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  493. //PDFViewer.SetToolParam(stampArgs);
  494. //StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
  495. //stampAnnotArgs.Opacity = 1;
  496. //stampAnnotArgs.StampText = "APPROVED";
  497. //stampAnnotArgs.Type = StampType.STANDARD_STAMP;
  498. // stampAnnotArgs.Type = StampType.STANDARD_STAMP;
  499. stampAnnotArgs.IsContinueMode = true;
  500. stampAnnotArgs.IsSignPoint = IsSignPoint;
  501. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  502. annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
  503. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotStamp);
  504. List<AnnotHandlerEventArgs> stampAnnotArgsList = new List<AnnotHandlerEventArgs>();
  505. if (stampAnnotArgs != null)
  506. stampAnnotArgsList.Add(stampAnnotArgs);
  507. //if (selectedArgs != null) {
  508. //var annot = selectedArgs[0];
  509. //if (annot != null)
  510. //{
  511. // foreach (var item in selectedArgs)
  512. // {
  513. // selectedArgs[selectedArgs.IndexOf(item)] = stampAnnotArgs;
  514. // }
  515. // AddToPropertyPanel("ShapFillProperty", "", selectedArgs, annotAttribsList);
  516. // return stampAnnotArgs;
  517. //}
  518. // }
  519. AddToPropertyPanel("ShapFillProperty", "", stampAnnotArgsList, annotAttribsList);
  520. return stampAnnotArgs;
  521. }
  522. public void SetStamp()
  523. {
  524. StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
  525. stampAnnotArgs.SetInkData(ShapePoints, LineWidth * LineWidthMultiple, (SelectColor as SolidColorBrush).Color);
  526. //PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  527. //PDFViewer.SetToolParam(stampArgs);
  528. //StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
  529. //stampAnnotArgs.Opacity = 1;
  530. //stampAnnotArgs.StampText = "APPROVED";
  531. //stampAnnotArgs.Type = StampType.STANDARD_STAMP;
  532. stampAnnotArgs.IsContinueMode = true;
  533. stampAnnotArgs.IsSignPoint = IsSignPoint;
  534. stampAnnotArgs.Opacity = FillOpacity;
  535. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  536. annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
  537. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotStamp);
  538. List<AnnotHandlerEventArgs> stampAnnotArgsList = new List<AnnotHandlerEventArgs>();
  539. if (stampAnnotArgs != null)
  540. stampAnnotArgsList.Add(stampAnnotArgs);
  541. //AddToPropertyPanel("ShapFillProperty", "", stampAnnotArgsList, annotAttribsList);
  542. bool isTemplateAnnot = false;
  543. bool isSnapshotEdit = false;
  544. AnnotHandlerEventArgs annotArgs = stampAnnotArgs;
  545. if (annotArgs != null)
  546. {
  547. annotArgs.Author = Settings.Default.AppProperties.Description.Author;
  548. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  549. PDFViewer.SetToolParam(annotArgs);
  550. isRightMenuAddAnnot = false;
  551. }
  552. //当不是注释模板,且无创建注释时,属性面板显示为空内容
  553. if (isTemplateAnnot == false && annotArgs == null)
  554. {
  555. PDFViewer.SetMouseMode(MouseModes.PanTool);
  556. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  557. }
  558. else
  559. {
  560. if (isSnapshotEdit == true)
  561. {
  562. ShowPropertyPanel(false);
  563. isSnapshotEdit = false;
  564. }
  565. else
  566. {
  567. ShowPropertyPanel(true);
  568. }
  569. }
  570. }
  571. /// <summary>
  572. /// 手绘
  573. /// </summary>
  574. /// <param name="selectedArgs"></param>
  575. /// <returns></returns>
  576. private AnnotHandlerEventArgs GetFreehand(List<AnnotHandlerEventArgs> selectedArgs = null)
  577. {
  578. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  579. List<AnnotHandlerEventArgs> newSelectedArgs = new List<AnnotHandlerEventArgs>();
  580. FreehandAnnotArgs freehandArgs = null;
  581. if (selectedArgs == null || selectedArgs.Count == 0)
  582. {
  583. freehandArgs = new FreehandAnnotArgs();
  584. var annotate = Settings.Default.AppProperties.Annotate;
  585. if (annotate != null)
  586. {
  587. freehandArgs.InkColor = annotate.FreeHandColor;
  588. }
  589. else
  590. {
  591. freehandArgs.InkColor = Color.FromRgb(0x38, 0xE0, 0x2E);
  592. }
  593. freehandArgs.RawPointList = new List<List<Point>> { new List<Point> { new Point(0.599976, 7.0286), new Point(5.57775, 11.8), new Point(13.4, 1.40002) } };
  594. freehandArgs.Transparency = 1;
  595. freehandArgs.LineWidth = 2;
  596. if (freehandArgs != null)
  597. {
  598. selectedArgs = new List<AnnotHandlerEventArgs>();
  599. selectedArgs.Add(freehandArgs);
  600. }
  601. }
  602. else
  603. {
  604. freehandArgs = selectedArgs[0] as FreehandAnnotArgs;
  605. foreach (var item in selectedArgs)
  606. {
  607. //if (ListPoint((item as FreehandAnnotArgs).RawPointList, ShapePoints)){
  608. foreach (var point in viewContentViewModel.FillAndSign)
  609. {
  610. if ((item as FreehandAnnotArgs).PageIndex == point.Item1 && (item as FreehandAnnotArgs).AnnotIndex == point.Item2)
  611. {
  612. newSelectedArgs.Add(item);
  613. }
  614. }
  615. }
  616. freehandArgs.RawPointList = ShapePoints;
  617. freehandArgs.InkColor = (SelectColor as SolidColorBrush).Color;
  618. freehandArgs.Transparency = 1;
  619. freehandArgs.LineWidth = LineWidth;
  620. annotAttribsList[AnnotAttrib.Color] = freehandArgs.InkColor;
  621. annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
  622. annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
  623. annotAttribsList[AnnotAttrib.NoteText] = freehandArgs.Content;
  624. annotAttribsList[AnnotAttrib.Path] = freehandArgs.RawPointList;
  625. annotAttribsList[AnnotAttrib.Width] = freehandArgs.Width;
  626. annotAttribsList[AnnotAttrib.Height] = freehandArgs.Height;
  627. AddToPropertyPanel("ShapFillProperty", "Freehand", newSelectedArgs, annotAttribsList);
  628. //GetStamp();
  629. return freehandArgs;
  630. }
  631. //annotAttribsList[AnnotAttrib.Color] = freehandArgs.InkColor;
  632. //annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
  633. //annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
  634. //annotAttribsList[AnnotAttrib.NoteText] = freehandArgs.Content;
  635. //AddToPropertyPanel("ShapFillProperty", "Freehand", selectedArgs, annotAttribsList);
  636. return freehandArgs;
  637. }
  638. private bool ListPoint(List<List<Point>> leftpoints, List<List<Point>> rightpoints)
  639. {
  640. if (leftpoints.Count == rightpoints.Count)
  641. {
  642. if (leftpoints[0][0].X == rightpoints[0][0].X) { return true; }
  643. }
  644. return false;
  645. }
  646. /// <summary>
  647. /// 文本
  648. /// </summary>
  649. /// <param name="selectedfreetextArgs"></param>
  650. /// <returns></returns>
  651. private AnnotHandlerEventArgs GetFreetext(List<AnnotHandlerEventArgs> selectedArgs = null)
  652. {
  653. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  654. FreeTextAnnotArgs freetextArgs = null;
  655. TextAlignment textAlignment;
  656. if (selectedArgs == null || selectedArgs.Count == 0)
  657. {
  658. freetextArgs = new FreeTextAnnotArgs();
  659. freetextArgs.Align = TextAlignment.Left;
  660. freetextArgs.BgColor = Colors.Transparent;
  661. freetextArgs.FontFamily = new FontFamily(Settings.Default.AppProperties.Annotate.TextFontFamaily);
  662. freetextArgs.FontColor = Colors.Black;
  663. freetextArgs.FontSize = 14;
  664. freetextArgs.Transparency = 1;
  665. freetextArgs.LineColor = Colors.Black;
  666. freetextArgs.LineWidth = 0;
  667. freetextArgs.TextContent = string.Empty;
  668. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotFreeText);
  669. if (annotProperty != null)
  670. {
  671. freetextArgs.Align = annotProperty.TextAlign;
  672. freetextArgs.BgColor = annotProperty.BackgroundColor;
  673. freetextArgs.FontFamily = new FontFamily(annotProperty.FontFamily);
  674. freetextArgs.FontColor = annotProperty.ForgoundColor;
  675. freetextArgs.FontSize = annotProperty.FontSize;
  676. freetextArgs.Transparency = annotProperty.Opacity;
  677. freetextArgs.LineColor = annotProperty.BorderColor;
  678. freetextArgs.LineWidth = annotProperty.Thickness;
  679. freetextArgs.TextContent = annotProperty.NoteText;
  680. freetextArgs.FontWeight = annotProperty.FontWeight;
  681. freetextArgs.FontStyle = annotProperty.FontStyle;
  682. }
  683. int align = (int)Settings.Default.AppProperties.Annotate.TextAlign;
  684. if (align == 0)
  685. textAlignment = TextAlignment.Left;
  686. else if (align == 1)
  687. textAlignment = TextAlignment.Center;
  688. else
  689. textAlignment = TextAlignment.Right;
  690. if (freetextArgs != null)
  691. {
  692. selectedArgs = new List<AnnotHandlerEventArgs>();
  693. selectedArgs.Add(freetextArgs);
  694. }
  695. }
  696. else
  697. {
  698. freetextArgs = selectedArgs[0] as FreeTextAnnotArgs;
  699. textAlignment = freetextArgs.Align;
  700. }
  701. annotAttribsList[AnnotAttrib.Color] = freetextArgs.LineColor;
  702. annotAttribsList[AnnotAttrib.FillColor] = freetextArgs.BgColor;
  703. annotAttribsList[AnnotAttrib.Thickness] = freetextArgs.LineWidth;
  704. annotAttribsList[AnnotAttrib.Transparency] = freetextArgs.Transparency;
  705. annotAttribsList[AnnotAttrib.FontColor] = freetextArgs.FontColor;
  706. annotAttribsList[AnnotAttrib.FontSize] = freetextArgs.FontSize;
  707. annotAttribsList[AnnotAttrib.FontFamily] = freetextArgs.FontFamily;
  708. annotAttribsList[AnnotAttrib.FontStyle] = freetextArgs.FontStyle;
  709. annotAttribsList[AnnotAttrib.FontWeight] = freetextArgs.FontWeight;
  710. annotAttribsList[AnnotAttrib.TextAlign] = textAlignment;
  711. annotAttribsList[AnnotAttrib.NoteText] = freetextArgs.TextContent;
  712. annotAttribsList[AnnotAttrib.Text] = freetextArgs.TextContent;
  713. AddToPropertyPanel("FreetextAnnotProperty", "Freetext", selectedArgs, annotAttribsList);
  714. return freetextArgs;
  715. }
  716. /// <summary>
  717. /// 导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线
  718. /// </summary>
  719. /// <param name="viewContent">对应的注释面板</param>
  720. /// <param name="toolTag">导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线</param>
  721. /// <param name="annot">注释</param>
  722. /// <param name="annotAttribsList">更改注释属性的键值对,更改值后会自动记录undoRedo容器里</param>
  723. private void AddToPropertyPanel(string viewContent, string toolTag = null, List<AnnotHandlerEventArgs> annots = null, Dictionary<AnnotAttrib, object> annotAttribsList = null, AnnotAttribEvent annotAttribEvent = null, bool isUpData = false)
  724. {
  725. if (annots != null && annots.Count != 0)
  726. {
  727. propertyPanel.annotlists = annots;
  728. propertyPanel.annot = annots[0];
  729. }
  730. else
  731. {
  732. propertyPanel.annotlists = null;
  733. propertyPanel.annot = null;
  734. }
  735. if (annotAttribsList != null && annotAttribsList.Count != 0 && annots != null && annots.Count != 0)
  736. {
  737. if (annots.Count > 1)
  738. {
  739. if (propertyPanel.AnnotEvents == null)
  740. propertyPanel.AnnotEvents = new List<AnnotAttribEvent>();
  741. propertyPanel.AnnotEvents.Clear();
  742. foreach (var itemAnnot in annots)
  743. {
  744. var eventitem = AnnotAttribEvent.GetAnnotAttribEvent(itemAnnot, annotAttribsList);
  745. PDFViewer.SelectAnnotation(itemAnnot.PageIndex, itemAnnot.AnnotIndex);
  746. propertyPanel.AnnotEvents.Add(eventitem);
  747. }
  748. }
  749. propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annots[0], annotAttribsList);
  750. if (annots[0] is LinkAnnotArgs && annotAttribEvent != null)
  751. {
  752. propertyPanel.AnnotEvent = annotAttribEvent;
  753. }
  754. }
  755. if (toolTag == "Freetext")
  756. {
  757. propertyPanel.SetIsTextFill(true);
  758. }
  759. else
  760. {
  761. propertyPanel.SetIsTextFill(false);
  762. }
  763. if (string.IsNullOrEmpty(viewContent) == false)
  764. {
  765. if (isUpData) { return; }
  766. if (viewContent == "ShapFillProperty") {
  767. NavigateToProperty(viewContent, propertyPanel); return; }
  768. viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
  769. }
  770. }
  771. private void NavigateToProperty(string btnName, AnnotPropertyPanel annotPropertyPanel)
  772. {
  773. NavigationParameters values = new NavigationParameters();
  774. values.Add(ParameterNames.PDFViewer, PDFViewer);
  775. values.Add(ParameterNames.PropertyPanelContentViewModel, annotPropertyPanel);
  776. values.Add("Shape", Shape);
  777. values.Add("FillAndSignContentViewModel", this);
  778. regions.RequestNavigate(RegionNames.PropertyRegionName, btnName, values);
  779. viewContentViewModel.IsPropertyOpen = true;
  780. }
  781. /// <summary>
  782. /// 初始化按钮名称-属性面板字典
  783. /// </summary>
  784. private void InitDictionary()
  785. {
  786. btnToProperty["RbtnText"] = "TextFillProperty";
  787. btnToProperty["RbtnTick"] = "ShapFillProperty";
  788. btnToProperty["RbtnFork"] = "ShapFillProperty";
  789. btnToProperty["RbtnRectangle"] = "ShapFillProperty";
  790. btnToProperty["RbtnLine"] = "ShapFillProperty";
  791. btnToProperty["RbtnPoint"] = "ShapFillProperty";
  792. btnToProperty["RbtnDate"] = "DateFillProperty";
  793. btnToProperty["RbtnSign"] = "";
  794. }
  795. /// <summary>
  796. /// 手绘
  797. /// </summary>
  798. private void InitSelectFreeHandAnnotMenu()
  799. {
  800. var popMenu = new ContextMenu();
  801. PopMenu pop = new PopMenu(popMenu);
  802. var menuItem = new MenuItem();
  803. menuItem.Name = "FreeHandCopy";
  804. menuItem.Header = "复制";
  805. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  806. menuItem = new MenuItem();
  807. menuItem.Name = "FreeHandCut";
  808. menuItem.Header = "剪切";
  809. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  810. menuItem = new MenuItem();
  811. menuItem.Name = "FreeHandPaste";
  812. menuItem.Header = "粘贴";
  813. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
  814. menuItem = new MenuItem();
  815. menuItem.Name = "FreeHandDelete";
  816. menuItem.Header = "删除";
  817. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  818. pop.AddItem(GetSeparator());
  819. menuItem = new MenuItem();
  820. menuItem.Name = "FreeHandDefault";
  821. menuItem.Header = "设置当前属性为默认值";
  822. pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
  823. FreeHandAnnotPopMenu = pop;
  824. }
  825. /// <summary>
  826. /// 文本
  827. /// </summary>
  828. private void InitSelectFreeTextAnnotMenu()
  829. {
  830. var popMenu = new ContextMenu();
  831. PopMenu pop = new PopMenu(popMenu);
  832. var menuItem = new MenuItem();
  833. menuItem.Name = "FreeTextCopy";
  834. menuItem.Header = "复制";
  835. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  836. menuItem = new MenuItem();
  837. menuItem.Name = "FreeTextCut";
  838. menuItem.Header = "剪切";
  839. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  840. menuItem = new MenuItem();
  841. menuItem.Name = "FreeTextPaste";
  842. menuItem.Header = "粘贴";
  843. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
  844. menuItem = new MenuItem();
  845. menuItem.Name = "FreeTextDelete";
  846. menuItem.Header = "删除";
  847. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  848. pop.AddItem(GetSeparator());
  849. menuItem = new MenuItem();
  850. menuItem.Name = "FreeTextColor";
  851. menuItem.Header = "字体颜色";
  852. menuItem.Tag = "FontColor";
  853. pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
  854. menuItem = new MenuItem();
  855. menuItem.Name = "FreeTextColor";
  856. menuItem.Header = "填充颜色";
  857. menuItem.Tag = "FillColor";
  858. pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
  859. menuItem = new MenuItem();
  860. menuItem.Name = "FreeTextFontFamily";
  861. menuItem.Header = "字体";
  862. pop.AddItem(menuItem);
  863. var family = TextFont.GetFamily();
  864. foreach (var item in family)
  865. {
  866. RadioButton familyRdioBtn = new RadioButton();
  867. familyRdioBtn.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
  868. familyRdioBtn.Background = new SolidColorBrush(Colors.Transparent);
  869. familyRdioBtn.Name = item.ValueStr;
  870. familyRdioBtn.Tag = item.ValueStr;
  871. familyRdioBtn.GroupName = "FontFamily";
  872. familyRdioBtn.Content = item.Content;
  873. pop.BindingEvent(pop.AddChild("FreeTextFontFamily", familyRdioBtn), FreeTextFontFamily_MenuCommand);
  874. }
  875. menuItem = new MenuItem();
  876. menuItem.Name = "FreeTextAglin";
  877. menuItem.Header = "文本对齐";
  878. pop.AddItem(menuItem);
  879. var radioButton = new RadioButton();
  880. radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
  881. radioButton.Background = new SolidColorBrush(Colors.Transparent);
  882. radioButton.Name = "FreeTextAglinLeft";
  883. radioButton.Tag = "Left";
  884. radioButton.GroupName = "Aglin";
  885. radioButton.Content = "左对齐";
  886. pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
  887. radioButton = new RadioButton();
  888. radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
  889. radioButton.Background = new SolidColorBrush(Colors.Transparent);
  890. radioButton.Name = "FreeTextAglinCenter";
  891. radioButton.Tag = "Center";
  892. radioButton.GroupName = "Aglin";
  893. radioButton.Content = "居中对齐";
  894. pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
  895. radioButton = new RadioButton();
  896. radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
  897. radioButton.Background = new SolidColorBrush(Colors.Transparent);
  898. radioButton.Name = "FreeTextAglinRight";
  899. radioButton.Tag = "Right";
  900. radioButton.GroupName = "Aglin";
  901. radioButton.Content = "右对齐";
  902. pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
  903. radioButton = new RadioButton();
  904. radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
  905. radioButton.Background = new SolidColorBrush(Colors.Transparent);
  906. radioButton.Name = "FreeTextAglinJustify";
  907. radioButton.Tag = "Justify";
  908. radioButton.GroupName = "Aglin";
  909. radioButton.Content = "两端对齐";
  910. pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
  911. menuItem = new MenuItem();
  912. menuItem.Name = "FreeHandDefault";
  913. menuItem.Header = "设置当前属性为默认值";
  914. pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
  915. FreeTextAnnotPopMenu = pop;
  916. }
  917. /// <summary>
  918. /// 多选注释
  919. /// </summary>
  920. private void InitSelectMultiAnnotMenu()
  921. {
  922. var popMenu = new ContextMenu();
  923. PopMenu pop = new PopMenu(popMenu);
  924. var menuItem = new MenuItem();
  925. menuItem.Name = "MultiCopy";
  926. menuItem.Header = "复制";
  927. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  928. menuItem = new MenuItem();
  929. menuItem.Name = "MultiCut";
  930. menuItem.Header = "剪切";
  931. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  932. menuItem = new MenuItem();
  933. menuItem.Name = "MultiDelete";
  934. menuItem.Header = "删除";
  935. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  936. MultiAnnotPopMenu = pop;
  937. }
  938. private Separator GetSeparator()
  939. {
  940. Separator separator = new Separator();
  941. separator.Height = 1;
  942. separator.BorderBrush = new SolidColorBrush(Color.FromArgb(0x33, 0x00, 0x00, 0x00));
  943. separator.BorderThickness = new Thickness(1);
  944. return separator;
  945. }
  946. private void BindingPDFViewerHandler()
  947. {
  948. //来自PDFViewer的响应事件
  949. if (PDFViewer != null)
  950. {
  951. PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
  952. PDFViewer.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
  953. PDFViewer.AnnotCommandHandler -= PDFViewer_AnnotCommandHandler;
  954. PDFViewer.AnnotCommandHandler += PDFViewer_AnnotCommandHandler;
  955. PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
  956. PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
  957. PDFViewer.AnnotHoverHandler -= PDFViewer_AnnotHoverHandler;
  958. PDFViewer.AnnotHoverHandler += PDFViewer_AnnotHoverHandler;
  959. }
  960. }
  961. private void UnBindingPDFViewerHandler()
  962. {
  963. if (PDFViewer != null)
  964. {
  965. PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
  966. PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
  967. PDFViewer.AnnotCommandHandler -= PDFViewer_AnnotCommandHandler;
  968. PDFViewer.AnnotHoverHandler -= PDFViewer_AnnotHoverHandler;
  969. }
  970. }
  971. //在注释工具的状态下,右键菜单
  972. private void PDFViewer_AnnotCommandHandler(object sender, AnnotCommandArgs e)
  973. {
  974. if (e.AnnotEventArgsList == null || (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool))
  975. return;
  976. switch (e.CommandType)
  977. {
  978. case CommandType.Context:
  979. if (e.AnnotEventArgsList.Count > 0)
  980. {
  981. if (App.mainWindowViewModel.SelectedItem.IsInReadctonMode && e.AnnotEventArgsList[0].EventType == AnnotArgsType.AnnotRedaction)
  982. {
  983. //绑定标记密文处右键菜单
  984. events.GetEvent<RedactionCommandEvent>().Publish(new RedactionCommandEventArgs() { UniCode = App.mainWindowViewModel.SelectedItem.Unicode, Sender = sender, args = e });
  985. }
  986. else
  987. {
  988. if (e.AnnotEventArgsList.Count == 1)
  989. {
  990. var selectedAnnot = e.AnnotEventArgsList[0];
  991. switch (selectedAnnot.EventType)
  992. {
  993. case AnnotArgsType.AnnotFreehand:
  994. e.PopupMenu = FreeHandAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  995. break;
  996. case AnnotArgsType.AnnotFreeText:
  997. e.PopupMenu= FreeTextAnnotPopMenu.OpenMenu(selectedAnnot, sender);
  998. break;
  999. }
  1000. }
  1001. else
  1002. {
  1003. bool isHigh = true;//是否为高亮
  1004. foreach (var item in e.AnnotEventArgsList)
  1005. {
  1006. if (isHightAnnot(item) == false)
  1007. {
  1008. isHigh = false;
  1009. break;
  1010. }
  1011. }
  1012. MultiAnnotPopMenu.SetVisual("MultiCopy", !isHigh);
  1013. MultiAnnotPopMenu.SetVisual("MultiCut", !isHigh);
  1014. e.PopupMenu = MultiAnnotPopMenu.OpenMenu(e.AnnotEventArgsList, sender);//SelectMultiAnnotMenu(e.AnnotEventArgsList, isHigh);
  1015. }
  1016. }
  1017. if (e.PopupMenu != null)
  1018. {
  1019. e.Handle = true;
  1020. }
  1021. }
  1022. else
  1023. {
  1024. if (e.PressOnSelectedText || e.CommandTarget == TargetType.ImageSelection)
  1025. {
  1026. if (e.PopupMenu != null)
  1027. {
  1028. e.Handle = true;
  1029. }
  1030. }
  1031. else
  1032. {
  1033. e.PopupMenu = ViewerContextMenu(sender);
  1034. if (e.PopupMenu != null)
  1035. {
  1036. e.Handle = true;
  1037. }
  1038. }
  1039. }
  1040. break;
  1041. }
  1042. }
  1043. private void PDFViewer_AnnotHoverHandler(object sender, AnnotHoverData e)
  1044. {
  1045. if (e != null && e.DrawContext != null)
  1046. {
  1047. Rect hoverRect = new Rect(
  1048. e.PaintRect.Left - 2,
  1049. e.PaintRect.Top - 2,
  1050. e.PaintRect.Width + 4,
  1051. e.PaintRect.Height + 4);
  1052. Pen hoverPen = new Pen(new SolidColorBrush(Color.FromArgb(0xff, 0x11, 0x8A, 0xff)), 1);
  1053. hoverPen.DashStyle = DashStyles.Dash;
  1054. e.DrawContext?.DrawRectangle(null, hoverPen, hoverRect);
  1055. //Todo:目前ComPDFKit.Viewer没有e.Annot参数
  1056. //便签,显示ToolTip内容
  1057. //if (e.Annot != null && e.Annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_TEXT)
  1058. //{
  1059. // if (PDFViewer.ToolTip == null)
  1060. // {
  1061. // var content = e.Annot.GetContent();
  1062. // if (string.IsNullOrEmpty(content) == false)
  1063. // {
  1064. // ToolTip TipChild = new ToolTip();
  1065. // TipChild.Style = App.Current.Resources["FlowToolTip"] as Style;
  1066. // TipChild.MaxWidth = 246;
  1067. // TipChild.Content = content;
  1068. // TipChild.Visibility = Visibility.Visible;
  1069. // TipChild.IsOpen = true;
  1070. // TipChild.Placement = PlacementMode.Right;
  1071. // var rec = e.Annot.GetRect();
  1072. // TipChild.PlacementRectangle = new Rect(rec.left, rec.top, rec.right, rec.bottom);
  1073. // TipChild.PlacementTarget = PDFViewer.Parent as ContentControl;
  1074. // TipChild.Placement = PlacementMode.MousePoint;
  1075. // PDFViewer.ToolTip = TipChild;
  1076. // oldRect = hoverRect;
  1077. // PDFViewer.MouseMove -= PDFViewer_MouseMove;
  1078. // PDFViewer.MouseMove += PDFViewer_MouseMove;
  1079. // return;
  1080. // }
  1081. // }
  1082. //}
  1083. }
  1084. CloseAnnotToolTip();
  1085. }
  1086. private Rect oldRect = new Rect(0, 0, 0, 0);
  1087. private void CloseAnnotToolTip()
  1088. {
  1089. if (PDFViewer.ToolTip != null && PDFViewer.ToolTip is ToolTip)
  1090. {
  1091. ToolTip oldTips = (ToolTip)PDFViewer.ToolTip;
  1092. oldTips.IsOpen = false;
  1093. oldTips.Visibility = Visibility.Collapsed;
  1094. PDFViewer.ToolTip = null;
  1095. PDFViewer.MouseMove -= PDFViewer_MouseMove;
  1096. oldRect = new Rect(0, 0, 0, 0);
  1097. }
  1098. }
  1099. private void PDFViewer_MouseMove(object sender, MouseEventArgs e)
  1100. {
  1101. if (sender != null && PDFViewer.ToolTip != null && PDFViewer.Parent != null)
  1102. {
  1103. var newPoint = e.GetPosition(PDFViewer.Parent as ContentControl);
  1104. var isOutw = newPoint.X > (oldRect.X + oldRect.Width + 4);
  1105. var isOuth = newPoint.Y > (oldRect.Y + oldRect.Height + 4);
  1106. if (newPoint.X < oldRect.X || newPoint.Y < oldRect.Y || isOutw || isOuth)
  1107. {
  1108. CloseAnnotToolTip();
  1109. }
  1110. }
  1111. }
  1112. private ContextMenu ViewerContextMenu(object sender)
  1113. {
  1114. ContextMenu contextMenu = App.Current.FindResource("ViewerContextMenu") as ContextMenu;
  1115. ViewerContextMenu_Loaded(contextMenu, sender);
  1116. return contextMenu;
  1117. }
  1118. private void ViewerContextMenu_Loaded(object sender, object e, Visibility visibility = Visibility.Collapsed)
  1119. {
  1120. ContextMenu contextMenu = sender as ContextMenu;
  1121. if (contextMenu.Items.Count > 0)
  1122. {
  1123. int index = PDFViewer.CurrentIndex;
  1124. //检测是否已存在相同数据
  1125. CPDFBookmark list = PDFViewer.Document.GetBookmarkList().FirstOrDefault(q => q.PageIndex == index);
  1126. foreach (var item in contextMenu.Items)
  1127. {
  1128. if (item is Separator separator)
  1129. {
  1130. separator.Visibility = visibility;
  1131. }
  1132. if (item is MenuItem menuItem1)
  1133. {
  1134. //if (menuItem1.Tag.ToString() == "DisplayAnnot" || menuItem1.Tag.ToString() == "HiddenAnnot")
  1135. //{
  1136. // SetMenuItemVisibility(menuItem1, "DisplayAnnot", "HiddenAnnot", isHiddenAnnot);
  1137. //}
  1138. switch (menuItem1.Tag.ToString())
  1139. {
  1140. case "Paste":
  1141. //粘贴
  1142. //if (!ApplicationCommands.Paste.CanExecute(null, (UIElement)sender))
  1143. //{
  1144. // menuItem1.IsEnabled = false;
  1145. // menuItem1.Opacity = 0.5;
  1146. //}
  1147. //else
  1148. //{
  1149. // menuItem1.IsEnabled = true;
  1150. // menuItem1.Opacity = 1;
  1151. //}
  1152. menuItem1.CommandTarget = (UIElement)e;
  1153. menuItem1.Command = ApplicationCommands.Paste;
  1154. break;
  1155. case "AddAnnotation":
  1156. menuItem1.Visibility = visibility;
  1157. break;
  1158. case "HiddenAnnot":
  1159. menuItem1.Visibility = visibility;
  1160. break;
  1161. case "DisplayAnnot":
  1162. menuItem1.Visibility = visibility;
  1163. break;
  1164. case "AddBookMark":
  1165. menuItem1.Visibility = visibility;
  1166. break;
  1167. case "DelBookMark":
  1168. menuItem1.Visibility = visibility;
  1169. break;
  1170. case "ToolMode":
  1171. menuItem1.Visibility = visibility;
  1172. break;
  1173. case "ReadModel":
  1174. menuItem1.Visibility = visibility;
  1175. break;
  1176. case "UnReadModel":
  1177. menuItem1.Visibility = visibility;
  1178. break;
  1179. case "ViewZoom":
  1180. menuItem1.Visibility = visibility;
  1181. break;
  1182. case "PageDisplay":
  1183. menuItem1.Visibility = visibility;
  1184. break;
  1185. case "Select":
  1186. menuItem1.Click -= Select_Click;
  1187. menuItem1.Click += Select_Click;
  1188. break;
  1189. case "Print":
  1190. menuItem1.Command = viewContentViewModel.PrintCommand;
  1191. break;
  1192. }
  1193. }
  1194. }
  1195. }
  1196. }
  1197. private void Select_Click(object sender, RoutedEventArgs e)
  1198. {
  1199. if (viewContentViewModel.OpenBOTA == false)
  1200. {
  1201. viewContentViewModel.OpenBOTA = true;
  1202. }
  1203. bool isBook = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemSearch");
  1204. if (isBook == false)
  1205. {
  1206. bOTAContent.TabItemSearch.IsSelected = true;
  1207. }
  1208. }
  1209. private bool IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, string tabItemText)
  1210. {
  1211. bool isTabItem = false;
  1212. bOTAContentViewModel = null;
  1213. bOTAContent = null;
  1214. if (regions.Regions.ContainsRegionWithName(viewContentViewModel.BOTARegionName))
  1215. {
  1216. var views = regions.Regions[viewContentViewModel.BOTARegionName].Views;
  1217. var model = views.FirstOrDefault(q => q is BOTAContent);
  1218. if (model is BOTAContent bOTAContent1)
  1219. {
  1220. bOTAContent = bOTAContent1;
  1221. bOTAContentViewModel = bOTAContent.DataContext as BOTAContentViewModel;
  1222. if (bOTAContentViewModel.CurrentBar == tabItemText)
  1223. {
  1224. isTabItem = true;
  1225. }
  1226. }
  1227. //foreach (var item in views)
  1228. //{
  1229. // if (item is BOTAContent bOTAContent1)
  1230. // {
  1231. // bOTAContent = bOTAContent1;
  1232. // bOTAContentViewModel = bOTAContent.DataContext as BOTAContentViewModel;
  1233. // if (bOTAContentViewModel.CurrentBar == tabItemText)
  1234. // {
  1235. // isTabItem = true;
  1236. // break;
  1237. // }
  1238. // }
  1239. //}
  1240. }
  1241. return isTabItem;
  1242. }
  1243. private bool isHightAnnot(AnnotHandlerEventArgs annot)
  1244. {
  1245. if (annot.EventType == AnnotArgsType.AnnotUnderline ||
  1246. annot.EventType == AnnotArgsType.AnnotSquiggly ||
  1247. annot.EventType == AnnotArgsType.AnnotHighlight ||
  1248. annot.EventType == AnnotArgsType.AnnotStrikeout
  1249. )
  1250. {
  1251. return true;
  1252. }
  1253. else
  1254. {
  1255. return false;
  1256. }
  1257. }
  1258. //注释编辑事件
  1259. private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
  1260. {
  1261. if (e != null && e.Count > 0)
  1262. {
  1263. for (int i = 0; i < e.Count; i++)
  1264. {
  1265. AnnotEditEvent editEvent = e[i];
  1266. switch (editEvent.EditAction)
  1267. {
  1268. case ActionType.Add:
  1269. int pageindex = editEvent.PageIndex;
  1270. int annotindex = editEvent.AnnotIndex;
  1271. viewContentViewModel.FillAndSign.Add(new Tuple<int,int>(pageindex, annotindex));
  1272. PDFViewer.SelectAnnotation(pageindex, annotindex);
  1273. break;
  1274. }
  1275. }
  1276. }
  1277. }
  1278. //选中和非选中注释,右键菜单
  1279. private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
  1280. {
  1281. if (e != null)
  1282. {
  1283. var annot = e.AnnotItemsList[0];
  1284. if (annot != null)
  1285. {
  1286. if (e.AnnotItemsList.Count == 1)
  1287. {
  1288. //IsEdit = false;
  1289. //IsAnnotCreateReset:是否为创建注释的状态
  1290. if (e.IsAnnotCreateReset == false)
  1291. {
  1292. GetSelectedAnnots(e);
  1293. //记录这次选中的注释,之后创建注释会跟随上次选中注释的属性值
  1294. //PDFViewer.SetToolParam(annot);
  1295. }
  1296. else
  1297. {
  1298. //TODO: 设计已重新调整为(仅限高亮注释):修改注释后,会作用到之后添加的注释中。因此先把此逻辑“创建注释后,会自动回到默认值”注释掉
  1299. if (annot.EventType != AnnotArgsType.AnnotStrikeout &&
  1300. annot.EventType != AnnotArgsType.AnnotUnderline &&
  1301. annot.EventType != AnnotArgsType.AnnotHighlight &&
  1302. annot.EventType != AnnotArgsType.AnnotSquiggly &&
  1303. annot.EventType != AnnotArgsType.AnnotLink &&
  1304. annot.EventType != AnnotArgsType.AnnotFreehand &&
  1305. annot.EventType != AnnotArgsType.AnnotSticky
  1306. )
  1307. {
  1308. if (ToolExpandDict.ContainsValue(e.AnnotItemsList[0].EventType))
  1309. {
  1310. foreach (var item in ToolExpandDict)
  1311. {
  1312. if (item.Value == e.AnnotItemsList[0].EventType)
  1313. {
  1314. annot = null;//新建注释时,回到默认值
  1315. FindAnnotTypeKey(item.Key, ref annot);
  1316. break;
  1317. }
  1318. }
  1319. }
  1320. }
  1321. //else
  1322. //PDFViewer.SetToolParam(annot);
  1323. //设计重新调整,阅读页空白处,右键菜单,添加链接,和pro mac一样的效果,不显示属性栏
  1324. if (isRightMenuAddAnnot)
  1325. {
  1326. ShowPropertyPanel(false);
  1327. }
  1328. else
  1329. {
  1330. ShowPropertyPanel();
  1331. }
  1332. }
  1333. }
  1334. else
  1335. {
  1336. bool isDifferentAnnotTyle = false;
  1337. var lastAnnot = annot;
  1338. foreach (var item in e.AnnotItemsList)
  1339. {
  1340. if (lastAnnot.EventType != item.EventType)
  1341. {
  1342. if (isShapAnnot(annot) == true && isShapAnnot(item) == true)
  1343. {
  1344. lastAnnot = item;
  1345. continue;
  1346. }
  1347. lastAnnot = item;
  1348. isDifferentAnnotTyle = true;
  1349. break;
  1350. }
  1351. }
  1352. if (isDifferentAnnotTyle)
  1353. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  1354. else
  1355. GetSelectedAnnots(e);
  1356. }
  1357. }
  1358. }
  1359. else
  1360. {
  1361. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  1362. }
  1363. }
  1364. //private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
  1365. //{
  1366. // if (e != null && e.Count > 0)
  1367. // {
  1368. // for (int i = 0; i < e.Count; i++)
  1369. // {
  1370. // AnnotEditEvent editEvent = e[i];
  1371. // switch (editEvent.EditAction)
  1372. // {
  1373. // case ActionType.Add:
  1374. // // bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  1375. // if (viewContentViewModel.OpenBOTA == true && isTabItemAnnotation == true)
  1376. // {
  1377. // AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel);
  1378. // if (viewModel != null)
  1379. // {
  1380. // int pageindex = editEvent.PageIndex;
  1381. // int annotindex = editEvent.AnnotIndex;
  1382. // viewModel.UpdateAddedAnnot(pageindex, annotindex);
  1383. // }
  1384. // }
  1385. // break;
  1386. // case ActionType.Del:
  1387. // //isTabItemAnnotation = IsBOTATabItemShow(out bOTAContentViewModel, out bOTAContent, "TabItemAnnotation");
  1388. // if (isTabItemAnnotation)
  1389. // {
  1390. // AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel);
  1391. // if (viewModel != null)
  1392. // {
  1393. // int pageindex = editEvent.PageIndex;
  1394. // int annotindex = editEvent.AnnotIndex;
  1395. // viewModel.UpdateModifiedAnnot(pageindex, annotindex, true);
  1396. // }
  1397. // }
  1398. // break;
  1399. // case ActionType.Modify:
  1400. // isTabItemAnnotation = IsBOTATabItemShow(out bOTAContentViewModel, out bOTAContent, "TabItemAnnotation");
  1401. // if (bOTAContent.TabItemAnnotation.IsSelected)
  1402. // {
  1403. // AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel);
  1404. // if (viewModel != null)
  1405. // {
  1406. // int pageindex = editEvent.PageIndex;
  1407. // int annotindex = editEvent.AnnotIndex;
  1408. // viewModel.UpdateModifiedAnnot(pageindex, annotindex, false);
  1409. // }
  1410. // }
  1411. // break;
  1412. // case ActionType.TextEdit:
  1413. // break;
  1414. // default:
  1415. // break;
  1416. // }
  1417. // }
  1418. // }
  1419. //}
  1420. private bool isShapAnnot(AnnotHandlerEventArgs annot)
  1421. {
  1422. if (annot.EventType == AnnotArgsType.AnnotCircle ||
  1423. annot.EventType == AnnotArgsType.AnnotSquare ||
  1424. annot.EventType == AnnotArgsType.AnnotLine
  1425. )
  1426. {
  1427. return true;
  1428. }
  1429. else
  1430. {
  1431. return false;
  1432. }
  1433. }
  1434. private void GetSelectedAnnots(AnnotAttribEvent e)
  1435. {
  1436. IsEdit = true;
  1437. var annot = e.AnnotItemsList[0];
  1438. switch (annot.EventType)
  1439. {
  1440. case AnnotArgsType.AnnotFreeText:
  1441. GetFreetext(e.AnnotItemsList);
  1442. break;
  1443. case AnnotArgsType.AnnotFreehand:
  1444. GetFreehand(e.AnnotItemsList);
  1445. break;
  1446. }
  1447. }
  1448. private void ShowPropertyPanel(bool show = true)
  1449. {
  1450. viewContentViewModel.IsPropertyOpen = show;
  1451. }
  1452. #region Navigation
  1453. public bool IsNavigationTarget(NavigationContext navigationContext)
  1454. {
  1455. return true;
  1456. }
  1457. public void OnNavigatedFrom(NavigationContext navigationContext)
  1458. {
  1459. UnBindingPDFViewerHandler();
  1460. ContextMenu contextMenu = App.Current.FindResource("ViewerContextMenu") as ContextMenu;
  1461. ViewerContextMenu_Loaded(contextMenu, null, Visibility.Visible);
  1462. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  1463. PDFViewer.SetMouseMode(MouseModes.PanTool);
  1464. ShowPropertyPanel(false);
  1465. }
  1466. public void OnNavigatedTo(NavigationContext navigationContext)
  1467. {
  1468. navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
  1469. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  1470. BindingPDFViewerHandler();
  1471. HookShapeIsCheck = true;
  1472. InitFillAndSignProperty();
  1473. InitCheckedEvent("RbtnTick");
  1474. IsEdit = false;
  1475. }
  1476. #endregion
  1477. }
  1478. }