AnnotToolContentViewModel.Layout.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  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 = App.Current.FindResource("HightAnnotContextMenu") as ContextMenu;
  289. CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
  290. //颜色列表
  291. ColorContent colorContent = new ColorContent();
  292. colorContent.DataContext = sender;
  293. colorContent.SelectedColorHandler -= colorContent_SelectedColorHandler;
  294. colorContent.SelectedColorHandler += colorContent_SelectedColorHandler;
  295. customMenu.SetMenuUI(0,colorContent);
  296. //复制文本
  297. customMenu.SetMenuBinding(1, HightAnnotCopyText_MenuCommand);
  298. //删除
  299. customMenu.SetMenuBinding(2, ApplicationCommands.Delete);
  300. //添加笔记
  301. customMenu.SetMenuBinding(3, AnnotAddNoteText_MenuCommand);
  302. //设置当前属性为默认值
  303. customMenu.SetMenuBinding(4, AnnotDefaultValue_MenuCommand);
  304. return popMenu;
  305. }
  306. private void colorContent_SelectedColorHandler(object sender, Color e)
  307. {
  308. if (e == null) return;
  309. var annot =(sender as FrameworkElement).DataContext as AnnotHandlerEventArgs;
  310. if(annot != null)
  311. {
  312. var test = annot as TextHighlightAnnotArgs;
  313. if(test != null)
  314. {
  315. var anvent = AnnotAttribEvent.GetAnnotAttribEvent(test, test.GetAnnotAttrib());
  316. anvent.UpdateAttrib(AnnotAttrib.Color, e);
  317. anvent.UpdateAnnot();
  318. }
  319. }
  320. }
  321. //手绘
  322. private ContextMenu SelectFreeHandAnnotMenu(object sender)
  323. {
  324. var popMenu = App.Current.FindResource("FreeHandAnnotContextMenu") as ContextMenu;
  325. CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
  326. //复制
  327. customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
  328. //剪切
  329. customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
  330. //粘贴
  331. customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
  332. //删除
  333. customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
  334. //颜色
  335. customMenu.SetMenuBinding(4, AnnotColorPalette_MenuCommand);
  336. //线段样式
  337. var freeHand = sender as FreehandAnnotArgs;
  338. bool IsSolid = true;
  339. if (freeHand != null)
  340. {
  341. IsSolid = AnnotPropertyPanel.IsSolidStyle(freeHand.LineDash);
  342. }
  343. customMenu.SetSubMenuBinding(5, 0, FreeHandLineStyle_MenuCommand,null, IsSolid);
  344. customMenu.SetSubMenuBinding(5, 1, FreeHandLineStyle_MenuCommand, null, !IsSolid);
  345. //添加笔记
  346. customMenu.SetMenuBinding(6, AnnotAddNoteText_MenuCommand);
  347. //设置当前属性为默认值
  348. customMenu.SetMenuBinding(7, AnnotDefaultValue_MenuCommand);
  349. return popMenu;
  350. }
  351. //文本
  352. private ContextMenu SelectFreeTextAnnotMenu(object sender)
  353. {
  354. var popMenu = App.Current.FindResource("FreeTextAnnotContextMenu") as ContextMenu;
  355. CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
  356. //复制
  357. customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
  358. //剪切
  359. customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
  360. //粘贴
  361. customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
  362. //删除
  363. customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
  364. //文本颜色
  365. customMenu.SetMenuBinding(4, AnnotColorPalette_MenuCommand);
  366. //字体
  367. var annot = sender as FreeTextAnnotArgs;
  368. customMenu.SetSubMenuBinding(5, 0, FreeTextFontFamily_MenuCommand, null, (annot != null && annot.FontFamily.ToString() == "Arial") ?true:false);
  369. customMenu.SetSubMenuBinding(5, 1, FreeTextFontFamily_MenuCommand, null,(annot != null && annot.FontFamily.ToString() == "Courier") ? true : false);
  370. customMenu.SetSubMenuBinding(5, 2, FreeTextFontFamily_MenuCommand, null, (annot != null && annot.FontFamily.ToString() == "Times New Roman") ? true : false);
  371. //文本对齐
  372. customMenu.SetSubMenuBinding(6, 0, FreeTextAglin_MenuCommand, null, (annot != null && annot.Align == TextAlignment.Left) ? true : false);
  373. customMenu.SetSubMenuBinding(6, 1, FreeTextAglin_MenuCommand, null, (annot != null && annot.Align == TextAlignment.Center) ? true : false);
  374. customMenu.SetSubMenuBinding(6, 2, FreeTextAglin_MenuCommand, null, (annot != null && annot.Align == TextAlignment.Right) ? true : false);
  375. //设置当前属性为默认值
  376. customMenu.SetMenuBinding(7, AnnotDefaultValue_MenuCommand);
  377. return popMenu;
  378. }
  379. //便签
  380. private ContextMenu SelectStrickNoteAnnotMenu(object sender)
  381. {
  382. var popMenu = App.Current.FindResource("StrickNoteAnnotContextMenu") as ContextMenu;
  383. CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
  384. //复制
  385. customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
  386. //剪切
  387. customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
  388. //粘贴
  389. customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
  390. //删除
  391. customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
  392. //颜色
  393. customMenu.SetMenuBinding(4, AnnotColorPalette_MenuCommand);
  394. if(sender as StickyAnnotArgs != null)
  395. {
  396. }
  397. //编辑便签
  398. customMenu.SetMenuBinding(5, ApplicationCommands.Delete);//
  399. //设置当前属性为默认值
  400. customMenu.SetMenuBinding(7, AnnotDefaultValue_MenuCommand);
  401. return popMenu;
  402. }
  403. //形状
  404. private ContextMenu SelectShapeAnnotMenu(object sender)
  405. {
  406. var popMenu = App.Current.FindResource("ShapeAnnotContextMenu") as ContextMenu;
  407. CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
  408. //复制
  409. customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
  410. //剪切
  411. customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
  412. //粘贴
  413. customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
  414. //删除
  415. customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
  416. //颜色
  417. customMenu.SetMenuBinding(4, AnnotColorPalette_MenuCommand);
  418. //线段样式
  419. bool IsSolid = true;
  420. if (sender as SquareAnnotArgs != null)
  421. {
  422. IsSolid = AnnotPropertyPanel.IsSolidStyle((sender as SquareAnnotArgs).LineDash);
  423. }
  424. else if(sender as CircleAnnotArgs != null)
  425. {
  426. IsSolid = AnnotPropertyPanel.IsSolidStyle((sender as CircleAnnotArgs).LineDash);
  427. }
  428. else if(sender as LineAnnotArgs != null)
  429. {
  430. IsSolid = AnnotPropertyPanel.IsSolidStyle((sender as LineAnnotArgs).LineDash);
  431. }
  432. customMenu.SetSubMenuBinding(5, 0, ShapeLineStyle_MenuCommand, null, IsSolid);
  433. customMenu.SetSubMenuBinding(5, 1, ShapeLineStyle_MenuCommand, null, !IsSolid);
  434. //线段方向
  435. if(sender as LineAnnotArgs != null)
  436. {
  437. customMenu.SetSubMenuBinding(6, 0, ShapeLineDirect_MenuCommand ,null, true);//暂无,待确认
  438. customMenu.SetSubMenuBinding(6, 1, ShapeLineDirect_MenuCommand ,null, true);//
  439. customMenu.SetVisibilityProperty(6, true);
  440. }
  441. else
  442. {
  443. customMenu.SetVisibilityProperty(6,false);
  444. }
  445. //添加笔记
  446. customMenu.SetMenuBinding(7, AnnotAddNoteText_MenuCommand);
  447. //设置当前属性为默认值
  448. customMenu.SetMenuBinding(8, AnnotDefaultValue_MenuCommand);
  449. return popMenu;
  450. }
  451. //链接
  452. private ContextMenu SelectLinkAnnotMenu(object sender)
  453. {
  454. var popMenu = App.Current.FindResource("LinkAnnotContextMenu") as ContextMenu;
  455. CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
  456. //复制
  457. customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
  458. //剪切
  459. customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
  460. //粘贴
  461. customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
  462. //删除
  463. customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
  464. return popMenu;
  465. }
  466. //图章、签名
  467. private ContextMenu SelectStampAnnotMenu(object sender)
  468. {
  469. var popMenu = App.Current.FindResource("StampAnnotContextMenu") as ContextMenu;
  470. CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
  471. //复制
  472. customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
  473. //剪切
  474. customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
  475. //粘贴
  476. customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
  477. //删除
  478. customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
  479. //导出
  480. customMenu.SetSubMenuBinding(4, 0, StampExportPicture_MenuCommand);//
  481. customMenu.SetSubMenuBinding(4, 1, StampExportPicture_MenuCommand);//
  482. customMenu.SetSubMenuBinding(4, 2, StampExportPicture_MenuCommand);//
  483. //添加笔记
  484. customMenu.SetMenuBinding(5, AnnotAddNoteText_MenuCommand);
  485. return popMenu;
  486. }
  487. //多选注释
  488. private ContextMenu SelectMultiAnnotMenu(object sender, bool isHightAnnot)
  489. {
  490. var popMenu = App.Current.FindResource("MultiSelectAnnotContextMenu") as ContextMenu;
  491. CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
  492. if (isHightAnnot)
  493. {
  494. customMenu.SetVisibilityProperty(0, false);
  495. customMenu.SetVisibilityProperty(1, false);
  496. }
  497. else
  498. {
  499. //复制
  500. customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
  501. //剪切
  502. customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
  503. }
  504. //删除
  505. customMenu.SetMenuBinding(2, ApplicationCommands.Delete);
  506. return popMenu;
  507. }
  508. #endregion 注释-右键菜单
  509. }
  510. }