AnnotToolContentViewModel.Layout.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. using ComPDFKit.PDFDocument;
  2. using ComPDFKitViewer;
  3. using ComPDFKitViewer.AnnotEvent;
  4. using PDF_Office.CustomControl.CompositeControl;
  5. using PDF_Office.Helper;
  6. using Prism.Mvvm;
  7. using Prism.Regions;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows;
  14. using System.Windows.Controls;
  15. using System.Windows.Input;
  16. using System.Windows.Media;
  17. namespace PDF_Office.ViewModels.Tools
  18. {
  19. //文件说明:与布局相关的代码逻辑:菜单、属性面板
  20. public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
  21. {
  22. #region 属性面板
  23. /// <summary>
  24. /// 导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线
  25. /// </summary>
  26. /// <param name="viewContent">对应的注释面板</param>
  27. /// <param name="toolTag">导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线</param>
  28. /// <param name="annot">注释</param>
  29. /// <param name="annotAttribsList">更改注释属性的键值对,更改值后会自动记录undoRedo容器里</param>
  30. private void AddToPropertyPanel(string viewContent, string toolTag = null, List<AnnotHandlerEventArgs> annots = null, Dictionary<AnnotAttrib, object> annotAttribsList = null, AnnotAttribEvent annotAttribEvent = null)
  31. {
  32. if (annots != null)
  33. {
  34. propertyPanel.annotlists = annots;
  35. propertyPanel.annot = annots[0];
  36. }
  37. else
  38. {
  39. propertyPanel.annotlists = null;
  40. propertyPanel.annot = null;
  41. }
  42. if (annotAttribsList != null)
  43. {
  44. if (annots.Count > 1)
  45. {
  46. if (propertyPanel.AnnotEvents == null)
  47. propertyPanel.AnnotEvents = new List<AnnotAttribEvent>();
  48. propertyPanel.AnnotEvents.Clear();
  49. foreach (var itemAnnot in annots)
  50. {
  51. var eventitem = AnnotAttribEvent.GetAnnotAttribEvent(itemAnnot, annotAttribsList);
  52. propertyPanel.AnnotEvents.Add(eventitem);
  53. }
  54. }
  55. propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annots[0], annotAttribsList);
  56. if (annots[0] is LinkAnnotArgs && annotAttribEvent != null)
  57. {
  58. propertyPanel.AnnotEvent = annotAttribEvent;
  59. }
  60. }
  61. if (string.IsNullOrEmpty(viewContent) == false)
  62. {
  63. viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
  64. }
  65. }
  66. /// <summary>
  67. /// 展开显示属性面板
  68. /// </summary>
  69. private void ShowPropertyPanel(bool show = true)
  70. {
  71. viewContentViewModel.IsPropertyOpen = show;
  72. }
  73. #endregion 属性面板
  74. #region 阅读页 - 右键菜单
  75. private ContextMenu ViewerContextMenu()
  76. {
  77. ContextMenu contextMenu = App.Current.FindResource("ViewerContextMenu") as ContextMenu;
  78. //contextMenu.Loaded += ContextMenu_Loaded;
  79. ViewerContextMenu_Loaded(contextMenu, null);
  80. return contextMenu;
  81. }
  82. private void ViewerContextMenu_Loaded(object sender, RoutedEventArgs e)
  83. {
  84. ContextMenu contextMenu = sender as ContextMenu;
  85. if (contextMenu.Items.Count > 0)
  86. {
  87. int index = PDFViewer.CurrentIndex;
  88. //检测是否已存在相同数据
  89. CPDFBookmark list = PDFViewer.Document.GetBookmarkList().FirstOrDefault(q => q.PageIndex == index);
  90. if (list != null)
  91. {
  92. isAddBookMark = false;
  93. }
  94. else
  95. {
  96. isAddBookMark = true;
  97. }
  98. foreach (var item in contextMenu.Items)
  99. {
  100. if (item is MenuItem menuItem1)
  101. {
  102. //if (menuItem1.Tag.ToString() == "DisplayAnnot" || menuItem1.Tag.ToString() == "HiddenAnnot")
  103. //{
  104. // SetMenuItemVisibility(menuItem1, "DisplayAnnot", "HiddenAnnot", isHiddenAnnot);
  105. //}
  106. switch (menuItem1.Tag.ToString())
  107. {
  108. case "Copy":
  109. //粘贴
  110. if (!ApplicationCommands.Paste.CanExecute(null, (UIElement)sender))
  111. {
  112. menuItem1.IsEnabled = false;
  113. menuItem1.Opacity = 0.5;
  114. }
  115. else
  116. {
  117. menuItem1.IsEnabled = true;
  118. menuItem1.Opacity = 1;
  119. }
  120. menuItem1.CommandTarget = (UIElement)sender;
  121. menuItem1.Command = ApplicationCommands.Copy;
  122. break;
  123. case "AddAnnotation":
  124. if (menuItem1.Items.Count > 0)
  125. {
  126. SetAddAnnotation(menuItem1.Items);
  127. }
  128. break;
  129. case "HiddenAnnot":
  130. menuItem1.Click -= HiddenAnnot_Click;
  131. menuItem1.Click += HiddenAnnot_Click;
  132. SetMenuItemVisibility(menuItem1, "DisplayAnnot", "HiddenAnnot", isHiddenAnnot);
  133. break;
  134. case "DisplayAnnot":
  135. menuItem1.Click -= DisplayAnnot_Click;
  136. menuItem1.Click += DisplayAnnot_Click;
  137. SetMenuItemVisibility(menuItem1, "DisplayAnnot", "HiddenAnnot", isHiddenAnnot);
  138. break;
  139. case "AddBookMark":
  140. //menuItem1.Click -= AddBookMark_Click;
  141. //menuItem1.Click += AddBookMark_Click;
  142. menuItem1.Command = AddBookMarkCommand;
  143. SetMenuItemVisibility(menuItem1, "DelBookMark", "AddBookMark", isAddBookMark);
  144. break;
  145. case "DelBookMark":
  146. menuItem1.Click -= DelBookMark_Click;
  147. menuItem1.Click += DelBookMark_Click;
  148. SetMenuItemVisibility(menuItem1, "DelBookMark", "AddBookMark", isAddBookMark);
  149. break;
  150. case "ToolMode":
  151. if (menuItem1.Items.Count > 0)
  152. {
  153. SetToolMode(menuItem1.Items);
  154. }
  155. break;
  156. case "ReadModel":
  157. SetMenuItemVisibility(menuItem1, "ReadModel", "UnReadModel", App.IsBookMode);
  158. menuItem1.Click -= ReadModel_Click;
  159. menuItem1.Click += ReadModel_Click;
  160. break;
  161. case "UnReadModel":
  162. SetMenuItemVisibility(menuItem1, "ReadModel", "UnReadModel", App.IsBookMode);
  163. menuItem1.Click -= UnReadModel_Click;
  164. menuItem1.Click += UnReadModel_Click;
  165. break;
  166. case "ViewZoom":
  167. if (menuItem1.Items.Count > 0)
  168. {
  169. ViewZoom(menuItem1.Items);
  170. }
  171. break;
  172. case "PageDisplay":
  173. if (menuItem1.Items.Count > 0)
  174. {
  175. PageDisplay(menuItem1.Items);
  176. }
  177. break;
  178. case "Select":
  179. menuItem1.Click -= Select_Click;
  180. menuItem1.Click += Select_Click;
  181. break;
  182. case "Print":
  183. menuItem1.Command = viewContentViewModel.PrintCommand;
  184. break;
  185. }
  186. }
  187. }
  188. }
  189. }
  190. private void SetMenuItemVisibility(MenuItem menuItem1, string right, string deny, bool flag)
  191. {
  192. if (menuItem1.Tag.ToString() == right && flag)
  193. {
  194. menuItem1.Visibility = Visibility.Collapsed;
  195. }
  196. if (menuItem1.Tag.ToString() == right && flag == false)
  197. {
  198. menuItem1.Visibility = Visibility.Visible;
  199. }
  200. if (menuItem1.Tag.ToString() == deny && flag == false)
  201. {
  202. menuItem1.Visibility = Visibility.Collapsed;
  203. }
  204. if (menuItem1.Tag.ToString() == deny && flag)
  205. {
  206. menuItem1.Visibility = Visibility.Visible;
  207. }
  208. }
  209. private ContextMenu NoneSelectAnnotContextMenu(object sender, AnnotCommandArgs annotCommand)
  210. {
  211. ContextMenu popMenu = new ContextMenu();
  212. popMenu.FontSize = 14;
  213. MenuItem menuItem = new MenuItem();
  214. menuItem = new MenuItem();
  215. menuItem.CommandTarget = (UIElement)sender;
  216. menuItem.Command = ApplicationCommands.Copy;
  217. popMenu.Items.Add(menuItem);
  218. menuItem = new MenuItem();
  219. menuItem.CommandTarget = (UIElement)sender;
  220. menuItem.Command = ApplicationCommands.Paste;
  221. popMenu.Items.Add(menuItem);
  222. Separator separator = null;
  223. if (annotCommand.CommandTarget == TargetType.ImageSelection)
  224. {
  225. separator = SetSeparator();
  226. popMenu.Items.Add(separator);
  227. SetSelectTextOrImageMenuItem("导出图片...", "ExportPicture", annotCommand, out menuItem);
  228. popMenu.Items.Add(menuItem);
  229. }
  230. else if (annotCommand.CommandTarget == TargetType.Annot)
  231. {
  232. separator = SetSeparator();
  233. popMenu.Items.Add(separator);
  234. SetSelectTextOrImageMenuItem("高亮", "HighLight", annotCommand, out menuItem);
  235. popMenu.Items.Add(menuItem);
  236. SetSelectTextOrImageMenuItem("下划线", "UnderLine", annotCommand, out menuItem);
  237. popMenu.Items.Add(menuItem);
  238. SetSelectTextOrImageMenuItem("删除线", "Strikeout", annotCommand, out menuItem);
  239. popMenu.Items.Add(menuItem);
  240. }
  241. separator = SetSeparator();
  242. popMenu.Items.Add(separator);
  243. SetSelectTextOrImageMenuItem("文本", "Freetext", annotCommand, out menuItem);
  244. popMenu.Items.Add(menuItem);
  245. SetSelectTextOrImageMenuItem("便签", "StickyNote", annotCommand, out menuItem);
  246. popMenu.Items.Add(menuItem);
  247. separator = SetSeparator();
  248. popMenu.Items.Add(separator);
  249. SetSelectTextOrImageMenuItem("矩形", "Rect", annotCommand, out menuItem);
  250. popMenu.Items.Add(menuItem);
  251. SetSelectTextOrImageMenuItem("椭圆形", "Circle", annotCommand, out menuItem);
  252. popMenu.Items.Add(menuItem);
  253. SetSelectTextOrImageMenuItem("直线", "Line", annotCommand, out menuItem);
  254. popMenu.Items.Add(menuItem);
  255. separator = SetSeparator();
  256. popMenu.Items.Add(separator);
  257. SetSelectTextOrImageMenuItem("添加链接", "Link", annotCommand, out menuItem);
  258. popMenu.Items.Add(menuItem);
  259. SetSelectTextOrImageMenuItem("添加大纲", "OutLine", annotCommand, out menuItem);
  260. popMenu.Items.Add(menuItem);
  261. return popMenu;
  262. }
  263. private void SetSelectTextOrImageMenuItem(string header, string tag, AnnotCommandArgs annotCommand, out MenuItem menuItem)
  264. {
  265. menuItem = new MenuItem();
  266. menuItem.Header = header;
  267. menuItem.Tag = tag;
  268. menuItem.Click -= AnnotToolMenu_Click;
  269. menuItem.Click += AnnotToolMenu_Click;
  270. menuItem.CommandParameter = annotCommand;
  271. }
  272. private Separator SetSeparator()
  273. {
  274. Separator separator = new Separator
  275. {
  276. Height = 1,
  277. BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#33000000")),
  278. BorderThickness = new Thickness(1),
  279. Style = (Style)App.Current.FindResource(System.Windows.Controls.ToolBar.SeparatorStyleKey)
  280. };
  281. return separator;
  282. }
  283. #endregion 阅读页 - 右键菜单
  284. #region 注释-右键菜单
  285. //高亮注释,右键菜单
  286. private ContextMenu SelectHightAnnotMenu(object sender)
  287. {
  288. var popMenu = new ContextMenu();
  289. PopMenu pop = new PopMenu(popMenu);
  290. ColorContent colorContent = new ColorContent();
  291. colorContent.Name = "hightcolor";
  292. colorContent.SelectedColorHandler -= colorContent_SelectedColorHandler;
  293. colorContent.SelectedColorHandler += colorContent_SelectedColorHandler;
  294. pop.AddItem(colorContent);
  295. var menuItem = new MenuItem();
  296. menuItem.Name = "hightCopyText";
  297. menuItem.Header = "复制文本";
  298. pop.BindingEvent(pop.AddItem(menuItem), HightAnnotCopyText_MenuCommand, sender);
  299. menuItem = new MenuItem();
  300. menuItem.Name = "hightdelete";
  301. menuItem.Header = "删除";
  302. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete, sender);
  303. menuItem = new MenuItem();
  304. menuItem.Name = "hightAddNote";
  305. menuItem.Header = "添加笔记";
  306. pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand, sender);
  307. menuItem = new MenuItem();
  308. menuItem.Name = "hightdefault";
  309. menuItem.Header = "设置当前属性为默认值";
  310. pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand, sender);
  311. //var popMenu = App.Current.FindResource("HightAnnotContextMenu") as ContextMenu;
  312. //CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
  313. ////颜色列表
  314. //ColorContent colorContent = new ColorContent();
  315. //colorContent.DataContext = sender;
  316. //colorContent.SelectedColorHandler -= colorContent_SelectedColorHandler;
  317. //colorContent.SelectedColorHandler += colorContent_SelectedColorHandler;
  318. //customMenu.SetMenuUI(0,colorContent);
  319. ////复制文本
  320. //customMenu.SetMenuBinding(1, HightAnnotCopyText_MenuCommand);
  321. ////删除
  322. //customMenu.SetMenuBinding(2, ApplicationCommands.Delete);
  323. ////添加笔记
  324. //customMenu.SetMenuBinding(3, AnnotAddNoteText_MenuCommand);
  325. ////设置当前属性为默认值
  326. //customMenu.SetMenuBinding(4, AnnotDefaultValue_MenuCommand);
  327. return popMenu;
  328. }
  329. private void colorContent_SelectedColorHandler(object sender, Color e)
  330. {
  331. if (e == null) return;
  332. var annot =(sender as FrameworkElement).DataContext as AnnotHandlerEventArgs;
  333. if(annot != null)
  334. {
  335. var test = annot as TextHighlightAnnotArgs;
  336. if(test != null)
  337. {
  338. var anvent = AnnotAttribEvent.GetAnnotAttribEvent(test, test.GetAnnotAttrib());
  339. anvent.UpdateAttrib(AnnotAttrib.Color, e);
  340. anvent.UpdateAnnot();
  341. }
  342. }
  343. }
  344. //手绘
  345. private ContextMenu SelectFreeHandAnnotMenu(object sender)
  346. {
  347. var popMenu = App.Current.FindResource("FreeHandAnnotContextMenu") as ContextMenu;
  348. CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
  349. //复制
  350. customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
  351. //剪切
  352. customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
  353. //粘贴
  354. customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
  355. //删除
  356. customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
  357. //颜色
  358. customMenu.SetMenuBinding(4, AnnotColorPalette_MenuCommand);
  359. //线段样式
  360. var freeHand = sender as FreehandAnnotArgs;
  361. bool IsSolid = true;
  362. if (freeHand != null)
  363. {
  364. IsSolid = AnnotPropertyPanel.IsSolidStyle(freeHand.LineDash);
  365. }
  366. customMenu.SetSubMenuBinding(5, 0, FreeHandLineStyle_MenuCommand,null, IsSolid);
  367. customMenu.SetSubMenuBinding(5, 1, FreeHandLineStyle_MenuCommand, null, !IsSolid);
  368. //添加笔记
  369. customMenu.SetMenuBinding(6, AnnotAddNoteText_MenuCommand);
  370. //设置当前属性为默认值
  371. customMenu.SetMenuBinding(7, AnnotDefaultValue_MenuCommand);
  372. return popMenu;
  373. }
  374. //文本
  375. private ContextMenu SelectFreeTextAnnotMenu(object sender)
  376. {
  377. var popMenu = App.Current.FindResource("FreeTextAnnotContextMenu") as ContextMenu;
  378. CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
  379. //复制
  380. customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
  381. //剪切
  382. customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
  383. //粘贴
  384. customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
  385. //删除
  386. customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
  387. //文本颜色
  388. customMenu.SetMenuBinding(4, AnnotColorPalette_MenuCommand);
  389. //字体
  390. var annot = sender as FreeTextAnnotArgs;
  391. customMenu.SetSubMenuBinding(5, 0, FreeTextFontFamily_MenuCommand, null, (annot != null && annot.FontFamily.ToString() == "Arial") ?true:false);
  392. customMenu.SetSubMenuBinding(5, 1, FreeTextFontFamily_MenuCommand, null,(annot != null && annot.FontFamily.ToString() == "Courier") ? true : false);
  393. customMenu.SetSubMenuBinding(5, 2, FreeTextFontFamily_MenuCommand, null, (annot != null && annot.FontFamily.ToString() == "Times New Roman") ? true : false);
  394. //文本对齐
  395. customMenu.SetSubMenuBinding(6, 0, FreeTextAglin_MenuCommand, null, (annot != null && annot.Align == TextAlignment.Left) ? true : false);
  396. customMenu.SetSubMenuBinding(6, 1, FreeTextAglin_MenuCommand, null, (annot != null && annot.Align == TextAlignment.Center) ? true : false);
  397. customMenu.SetSubMenuBinding(6, 2, FreeTextAglin_MenuCommand, null, (annot != null && annot.Align == TextAlignment.Right) ? true : false);
  398. //设置当前属性为默认值
  399. customMenu.SetMenuBinding(7, AnnotDefaultValue_MenuCommand);
  400. return popMenu;
  401. }
  402. //便签
  403. private ContextMenu SelectStrickNoteAnnotMenu(object sender)
  404. {
  405. var popMenu = App.Current.FindResource("StrickNoteAnnotContextMenu") as ContextMenu;
  406. CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
  407. //复制
  408. customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
  409. //剪切
  410. customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
  411. //粘贴
  412. customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
  413. //删除
  414. customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
  415. //颜色
  416. customMenu.SetMenuBinding(4, AnnotColorPalette_MenuCommand);
  417. if(sender as StickyAnnotArgs != null)
  418. {
  419. }
  420. //编辑便签
  421. customMenu.SetMenuBinding(5, ApplicationCommands.Delete);//
  422. //设置当前属性为默认值
  423. customMenu.SetMenuBinding(7, AnnotDefaultValue_MenuCommand);
  424. return popMenu;
  425. }
  426. //形状
  427. private ContextMenu SelectShapeAnnotMenu(object sender)
  428. {
  429. var popMenu = App.Current.FindResource("ShapeAnnotContextMenu") as ContextMenu;
  430. CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
  431. //复制
  432. customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
  433. //剪切
  434. customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
  435. //粘贴
  436. customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
  437. //删除
  438. customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
  439. //颜色
  440. customMenu.SetMenuBinding(4, AnnotColorPalette_MenuCommand);
  441. //线段样式
  442. bool IsSolid = true;
  443. if (sender as SquareAnnotArgs != null)
  444. {
  445. IsSolid = AnnotPropertyPanel.IsSolidStyle((sender as SquareAnnotArgs).LineDash);
  446. }
  447. else if(sender as CircleAnnotArgs != null)
  448. {
  449. IsSolid = AnnotPropertyPanel.IsSolidStyle((sender as CircleAnnotArgs).LineDash);
  450. }
  451. else if(sender as LineAnnotArgs != null)
  452. {
  453. IsSolid = AnnotPropertyPanel.IsSolidStyle((sender as LineAnnotArgs).LineDash);
  454. }
  455. customMenu.SetSubMenuBinding(5, 0, ShapeLineStyle_MenuCommand, null, IsSolid);
  456. customMenu.SetSubMenuBinding(5, 1, ShapeLineStyle_MenuCommand, null, !IsSolid);
  457. //线段方向
  458. if(sender as LineAnnotArgs != null)
  459. {
  460. customMenu.SetSubMenuBinding(6, 0, ShapeLineDirect_MenuCommand ,null, true);//暂无,待确认
  461. customMenu.SetSubMenuBinding(6, 1, ShapeLineDirect_MenuCommand ,null, true);//
  462. customMenu.SetVisibilityProperty(6, true);
  463. }
  464. else
  465. {
  466. customMenu.SetVisibilityProperty(6,false);
  467. }
  468. //添加笔记
  469. customMenu.SetMenuBinding(7, AnnotAddNoteText_MenuCommand);
  470. //设置当前属性为默认值
  471. customMenu.SetMenuBinding(8, AnnotDefaultValue_MenuCommand);
  472. return popMenu;
  473. }
  474. //链接
  475. private ContextMenu SelectLinkAnnotMenu(object sender)
  476. {
  477. var popMenu = App.Current.FindResource("LinkAnnotContextMenu") as ContextMenu;
  478. CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
  479. //复制
  480. customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
  481. //剪切
  482. customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
  483. //粘贴
  484. customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
  485. //删除
  486. customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
  487. return popMenu;
  488. }
  489. //图章、签名
  490. private ContextMenu SelectStampAnnotMenu(object sender)
  491. {
  492. var popMenu = App.Current.FindResource("StampAnnotContextMenu") as ContextMenu;
  493. CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
  494. //复制
  495. customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
  496. //剪切
  497. customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
  498. //粘贴
  499. customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
  500. //删除
  501. customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
  502. //导出
  503. customMenu.SetSubMenuBinding(4, 0, StampExportPicture_MenuCommand);//
  504. customMenu.SetSubMenuBinding(4, 1, StampExportPicture_MenuCommand);//
  505. customMenu.SetSubMenuBinding(4, 2, StampExportPicture_MenuCommand);//
  506. //添加笔记
  507. customMenu.SetMenuBinding(5, AnnotAddNoteText_MenuCommand);
  508. return popMenu;
  509. }
  510. //多选注释
  511. private ContextMenu SelectMultiAnnotMenu(object sender, bool isHightAnnot)
  512. {
  513. var popMenu = App.Current.FindResource("MultiSelectAnnotContextMenu") as ContextMenu;
  514. CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
  515. if (isHightAnnot)
  516. {
  517. customMenu.SetVisibilityProperty(0, false);
  518. customMenu.SetVisibilityProperty(1, false);
  519. }
  520. else
  521. {
  522. //复制
  523. customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
  524. //剪切
  525. customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
  526. }
  527. //删除
  528. customMenu.SetMenuBinding(2, ApplicationCommands.Delete);
  529. return popMenu;
  530. }
  531. #endregion 注释-右键菜单
  532. }
  533. }