FillAndSignContentViewModel.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  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. namespace PDF_Office.ViewModels.FillAndSign
  31. {
  32. public class FillAndSignContentViewModel : BindableBase, INavigationAware
  33. {
  34. #region
  35. private CPDFViewer PDFViewer;
  36. private AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
  37. private ViewContentViewModel viewContentViewModel;
  38. private bool isRightMenuAddAnnot = false;
  39. private List<List<Point>> ShapePoints = new List<List<Point>>();
  40. private string Shape = "HookShape";
  41. private IRegionManager regions { get; set; }
  42. private Dictionary<string, AnnotArgsType> ToolExpandDict = new Dictionary<string, AnnotArgsType>();
  43. public Brush SelectColor=new SolidColorBrush(Colors.GreenYellow);
  44. public double FillOpacity = 1;
  45. public double LineWidth = 1;
  46. #endregion
  47. #region Command
  48. public DelegateCommand<RoutedEventArgs> CheckCommand { get; set; }
  49. /// <summary>
  50. /// 按钮名称和属性面板映射字典
  51. /// </summary>
  52. public Dictionary<string, string> btnToProperty = new Dictionary<string, string>();
  53. #endregion
  54. public FillAndSignContentViewModel(IRegionManager regionManager)
  55. {
  56. regions = regionManager;
  57. CheckCommand = new DelegateCommand<RoutedEventArgs>(CheckedEvent);
  58. ToolExpandDict.Add("Freetext", AnnotArgsType.AnnotFreeText);
  59. InitDictionary();
  60. }
  61. private void CheckedEvent(RoutedEventArgs e)
  62. {
  63. var control = e.OriginalSource as Control;
  64. //NavigateToProperty(control.Name);
  65. //不创建注释,属于注释模板
  66. bool isTemplateAnnot = false;
  67. bool isSnapshotEdit = false;
  68. AnnotHandlerEventArgs annotArgs = null;
  69. var tag = control.Name;
  70. FindAnnotTypeKey(control.Name, ref annotArgs);
  71. if (control.Name == "RbtnSign") { isTemplateAnnot = true; }
  72. if (tag == "SnapshotEdit")
  73. {
  74. isSnapshotEdit = true;
  75. }
  76. else if (tag == "Signature" || tag == "Stamp")
  77. {
  78. isTemplateAnnot = true;
  79. }
  80. if (annotArgs != null)
  81. {
  82. annotArgs.Author = Settings.Default.AppProperties.Description.Author;
  83. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  84. PDFViewer.SetToolParam(annotArgs);
  85. isRightMenuAddAnnot = false;
  86. }
  87. //当不是注释模板,且无创建注释时,属性面板显示为空内容
  88. if (isTemplateAnnot == false && annotArgs == null)
  89. {
  90. PDFViewer.SetMouseMode(MouseModes.PanTool);
  91. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  92. }
  93. else
  94. {
  95. if (isSnapshotEdit == true)
  96. {
  97. ShowPropertyPanel(false);
  98. isSnapshotEdit = false;
  99. }
  100. else
  101. {
  102. ShowPropertyPanel(true);
  103. }
  104. }
  105. }
  106. //注释工具
  107. private void FindAnnotTypeKey(string tag, ref AnnotHandlerEventArgs annotArgs, bool isRightMenuAdd = false)
  108. {
  109. switch (tag)
  110. {
  111. case "RbtnDate":
  112. case "RbtnText"://文本
  113. annotArgs = GetFreetext();
  114. break;
  115. case "Freetext"://文本
  116. annotArgs = GetFreetext();
  117. break;
  118. case "RbtnSign"://签名
  119. annotArgs = GetSignature();
  120. PDFViewer.SetMouseMode(MouseModes.PanTool);//清空其他注释
  121. break;
  122. case "RbtnTick"://勾
  123. Shape = "HookShape";
  124. 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)} };
  125. annotArgs = GetStamp();
  126. break;
  127. case "RbtnFork"://叉
  128. Shape = "ForkShape";
  129. 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) }};
  130. annotArgs = GetStamp();
  131. break;
  132. case "RbtnRectangle"://矩形
  133. Shape = "RectShape";
  134. ShapePoints = new List<List<Point>> { new List<Point> { new Point(0, 5), new Point(28, 5),new Point(28,27),new Point(0,27) , new Point(0, 5) } };
  135. annotArgs = GetStamp();
  136. break;
  137. case "RbtnLine"://下划线
  138. Shape = "LineShape";
  139. ShapePoints = new List<List<Point>> { new List<Point> { new Point(12, 10), new Point(36, 10) } };
  140. annotArgs = GetStamp();
  141. break;
  142. case "RbtnPoint":
  143. Shape = "DotShape";
  144. ShapePoints = new List<List<Point>> { new List<Point> { new Point(0, 0), new Point(2, 2) }, new List<Point> { new Point(2, 0), new Point(0,2 ) } };
  145. annotArgs = GetStamp();
  146. break;
  147. default://图章
  148. break;
  149. }
  150. }
  151. /// <summary>
  152. /// 签名
  153. /// </summary>
  154. /// <returns></returns>
  155. private AnnotHandlerEventArgs GetSignature()
  156. {
  157. AddToPropertyPanel("SignatureAnnotProperty");
  158. return null;
  159. }
  160. /// <summary>
  161. /// 图章
  162. /// </summary>
  163. /// <returns></returns>
  164. private AnnotHandlerEventArgs GetStamp()
  165. {
  166. StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
  167. stampAnnotArgs.SetInkData(ShapePoints, LineWidth, (SelectColor as SolidColorBrush).Color);
  168. //PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  169. //PDFViewer.SetToolParam(stampArgs);
  170. //StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
  171. //stampAnnotArgs.Opacity = 1;
  172. //stampAnnotArgs.StampText = "APPROVED";
  173. //stampAnnotArgs.Type = StampType.STANDARD_STAMP;
  174. // stampAnnotArgs.Type = StampType.STANDARD_STAMP;
  175. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  176. annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
  177. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotStamp);
  178. List<AnnotHandlerEventArgs> stampAnnotArgsList = new List<AnnotHandlerEventArgs>();
  179. if (stampAnnotArgs != null)
  180. stampAnnotArgsList.Add(stampAnnotArgs);
  181. AddToPropertyPanel("ShapFillProperty", "", stampAnnotArgsList, annotAttribsList);
  182. return stampAnnotArgs;
  183. }
  184. public void SetStamp()
  185. {
  186. StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
  187. stampAnnotArgs.SetInkData(ShapePoints, LineWidth, (SelectColor as SolidColorBrush).Color);
  188. //PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  189. //PDFViewer.SetToolParam(stampArgs);
  190. //StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
  191. //stampAnnotArgs.Opacity = 1;
  192. //stampAnnotArgs.StampText = "APPROVED";
  193. //stampAnnotArgs.Type = StampType.STANDARD_STAMP;
  194. stampAnnotArgs.Opacity = FillOpacity;
  195. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  196. annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
  197. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotStamp);
  198. List<AnnotHandlerEventArgs> stampAnnotArgsList = new List<AnnotHandlerEventArgs>();
  199. if (stampAnnotArgs != null)
  200. stampAnnotArgsList.Add(stampAnnotArgs);
  201. AddToPropertyPanel("ShapFillProperty", "", stampAnnotArgsList, annotAttribsList);
  202. bool isTemplateAnnot = false;
  203. bool isSnapshotEdit = false;
  204. AnnotHandlerEventArgs annotArgs = stampAnnotArgs;
  205. if (annotArgs != null)
  206. {
  207. annotArgs.Author = Settings.Default.AppProperties.Description.Author;
  208. PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
  209. PDFViewer.SetToolParam(annotArgs);
  210. isRightMenuAddAnnot = false;
  211. }
  212. //当不是注释模板,且无创建注释时,属性面板显示为空内容
  213. if (isTemplateAnnot == false && annotArgs == null)
  214. {
  215. PDFViewer.SetMouseMode(MouseModes.PanTool);
  216. viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  217. }
  218. else
  219. {
  220. if (isSnapshotEdit == true)
  221. {
  222. ShowPropertyPanel(false);
  223. isSnapshotEdit = false;
  224. }
  225. else
  226. {
  227. ShowPropertyPanel(true);
  228. }
  229. }
  230. }
  231. /// <summary>
  232. /// 文本
  233. /// </summary>
  234. /// <param name="selectedfreetextArgs"></param>
  235. /// <returns></returns>
  236. private AnnotHandlerEventArgs GetFreetext(List<AnnotHandlerEventArgs> selectedArgs = null)
  237. {
  238. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  239. FreeTextAnnotArgs freetextArgs = null;
  240. TextAlignment textAlignment;
  241. if (selectedArgs == null || selectedArgs.Count == 0)
  242. {
  243. freetextArgs = new FreeTextAnnotArgs();
  244. freetextArgs.Align = TextAlignment.Left;
  245. freetextArgs.BgColor = Colors.Transparent;
  246. freetextArgs.FontFamily = new FontFamily(Settings.Default.AppProperties.Annotate.TextFontFamaily);
  247. freetextArgs.FontColor = Colors.Black;
  248. freetextArgs.FontSize = 14;
  249. freetextArgs.Transparency = 1;
  250. freetextArgs.LineColor = Colors.Black;
  251. freetextArgs.LineWidth = 0;
  252. freetextArgs.TextContent = string.Empty;
  253. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotFreeText);
  254. if (annotProperty != null)
  255. {
  256. freetextArgs.Align = annotProperty.TextAlign;
  257. freetextArgs.BgColor = annotProperty.BackgroundColor;
  258. freetextArgs.FontFamily = new FontFamily(annotProperty.FontFamily);
  259. freetextArgs.FontColor = annotProperty.ForgoundColor;
  260. freetextArgs.FontSize = annotProperty.FontSize;
  261. freetextArgs.Transparency = annotProperty.Opacity;
  262. freetextArgs.LineColor = annotProperty.BorderColor;
  263. freetextArgs.LineWidth = annotProperty.Thickness;
  264. freetextArgs.TextContent = annotProperty.NoteText;
  265. freetextArgs.FontWeight = annotProperty.FontWeight;
  266. freetextArgs.FontStyle = annotProperty.FontStyle;
  267. }
  268. int align = (int)Settings.Default.AppProperties.Annotate.TextAlign;
  269. if (align == 0)
  270. textAlignment = TextAlignment.Left;
  271. else if (align == 1)
  272. textAlignment = TextAlignment.Center;
  273. else
  274. textAlignment = TextAlignment.Right;
  275. if (freetextArgs != null)
  276. {
  277. selectedArgs = new List<AnnotHandlerEventArgs>();
  278. selectedArgs.Add(freetextArgs);
  279. }
  280. }
  281. else
  282. {
  283. freetextArgs = selectedArgs[0] as FreeTextAnnotArgs;
  284. textAlignment = freetextArgs.Align;
  285. }
  286. annotAttribsList[AnnotAttrib.Color] = freetextArgs.LineColor;
  287. annotAttribsList[AnnotAttrib.FillColor] = freetextArgs.BgColor;
  288. annotAttribsList[AnnotAttrib.Thickness] = freetextArgs.LineWidth;
  289. annotAttribsList[AnnotAttrib.Transparency] = freetextArgs.Transparency;
  290. annotAttribsList[AnnotAttrib.FontColor] = freetextArgs.FontColor;
  291. annotAttribsList[AnnotAttrib.FontSize] = freetextArgs.FontSize;
  292. annotAttribsList[AnnotAttrib.FontFamily] = freetextArgs.FontFamily;
  293. annotAttribsList[AnnotAttrib.FontStyle] = freetextArgs.FontStyle;
  294. annotAttribsList[AnnotAttrib.FontWeight] = freetextArgs.FontWeight;
  295. annotAttribsList[AnnotAttrib.TextAlign] = textAlignment;
  296. annotAttribsList[AnnotAttrib.NoteText] = freetextArgs.TextContent;
  297. AddToPropertyPanel("FreetextAnnotProperty", "Freetext", selectedArgs, annotAttribsList);
  298. return freetextArgs;
  299. }
  300. /// <summary>
  301. /// 导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线
  302. /// </summary>
  303. /// <param name="viewContent">对应的注释面板</param>
  304. /// <param name="toolTag">导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线</param>
  305. /// <param name="annot">注释</param>
  306. /// <param name="annotAttribsList">更改注释属性的键值对,更改值后会自动记录undoRedo容器里</param>
  307. private void AddToPropertyPanel(string viewContent, string toolTag = null, List<AnnotHandlerEventArgs> annots = null, Dictionary<AnnotAttrib, object> annotAttribsList = null, AnnotAttribEvent annotAttribEvent = null,bool isUpData=false)
  308. {
  309. if (annots != null)
  310. {
  311. propertyPanel.annotlists = annots;
  312. propertyPanel.annot = annots[0];
  313. }
  314. else
  315. {
  316. propertyPanel.annotlists = null;
  317. propertyPanel.annot = null;
  318. }
  319. if (annotAttribsList != null)
  320. {
  321. if (annots.Count > 1)
  322. {
  323. if (propertyPanel.AnnotEvents == null)
  324. propertyPanel.AnnotEvents = new List<AnnotAttribEvent>();
  325. propertyPanel.AnnotEvents.Clear();
  326. foreach (var itemAnnot in annots)
  327. {
  328. var eventitem = AnnotAttribEvent.GetAnnotAttribEvent(itemAnnot, annotAttribsList);
  329. propertyPanel.AnnotEvents.Add(eventitem);
  330. }
  331. }
  332. propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annots[0], annotAttribsList);
  333. if (annots[0] is LinkAnnotArgs && annotAttribEvent != null)
  334. {
  335. propertyPanel.AnnotEvent = annotAttribEvent;
  336. }
  337. }
  338. if (string.IsNullOrEmpty(viewContent) == false)
  339. {
  340. if (isUpData) { return; }
  341. if (viewContent == "ShapFillProperty") { NavigateToProperty(viewContent, propertyPanel); return; }
  342. viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
  343. }
  344. }
  345. private void NavigateToProperty(string btnName, AnnotPropertyPanel annotPropertyPanel)
  346. {
  347. NavigationParameters values = new NavigationParameters();
  348. values.Add(ParameterNames.PDFViewer, PDFViewer);
  349. values.Add(ParameterNames.PropertyPanelContentViewModel, annotPropertyPanel);
  350. values.Add("Shape", Shape);
  351. values.Add("FillAndSignContentViewModel", this);
  352. regions.RequestNavigate(RegionNames.PropertyRegionName,btnName,values);
  353. viewContentViewModel.IsPropertyOpen = true;
  354. }
  355. /// <summary>
  356. /// 初始化按钮名称-属性面板字典
  357. /// </summary>
  358. private void InitDictionary()
  359. {
  360. btnToProperty["RbtnText"] = "TextFillProperty";
  361. btnToProperty["RbtnTick"] = "ShapFillProperty";
  362. btnToProperty["RbtnFork"] = "ShapFillProperty";
  363. btnToProperty["RbtnRectangle"] = "ShapFillProperty";
  364. btnToProperty["RbtnLine"] = "ShapFillProperty";
  365. btnToProperty["RbtnPoint"] = "ShapFillProperty";
  366. btnToProperty["RbtnDate"] = "DateFillProperty";
  367. btnToProperty["RbtnSign"] = "";
  368. }
  369. private void BindingPDFViewerHandler()
  370. {
  371. //来自PDFViewer的响应事件
  372. if (PDFViewer != null)
  373. {
  374. //PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
  375. //PDFViewer.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
  376. }
  377. }
  378. private void UnBindingPDFViewerHandler()
  379. {
  380. if (PDFViewer != null)
  381. { /*PDFViewer.AnnotActiveHandler += PDFViewer_AnnotActiveHandler; */}
  382. }
  383. //选中和非选中注释,右键菜单
  384. //private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
  385. //{
  386. // if (e != null)
  387. // {
  388. // var annot = e.AnnotItemsList[0];
  389. // if (annot != null)
  390. // {
  391. // if (e.AnnotItemsList.Count == 1)
  392. // {
  393. // //IsAnnotCreateReset:是否为创建注释的状态
  394. // if (e.IsAnnotCreateReset == false)
  395. // {
  396. // GetSelectedAnnots(e);
  397. // //记录这次选中的注释,之后创建注释会跟随上次选中注释的属性值
  398. // PDFViewer.SetToolParam(annot);
  399. // }
  400. // else
  401. // {
  402. // //TODO: 设计已重新调整为(仅限高亮注释):修改注释后,会作用到之后添加的注释中。因此先把此逻辑“创建注释后,会自动回到默认值”注释掉
  403. // if (annot.EventType != AnnotArgsType.AnnotStrikeout &&
  404. // annot.EventType != AnnotArgsType.AnnotUnderline &&
  405. // annot.EventType != AnnotArgsType.AnnotHighlight &&
  406. // annot.EventType != AnnotArgsType.AnnotSquiggly &&
  407. // annot.EventType != AnnotArgsType.AnnotLink &&
  408. // annot.EventType != AnnotArgsType.AnnotFreehand &&
  409. // annot.EventType != AnnotArgsType.AnnotSticky
  410. // )
  411. // {
  412. // if (ToolExpandDict.ContainsValue(e.AnnotItemsList[0].EventType))
  413. // {
  414. // foreach (var item in ToolExpandDict)
  415. // {
  416. // if (item.Value == e.AnnotItemsList[0].EventType)
  417. // {
  418. // annot = null;//新建注释时,回到默认值
  419. // FindAnnotTypeKey(item.Key, ref annot);
  420. // break;
  421. // }
  422. // }
  423. // }
  424. // }
  425. // //else
  426. // //PDFViewer.SetToolParam(annot);
  427. // //设计重新调整,阅读页空白处,右键菜单,添加链接,和pro mac一样的效果,不显示属性栏
  428. // if (isRightMenuAddAnnot)
  429. // {
  430. // ShowPropertyPanel(false);
  431. // }
  432. // else
  433. // {
  434. // ShowPropertyPanel();
  435. // }
  436. // }
  437. // }
  438. // else
  439. // {
  440. // bool isDifferentAnnotTyle = false;
  441. // var lastAnnot = annot;
  442. // foreach (var item in e.AnnotItemsList)
  443. // {
  444. // if (lastAnnot.EventType != item.EventType)
  445. // {
  446. // if (isShapAnnot(annot) == true && isShapAnnot(item) == true)
  447. // {
  448. // lastAnnot = item;
  449. // continue;
  450. // }
  451. // lastAnnot = item;
  452. // isDifferentAnnotTyle = true;
  453. // break;
  454. // }
  455. // }
  456. // if (isDifferentAnnotTyle)
  457. // viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  458. // else
  459. // GetSelectedAnnots(e);
  460. // }
  461. // }
  462. // }
  463. // else
  464. // {
  465. // viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
  466. // }
  467. //}
  468. //private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
  469. //{
  470. // if (e != null && e.Count > 0)
  471. // {
  472. // for (int i = 0; i < e.Count; i++)
  473. // {
  474. // AnnotEditEvent editEvent = e[i];
  475. // switch (editEvent.EditAction)
  476. // {
  477. // case ActionType.Add:
  478. // // bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
  479. // if (viewContentViewModel.OpenBOTA == true && isTabItemAnnotation == true)
  480. // {
  481. // AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel);
  482. // if (viewModel != null)
  483. // {
  484. // int pageindex = editEvent.PageIndex;
  485. // int annotindex = editEvent.AnnotIndex;
  486. // viewModel.UpdateAddedAnnot(pageindex, annotindex);
  487. // }
  488. // }
  489. // break;
  490. // case ActionType.Del:
  491. // //isTabItemAnnotation = IsBOTATabItemShow(out bOTAContentViewModel, out bOTAContent, "TabItemAnnotation");
  492. // if (isTabItemAnnotation)
  493. // {
  494. // AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel);
  495. // if (viewModel != null)
  496. // {
  497. // int pageindex = editEvent.PageIndex;
  498. // int annotindex = editEvent.AnnotIndex;
  499. // viewModel.UpdateModifiedAnnot(pageindex, annotindex, true);
  500. // }
  501. // }
  502. // break;
  503. // case ActionType.Modify:
  504. // isTabItemAnnotation = IsBOTATabItemShow(out bOTAContentViewModel, out bOTAContent, "TabItemAnnotation");
  505. // if (bOTAContent.TabItemAnnotation.IsSelected)
  506. // {
  507. // AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel);
  508. // if (viewModel != null)
  509. // {
  510. // int pageindex = editEvent.PageIndex;
  511. // int annotindex = editEvent.AnnotIndex;
  512. // viewModel.UpdateModifiedAnnot(pageindex, annotindex, false);
  513. // }
  514. // }
  515. // break;
  516. // case ActionType.TextEdit:
  517. // break;
  518. // default:
  519. // break;
  520. // }
  521. // }
  522. // }
  523. //}
  524. private bool isShapAnnot(AnnotHandlerEventArgs annot)
  525. {
  526. if (annot.EventType == AnnotArgsType.AnnotCircle ||
  527. annot.EventType == AnnotArgsType.AnnotSquare ||
  528. annot.EventType == AnnotArgsType.AnnotLine
  529. )
  530. {
  531. return true;
  532. }
  533. else
  534. {
  535. return false;
  536. }
  537. }
  538. private void GetSelectedAnnots(AnnotAttribEvent e)
  539. {
  540. var annot = e.AnnotItemsList[0];
  541. switch (annot.EventType)
  542. {
  543. case AnnotArgsType.AnnotFreeText:
  544. GetFreetext(e.AnnotItemsList);
  545. break;
  546. }
  547. }
  548. private void ShowPropertyPanel(bool show = true)
  549. {
  550. viewContentViewModel.IsPropertyOpen = show;
  551. }
  552. #region Navigation
  553. public bool IsNavigationTarget(NavigationContext navigationContext)
  554. {
  555. return true;
  556. }
  557. public void OnNavigatedFrom(NavigationContext navigationContext)
  558. {
  559. UnBindingPDFViewerHandler();
  560. }
  561. public void OnNavigatedTo(NavigationContext navigationContext)
  562. {
  563. navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
  564. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  565. BindingPDFViewerHandler();
  566. }
  567. #endregion
  568. }
  569. }