FillAndSignContentViewModel.cs 70 KB

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