AnnotToolContentViewModel.Layout.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  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, 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 (annots != 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, itemAnnot.GetAnnotAttrib());
  52. propertyPanel.AnnotEvents.Add(eventitem);
  53. }
  54. }
  55. propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annots[0], annots[0].GetAnnotAttrib());
  56. if (annots[0] is LinkAnnotArgs && annotAttribEvent != null)
  57. {
  58. propertyPanel.AnnotEvent = annotAttribEvent;
  59. }
  60. }
  61. propertyPanel.SetIsTextFill(false);
  62. if (string.IsNullOrEmpty(viewContent) == false)
  63. {
  64. viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
  65. }
  66. }
  67. /// <summary>
  68. /// 展开显示属性面板
  69. /// </summary>
  70. private void ShowPropertyPanel(bool show = true)
  71. {
  72. viewContentViewModel.IsPropertyOpen = show;
  73. }
  74. #endregion 属性面板
  75. #region 阅读页 - 右键菜单
  76. private ContextMenu ViewerContextMenu(object sender)
  77. {
  78. ContextMenu contextMenu = App.Current.FindResource("ViewerContextMenu") as ContextMenu;
  79. //contextMenu.Loaded += ContextMenu_Loaded;
  80. ViewerContextMenu_Loaded(contextMenu, sender);
  81. return contextMenu;
  82. }
  83. private void ViewerContextMenu_Loaded(object sender, object e)
  84. {
  85. ContextMenu contextMenu = sender as ContextMenu;
  86. if (contextMenu.Items.Count > 0)
  87. {
  88. int index = PDFViewer.CurrentIndex;
  89. //检测是否已存在相同数据
  90. CPDFBookmark list = PDFViewer.Document.GetBookmarkList().FirstOrDefault(q => q.PageIndex == index);
  91. if (list != null)
  92. {
  93. isAddBookMark = false;
  94. }
  95. else
  96. {
  97. isAddBookMark = true;
  98. }
  99. foreach (var item in contextMenu.Items)
  100. {
  101. if (item is MenuItem menuItem1)
  102. {
  103. //if (menuItem1.Tag.ToString() == "DisplayAnnot" || menuItem1.Tag.ToString() == "HiddenAnnot")
  104. //{
  105. // SetMenuItemVisibility(menuItem1, "DisplayAnnot", "HiddenAnnot", isHiddenAnnot);
  106. //}
  107. switch (menuItem1.Tag.ToString())
  108. {
  109. case "Paste":
  110. //粘贴
  111. //if (!ApplicationCommands.Paste.CanExecute(null, (UIElement)sender))
  112. //{
  113. // menuItem1.IsEnabled = false;
  114. // menuItem1.Opacity = 0.5;
  115. //}
  116. //else
  117. //{
  118. // menuItem1.IsEnabled = true;
  119. // menuItem1.Opacity = 1;
  120. //}
  121. menuItem1.CommandTarget = (UIElement)e;
  122. menuItem1.Command = ApplicationCommands.Paste;
  123. break;
  124. case "AddAnnotation":
  125. if (menuItem1.Items.Count > 0)
  126. {
  127. SetAddAnnotation(menuItem1.Items);
  128. }
  129. break;
  130. case "HiddenAnnot":
  131. menuItem1.Click -= HiddenAnnot_Click;
  132. menuItem1.Click += HiddenAnnot_Click;
  133. SetMenuItemVisibility(menuItem1, "DisplayAnnot", "HiddenAnnot", isHiddenAnnot);
  134. break;
  135. case "DisplayAnnot":
  136. menuItem1.Click -= DisplayAnnot_Click;
  137. menuItem1.Click += DisplayAnnot_Click;
  138. SetMenuItemVisibility(menuItem1, "DisplayAnnot", "HiddenAnnot", isHiddenAnnot);
  139. break;
  140. case "AddBookMark":
  141. //menuItem1.Click -= AddBookMark_Click;
  142. //menuItem1.Click += AddBookMark_Click;
  143. menuItem1.Command = AddBookMarkCommand;
  144. SetMenuItemVisibility(menuItem1, "DelBookMark", "AddBookMark", isAddBookMark);
  145. break;
  146. case "DelBookMark":
  147. menuItem1.Click -= DelBookMark_Click;
  148. menuItem1.Click += DelBookMark_Click;
  149. SetMenuItemVisibility(menuItem1, "DelBookMark", "AddBookMark", isAddBookMark);
  150. break;
  151. case "ToolMode":
  152. if (menuItem1.Items.Count > 0)
  153. {
  154. SetToolMode(menuItem1.Items);
  155. }
  156. break;
  157. case "ReadModel":
  158. SetMenuItemVisibility(menuItem1, "ReadModel", "UnReadModel", viewContentViewModel.mainViewModel.IsBookMode);
  159. menuItem1.Click -= ReadModel_Click;
  160. menuItem1.Click += ReadModel_Click;
  161. break;
  162. case "UnReadModel":
  163. SetMenuItemVisibility(menuItem1, "ReadModel", "UnReadModel", viewContentViewModel.mainViewModel.IsBookMode);
  164. menuItem1.Click -= UnReadModel_Click;
  165. menuItem1.Click += UnReadModel_Click;
  166. break;
  167. case "ViewZoom":
  168. if (menuItem1.Items.Count > 0)
  169. {
  170. ViewZoom(menuItem1.Items);
  171. }
  172. break;
  173. case "PageDisplay":
  174. if (menuItem1.Items.Count > 0)
  175. {
  176. PageDisplay(menuItem1.Items);
  177. }
  178. break;
  179. case "Select":
  180. menuItem1.Click -= Select_Click;
  181. menuItem1.Click += Select_Click;
  182. break;
  183. case "Print":
  184. menuItem1.Command = viewContentViewModel.PrintCommand;
  185. break;
  186. }
  187. }
  188. }
  189. }
  190. }
  191. private void SetMenuItemVisibility(MenuItem menuItem1, string right, string deny, bool flag)
  192. {
  193. if (menuItem1.Tag.ToString() == right && flag)
  194. {
  195. menuItem1.Visibility = Visibility.Collapsed;
  196. }
  197. if (menuItem1.Tag.ToString() == right && flag == false)
  198. {
  199. menuItem1.Visibility = Visibility.Visible;
  200. }
  201. if (menuItem1.Tag.ToString() == deny && flag == false)
  202. {
  203. menuItem1.Visibility = Visibility.Collapsed;
  204. }
  205. if (menuItem1.Tag.ToString() == deny && flag)
  206. {
  207. menuItem1.Visibility = Visibility.Visible;
  208. }
  209. }
  210. private ContextMenu NoneSelectAnnotContextMenu(object sender, AnnotCommandArgs annotCommand)
  211. {
  212. ContextMenu popMenu = new ContextMenu();
  213. popMenu.FontSize = 14;
  214. MenuItem menuItem = new MenuItem();
  215. menuItem = new MenuItem();
  216. menuItem.CommandTarget = (UIElement)sender;
  217. menuItem.Command = ApplicationCommands.Copy;
  218. popMenu.Items.Add(menuItem);
  219. menuItem = new MenuItem();
  220. menuItem.CommandTarget = (UIElement)sender;
  221. menuItem.Command = ApplicationCommands.Paste;
  222. popMenu.Items.Add(menuItem);
  223. Separator separator = null;
  224. if (annotCommand.CommandTarget == TargetType.ImageSelection)
  225. {
  226. separator = SetSeparator();
  227. popMenu.Items.Add(separator);
  228. SetSelectTextOrImageMenuItem("导出图片...", "ExportPicture", annotCommand, out menuItem);
  229. popMenu.Items.Add(menuItem);
  230. }
  231. else if (annotCommand.CommandTarget == TargetType.Annot)
  232. {
  233. separator = SetSeparator();
  234. popMenu.Items.Add(separator);
  235. SetSelectTextOrImageMenuItem("高亮", "HighLight", annotCommand, out menuItem);
  236. popMenu.Items.Add(menuItem);
  237. SetSelectTextOrImageMenuItem("下划线", "UnderLine", annotCommand, out menuItem);
  238. popMenu.Items.Add(menuItem);
  239. SetSelectTextOrImageMenuItem("删除线", "Strikeout", annotCommand, out menuItem);
  240. popMenu.Items.Add(menuItem);
  241. }
  242. separator = SetSeparator();
  243. popMenu.Items.Add(separator);
  244. SetSelectTextOrImageMenuItem("文本", "Freetext", annotCommand, out menuItem);
  245. popMenu.Items.Add(menuItem);
  246. SetSelectTextOrImageMenuItem("便签", "StickyNote", annotCommand, out menuItem);
  247. popMenu.Items.Add(menuItem);
  248. separator = SetSeparator();
  249. popMenu.Items.Add(separator);
  250. SetSelectTextOrImageMenuItem("矩形", "Rect", annotCommand, out menuItem);
  251. popMenu.Items.Add(menuItem);
  252. SetSelectTextOrImageMenuItem("椭圆形", "Circle", annotCommand, out menuItem);
  253. popMenu.Items.Add(menuItem);
  254. SetSelectTextOrImageMenuItem("直线", "Line", annotCommand, out menuItem);
  255. popMenu.Items.Add(menuItem);
  256. separator = SetSeparator();
  257. popMenu.Items.Add(separator);
  258. SetSelectTextOrImageMenuItem("添加链接", "Link", annotCommand, out menuItem);
  259. popMenu.Items.Add(menuItem);
  260. SetSelectTextOrImageMenuItem("添加大纲", "OutLine", annotCommand, out menuItem);
  261. popMenu.Items.Add(menuItem);
  262. return popMenu;
  263. }
  264. private void SetSelectTextOrImageMenuItem(string header, string tag, AnnotCommandArgs annotCommand, out MenuItem menuItem)
  265. {
  266. menuItem = new MenuItem();
  267. menuItem.Header = header;
  268. menuItem.Tag = tag;
  269. menuItem.Click -= AnnotToolMenu_Click;
  270. menuItem.Click += AnnotToolMenu_Click;
  271. menuItem.CommandParameter = annotCommand;
  272. }
  273. private Separator SetSeparator()
  274. {
  275. Separator separator = new Separator
  276. {
  277. Height = 1,
  278. BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#33000000")),
  279. BorderThickness = new Thickness(1),
  280. Style = (Style)App.Current.FindResource(System.Windows.Controls.ToolBar.SeparatorStyleKey)
  281. };
  282. return separator;
  283. }
  284. #endregion 阅读页 - 右键菜单
  285. #region 注释-右键菜单
  286. /// <summary>
  287. /// 高亮注释,右键菜单
  288. /// </summary>
  289. private void InitSelectHightAnnotMenu()
  290. {
  291. var popMenu = new ContextMenu();
  292. PopMenu pop = new PopMenu(popMenu);
  293. ColorContent colorContent = new ColorContent();
  294. colorContent.Name = "hightcolor";
  295. colorContent.SelectedColorHandler -= colorContent_SelectedColorHandler;
  296. colorContent.SelectedColorHandler += colorContent_SelectedColorHandler;
  297. colorContent.VerticalAlignment = VerticalAlignment.Top;
  298. colorContent.Height = 60;
  299. var menuItem = new MenuItem();
  300. menuItem.Name = "hightColor";
  301. menuItem.Height = colorContent.Height;
  302. menuItem.Header = colorContent;
  303. var hightColorStyle = App.Current.FindResource("UIElementMenuItem") as Style;
  304. if (hightColorStyle != null)
  305. menuItem.Style = hightColorStyle;
  306. pop.AddItem(menuItem);
  307. pop.AddItem(GetSeparator());
  308. menuItem = new MenuItem();
  309. menuItem.Name = "hightCopyText";
  310. menuItem.Header = "复制文本";
  311. pop.BindingEvent(pop.AddItem(menuItem), HightAnnotCopyText_MenuCommand);
  312. menuItem = new MenuItem();
  313. menuItem.Name = "hightdelete";
  314. menuItem.Header = "删除";
  315. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  316. pop.AddItem(GetSeparator());
  317. menuItem = new MenuItem();
  318. menuItem.Name = "hightAddNote";
  319. menuItem.Header = "添加笔记";
  320. pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand);
  321. menuItem = new MenuItem();
  322. menuItem.Name = "hightdefault";
  323. menuItem.Header = "设置当前属性为默认值";
  324. pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
  325. HightAnnotPopMenu = pop;
  326. }
  327. private Separator GetSeparator()
  328. {
  329. Separator separator = new Separator();
  330. separator.Height = 1;
  331. separator.BorderBrush = new SolidColorBrush(Color.FromArgb(0x33, 0x00, 0x00, 0x00));
  332. separator.BorderThickness = new Thickness(1);
  333. return separator;
  334. }
  335. private void colorContent_SelectedColorHandler(object sender, Color e)
  336. {
  337. if (e == null) return;
  338. var annot = (sender as FrameworkElement).DataContext as AnnotHandlerEventArgs;
  339. if (annot != null)
  340. {
  341. var test = annot as TextHighlightAnnotArgs;
  342. if (test != null)
  343. {
  344. var anvent = AnnotAttribEvent.GetAnnotAttribEvent(test, test.GetAnnotAttrib());
  345. anvent.UpdateAttrib(AnnotAttrib.Color, e);
  346. anvent.UpdateAnnot();
  347. }
  348. }
  349. }
  350. /// <summary>
  351. /// 手绘
  352. /// </summary>
  353. private void InitSelectFreeHandAnnotMenu()
  354. {
  355. var popMenu = new ContextMenu();
  356. PopMenu pop = new PopMenu(popMenu);
  357. var menuItem = new MenuItem();
  358. menuItem.Name = "FreeHandCopy";
  359. menuItem.Header = "复制";
  360. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  361. menuItem = new MenuItem();
  362. menuItem.Name = "FreeHandCut";
  363. menuItem.Header = "剪切";
  364. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  365. menuItem = new MenuItem();
  366. menuItem.Name = "FreeHandPaste";
  367. menuItem.Header = "粘贴";
  368. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
  369. menuItem = new MenuItem();
  370. menuItem.Name = "FreeHandDelete";
  371. menuItem.Header = "删除";
  372. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  373. pop.AddItem(GetSeparator());
  374. menuItem = new MenuItem();
  375. menuItem.Name = "FreeHandColor";
  376. menuItem.Header = "颜色...";
  377. pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
  378. menuItem = new MenuItem();
  379. menuItem.Name = "FreeHandLineStyle";
  380. menuItem.Header = "线段样式";
  381. pop.AddItem(menuItem);
  382. RadioButton radioButton = new RadioButton();
  383. radioButton.Name = "FreeHandSolid";
  384. radioButton.Content = "实线";
  385. radioButton.GroupName = "LineStyle";
  386. radioButton.Tag = "Solid";
  387. pop.BindingEvent(pop.AddChild("FreeHandLineStyle", radioButton), FreeHandLineStyle_MenuCommand);
  388. radioButton = new RadioButton();
  389. radioButton.Name = "FreeHandDash";
  390. radioButton.Content = "虚线";
  391. radioButton.GroupName = "LineStyle";
  392. radioButton.Tag = "Dash";
  393. pop.BindingEvent(pop.AddChild("FreeHandLineStyle", radioButton), FreeHandLineStyle_MenuCommand);
  394. menuItem = new MenuItem();
  395. menuItem.Name = "FreeHandAddNote";
  396. menuItem.Header = "添加笔记";
  397. pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand);
  398. menuItem = new MenuItem();
  399. menuItem.Name = "FreeHandDefault";
  400. menuItem.Header = "设置当前属性为默认值";
  401. pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
  402. FreeHandAnnotPopMenu = pop;
  403. }
  404. /// <summary>
  405. /// 文本
  406. /// </summary>
  407. private void InitSelectFreeTextAnnotMenu()
  408. {
  409. var popMenu = new ContextMenu();
  410. PopMenu pop = new PopMenu(popMenu);
  411. var menuItem = new MenuItem();
  412. menuItem.Name = "FreeTextCopy";
  413. menuItem.Header = "复制";
  414. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  415. menuItem = new MenuItem();
  416. menuItem.Name = "FreeTextCut";
  417. menuItem.Header = "剪切";
  418. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  419. menuItem = new MenuItem();
  420. menuItem.Name = "FreeTextPaste";
  421. menuItem.Header = "粘贴";
  422. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
  423. menuItem = new MenuItem();
  424. menuItem.Name = "FreeTextDelete";
  425. menuItem.Header = "删除";
  426. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  427. pop.AddItem(GetSeparator());
  428. menuItem = new MenuItem();
  429. menuItem.Name = "FreeTextColor";
  430. menuItem.Header = "颜色...";
  431. pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
  432. menuItem = new MenuItem();
  433. menuItem.Name = "FreeTextFontFamily";
  434. menuItem.Header = "字体";
  435. pop.AddItem(menuItem);
  436. menuItem = new MenuItem();
  437. menuItem.Name = "FreeTextArial";
  438. menuItem.Header = "楷体";
  439. menuItem.Tag = "Arial";
  440. pop.BindingEvent(pop.AddChild("FreeTextFontFamily", menuItem), FreeTextFontFamily_MenuCommand);
  441. menuItem = new MenuItem();
  442. menuItem.Name = "FreeTextCourier";
  443. menuItem.Header = "Courier";
  444. menuItem.Tag = "Courier";
  445. pop.BindingEvent(pop.AddChild("FreeTextFontFamily", menuItem), FreeTextFontFamily_MenuCommand);
  446. menuItem = new MenuItem();
  447. menuItem.Name = "FreeTextTimesRoman";
  448. menuItem.Header = "Times New Roman";
  449. menuItem.Tag = /*"Times New Roman"*/"Times";
  450. pop.BindingEvent(pop.AddChild("FreeTextFontFamily", menuItem), FreeTextFontFamily_MenuCommand);
  451. menuItem = new MenuItem();
  452. menuItem.Name = "FreeTextAglin";
  453. menuItem.Header = "文本对齐";
  454. pop.AddItem(menuItem);
  455. menuItem = new MenuItem();
  456. menuItem.Name = "FreeTextAglinLeft";
  457. menuItem.Header = "左对齐";
  458. menuItem.Tag = "Left";
  459. pop.BindingEvent(pop.AddChild("FreeTextAglin", menuItem), FreeTextAglin_MenuCommand);
  460. menuItem = new MenuItem();
  461. menuItem.Name = "FreeTextAglinCenter";
  462. menuItem.Header = "居中对齐";
  463. menuItem.Tag = "Center";
  464. pop.BindingEvent(pop.AddChild("FreeTextAglin", menuItem), FreeTextAglin_MenuCommand);
  465. menuItem = new MenuItem();
  466. menuItem.Name = "FreeTextAglinRight";
  467. menuItem.Header = "右对齐";
  468. menuItem.Tag = "Right";
  469. pop.BindingEvent(pop.AddChild("FreeTextAglin", menuItem), FreeTextAglin_MenuCommand);
  470. menuItem = new MenuItem();
  471. menuItem.Name = "FreeHandDefault";
  472. menuItem.Header = "设置当前属性为默认值";
  473. pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
  474. FreeTextAnnotPopMenu = pop;
  475. }
  476. /// <summary>
  477. /// 便签
  478. /// </summary>
  479. private void InitSelectStrickNoteAnnotMenu()
  480. {
  481. var popMenu = new ContextMenu();
  482. PopMenu pop = new PopMenu(popMenu);
  483. var menuItem = new MenuItem();
  484. menuItem.Name = "StrickNoteCopy";
  485. menuItem.Header = "复制";
  486. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  487. menuItem = new MenuItem();
  488. menuItem.Name = "StrickNoteCut";
  489. menuItem.Header = "剪切";
  490. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  491. menuItem = new MenuItem();
  492. menuItem.Name = "StrickNotePaste";
  493. menuItem.Header = "粘贴";
  494. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
  495. menuItem = new MenuItem();
  496. menuItem.Name = "StrickNoteDelete";
  497. menuItem.Header = "删除";
  498. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  499. pop.AddItem(GetSeparator());
  500. menuItem = new MenuItem();
  501. menuItem.Name = "StrickNoteColor";
  502. menuItem.Header = "颜色...";
  503. pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
  504. menuItem = new MenuItem();
  505. menuItem.Name = "StrickNoteEdit";
  506. menuItem.Header = "编辑便签";
  507. pop.BindingEvent(pop.AddItem(menuItem), StrikeNoteEditStrike_MenuCommand);
  508. menuItem = new MenuItem();
  509. menuItem.Name = "StrickNoteDefault";
  510. menuItem.Header = "设置当前属性为默认值";
  511. pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
  512. StrickNoteAnnotPopMenu = pop;
  513. }
  514. /// <summary>
  515. /// 形状
  516. /// </summary>
  517. private void InitSelectShapeAnnotMenu()
  518. {
  519. var popMenu = new ContextMenu();
  520. PopMenu pop = new PopMenu(popMenu);
  521. var menuItem = new MenuItem();
  522. menuItem.Name = "ShapeCopy";
  523. menuItem.Header = "复制";
  524. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  525. menuItem = new MenuItem();
  526. menuItem.Name = "ShapeCut";
  527. menuItem.Header = "剪切";
  528. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  529. menuItem = new MenuItem();
  530. menuItem.Name = "ShapePaste";
  531. menuItem.Header = "粘贴";
  532. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
  533. menuItem = new MenuItem();
  534. menuItem.Name = "ShapeDelete";
  535. menuItem.Header = "删除";
  536. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  537. pop.AddItem(GetSeparator());
  538. menuItem = new MenuItem();
  539. menuItem.Name = "ShapeColor";
  540. menuItem.Header = "颜色...";
  541. pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
  542. menuItem = new MenuItem();
  543. menuItem.Name = "ShapeLineStyle";
  544. menuItem.Header = "线段样式";
  545. pop.AddItem(menuItem);
  546. RadioButton radioButton = new RadioButton();
  547. radioButton.Name = "ShapeSolid";
  548. radioButton.Content = "实线";
  549. radioButton.GroupName = "LineStyle";
  550. radioButton.Tag = "Solid";
  551. pop.BindingEvent(pop.AddChild("ShapeLineStyle", radioButton), ShapeLineStyle_MenuCommand);
  552. radioButton = new RadioButton();
  553. radioButton.Name = "ShapeDash";
  554. radioButton.Content = "虚线";
  555. radioButton.GroupName = "LineStyle";
  556. radioButton.Tag = "Dash";
  557. pop.BindingEvent(pop.AddChild("ShapeLineStyle", radioButton), ShapeLineStyle_MenuCommand);
  558. menuItem = new MenuItem();
  559. menuItem.Name = "ShapeDirect";
  560. menuItem.Header = "线段方向";
  561. pop.AddItem(menuItem);
  562. menuItem = new MenuItem();
  563. menuItem.Name = "ShapeVer";
  564. menuItem.Header = "垂直";
  565. menuItem.Tag = "Ver";
  566. pop.BindingEvent(pop.AddChild("ShapeDirect", menuItem), ShapeLineDirect_MenuCommand);
  567. menuItem = new MenuItem();
  568. menuItem.Name = "ShapeHor";
  569. menuItem.Header = "横向";
  570. menuItem.Tag = "Hor";
  571. pop.BindingEvent(pop.AddChild("ShapeDirect", menuItem), ShapeLineDirect_MenuCommand);
  572. menuItem = new MenuItem();
  573. menuItem.Name = "ShapeNoteText";
  574. menuItem.Header = "添加笔记";
  575. pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand);
  576. menuItem = new MenuItem();
  577. menuItem.Name = "ShapeDefault";
  578. menuItem.Header = "设置当前属性为默认值";
  579. pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
  580. ShapeAnnotPopMenu = pop;
  581. }
  582. /// <summary>
  583. /// 链接
  584. /// </summary>
  585. private void InitSelectLinkAnnotMenu()
  586. {
  587. var popMenu = new ContextMenu();
  588. PopMenu pop = new PopMenu(popMenu);
  589. var menuItem = new MenuItem();
  590. menuItem.Name = "LinkCopy";
  591. menuItem.Header = "复制";
  592. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  593. menuItem = new MenuItem();
  594. menuItem.Name = "LinkCut";
  595. menuItem.Header = "剪切";
  596. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  597. menuItem = new MenuItem();
  598. menuItem.Name = "LinkPaste";
  599. menuItem.Header = "粘贴";
  600. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
  601. menuItem = new MenuItem();
  602. menuItem.Name = "LinkDelete";
  603. menuItem.Header = "删除";
  604. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  605. LinkAnnotPopMenu = pop;
  606. }
  607. /// <summary>
  608. /// 图章、签名
  609. /// </summary>
  610. private void InitSelectStampAnnotMenu()
  611. {
  612. var popMenu = new ContextMenu();
  613. PopMenu pop = new PopMenu(popMenu);
  614. var menuItem = new MenuItem();
  615. menuItem.Name = "StampCopy";
  616. menuItem.Header = "复制";
  617. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  618. menuItem = new MenuItem();
  619. menuItem.Name = "StampCut";
  620. menuItem.Header = "剪切";
  621. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  622. menuItem = new MenuItem();
  623. menuItem.Name = "StampPaste";
  624. menuItem.Header = "粘贴";
  625. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
  626. menuItem = new MenuItem();
  627. menuItem.Name = "StampDelete";
  628. menuItem.Header = "删除";
  629. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  630. pop.AddItem(GetSeparator());
  631. menuItem = new MenuItem();
  632. menuItem.Name = "StampExportPicture";
  633. menuItem.Header = "导出";
  634. pop.AddItem(menuItem);
  635. //已跟设计确认,暂时不需要PNG格式
  636. //menuItem = new MenuItem();
  637. //menuItem.Name = "StampExportPNG";
  638. //menuItem.Header = "PNG";
  639. //menuItem.Tag = "PNG";
  640. //pop.BindingEvent(pop.AddChild("StampExportPicture", menuItem), StampExportPicture_MenuCommand);
  641. menuItem = new MenuItem();
  642. menuItem.Name = "StampExportPNG";
  643. menuItem.Header = "JPG";
  644. menuItem.Tag = "JPG";
  645. pop.BindingEvent(pop.AddChild("StampExportPicture", menuItem), StampExportPicture_MenuCommand);
  646. menuItem = new MenuItem();
  647. menuItem.Name = "StampExportPNG";
  648. menuItem.Header = "PDF";
  649. menuItem.Tag = "PDF";
  650. pop.BindingEvent(pop.AddChild("StampExportPicture", menuItem), StampExportPicture_MenuCommand);
  651. menuItem = new MenuItem();
  652. menuItem.Name = "StampAddNote";
  653. menuItem.Header = "添加笔记";
  654. pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand);
  655. StampAnnotPopMenu = pop;
  656. }
  657. /// <summary>
  658. /// 多选注释
  659. /// </summary>
  660. private void InitSelectMultiAnnotMenu()
  661. {
  662. var popMenu = new ContextMenu();
  663. PopMenu pop = new PopMenu(popMenu);
  664. var menuItem = new MenuItem();
  665. menuItem.Name = "MultiCopy";
  666. menuItem.Header = "复制";
  667. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  668. menuItem = new MenuItem();
  669. menuItem.Name = "MultiCut";
  670. menuItem.Header = "剪切";
  671. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  672. menuItem = new MenuItem();
  673. menuItem.Name = "MultiDelete";
  674. menuItem.Header = "删除";
  675. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  676. MultiAnnotPopMenu = pop;
  677. }
  678. #endregion 注释-右键菜单
  679. }
  680. }