AnnotToolContentViewModel.Layout.cs 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160
  1. using ComPDFKit.PDFDocument;
  2. using ComPDFKitViewer;
  3. using ComPDFKitViewer.AnnotEvent;
  4. using ComPDFKitViewer.PdfViewer;
  5. using PDF_Master.CustomControl;
  6. using PDF_Master.CustomControl.CompositeControl;
  7. using PDF_Master.Helper;
  8. using PDF_Master.Model;
  9. using PDF_Master.Model.PropertyPanel.AnnotPanel;
  10. using PDF_Master.ViewModels.Dialog.ChatGPTAIDialogs;
  11. using PDF_Master.Views.Dialog.ChatGPTAIDialogs;
  12. using Prism.Commands;
  13. using Prism.Mvvm;
  14. using Prism.Regions;
  15. using Prism.Services.Dialogs;
  16. using System;
  17. using System.Collections.Generic;
  18. using System.ComponentModel;
  19. using System.IO;
  20. using System.Linq;
  21. using System.Text;
  22. using System.Threading.Tasks;
  23. using System.Windows;
  24. using System.Windows.Controls;
  25. using System.Windows.Input;
  26. using System.Windows.Markup;
  27. using System.Windows.Media;
  28. using System.Windows.Media.Imaging;
  29. using System.Windows.Shapes;
  30. using WIA;
  31. using static Dropbox.Api.TeamLog.AdminAlertSeverityEnum;
  32. using MenuItem = System.Windows.Controls.MenuItem;
  33. namespace PDF_Master.ViewModels.Tools
  34. {
  35. //文件说明:与布局相关的代码逻辑:菜单、属性面板
  36. public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
  37. {
  38. #region 属性面板
  39. /// <summary>
  40. /// 导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线
  41. /// </summary>
  42. /// <param name="viewContent">对应的注释面板</param>
  43. /// <param name="toolTag">导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线</param>
  44. /// <param name="annot">注释</param>
  45. /// <param name="annotAttribsList">更改注释属性的键值对,更改值后会自动记录undoRedo容器里</param>
  46. private void AddToPropertyPanel(string viewContent, string toolTag = null, List<AnnotHandlerEventArgs> annots = null, AnnotAttribEvent annotAttribEvent = null)
  47. {
  48. if (annots != null)
  49. {
  50. PropertyPanel.annotlists = annots;
  51. PropertyPanel.annot = annots[0];
  52. }
  53. else
  54. {
  55. PropertyPanel.annotlists = null;
  56. PropertyPanel.annot = null;
  57. }
  58. PropertyPanel.AnnotEvents = null;
  59. PropertyPanel.AnnotEvent = null;
  60. if (annots != null)
  61. {
  62. if (annots.Count > 1)
  63. {
  64. if (PropertyPanel.AnnotEvents == null)
  65. {
  66. PropertyPanel.AnnotEvents = new List<AnnotAttribEvent>();
  67. }
  68. PropertyPanel.AnnotEvents.Clear();
  69. foreach (var itemAnnot in annots)
  70. {
  71. var eventitem = AnnotAttribEvent.GetAnnotAttribEvent(itemAnnot, itemAnnot.GetAnnotAttrib(), PDFViewer);
  72. //eventitem.ClearChangeAttribute();
  73. PropertyPanel.AnnotEvents.Add(eventitem);
  74. }
  75. }
  76. PropertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annots[0], annots[0].GetAnnotAttrib(), PDFViewer);
  77. //propertyPanel.AnnotEvent.ClearChangeAttribute();
  78. if (annots[0] is LinkAnnotArgs && annotAttribEvent != null)
  79. {
  80. PropertyPanel.AnnotEvent = annotAttribEvent;
  81. }
  82. }
  83. PropertyPanel.SetIsTextFill(false);
  84. if (string.IsNullOrEmpty(viewContent) == false)
  85. {
  86. ViewContentViewModel.SelectedPrpoertyPanel(viewContent, PropertyPanel);
  87. }
  88. }
  89. /// <summary>
  90. /// 展开显示属性面板
  91. /// </summary>
  92. private void ShowPropertyPanel(bool show = true)
  93. {
  94. ViewContentViewModel.IsPropertyOpen = show;
  95. }
  96. #endregion 属性面板
  97. #region 阅读页 - 右键菜单
  98. #region 右击菜单文案
  99. /// <summary>
  100. /// 右键菜单文案
  101. /// </summary>
  102. ///
  103. public string T_RightMenuSelectionCopy = App.MainPageLoader.GetString("ViewRightMenuSelection_Copy");
  104. public string T_RightMenuSelectionPaste = App.MainPageLoader.GetString("ViewRightMenuSelection_Paste");
  105. public string T_RightMenuSelectionHighlight = App.MainPageLoader.GetString("ViewRightMenuSelection_Highlight");
  106. public string T_RightMenuSelectionUnderline = App.MainPageLoader.GetString("ViewRightMenuSelection_Underline");
  107. public string T_RightMenuSelectionStrikethrough = App.MainPageLoader.GetString("ViewRightMenuSelection_Strikethrough");
  108. public string T_RightMenuSelectionText = App.MainPageLoader.GetString("ViewRightMenuSelection_Text");
  109. public string T_RightMenuSelectionNote = App.MainPageLoader.GetString("ViewRightMenuSelection_Note");
  110. public string T_RightMenuSelectionRectangle = App.MainPageLoader.GetString("ViewRightMenuSelection_Rectangle");
  111. public string T_RightMenuSelectionOval = App.MainPageLoader.GetString("ViewRightMenuSelection_Oval");
  112. public string T_RightMenuSelectionStraightLine = App.MainPageLoader.GetString("ViewRightMenuSelection_StraightLine");
  113. public string T_RightMenuSelectionAddLink = App.MainPageLoader.GetString("ViewRightMenuSelection_AddLink");
  114. public string T_RightMenuSelectionAddOutline = App.MainPageLoader.GetString("ViewRightMenuSelection_AddOutline");
  115. public string T_RightMenuSelectionExtractImage = App.MainPageLoader.GetString("ViewRightMenuSelection_ExtractImage");
  116. #endregion 右击菜单文案
  117. private ContextMenu ViewerContextMenu(object sender)
  118. {
  119. //ContextMenu contextMenu = CommonHelper.DeepClone(App.Current.FindResource("ViewerContextMenu") as ContextMenu);
  120. string xaml = XamlWriter.Save(App.Current.FindResource("ViewerContextMenu") as ContextMenu);
  121. ContextMenu contextMenu = XamlReader.Parse(xaml) as ContextMenu;
  122. //contextMenu.Loaded += ContextMenu_Loaded;
  123. ViewerContextMenu_Loaded(contextMenu, sender);
  124. return contextMenu;
  125. }
  126. private void ViewerContextMenu_Loaded(object sender, object e)
  127. {
  128. ContextMenu contextMenu = sender as ContextMenu;
  129. contextMenu.DataContext = ViewContentViewModel;
  130. if (contextMenu.Items.Count > 0)
  131. {
  132. int index = PDFViewer.CurrentIndex;
  133. //检测是否已存在相同数据
  134. CPDFBookmark list = PDFViewer.Document.GetBookmarkList().FirstOrDefault(q => q.PageIndex == index);
  135. if (list != null)
  136. {
  137. isAddBookMark = false;
  138. }
  139. else
  140. {
  141. isAddBookMark = true;
  142. }
  143. var separator = contextMenu.Items[contextMenu.Items.Count - 3];
  144. InBookModeSetIsHidden(separator);
  145. foreach (var item in contextMenu.Items)
  146. {
  147. if (item is MenuItem menuItem1)
  148. {
  149. switch (menuItem1.Tag.ToString())
  150. {
  151. case "Paste":
  152. Separator separator1 = (Separator)contextMenu.Items[1];
  153. //粘贴
  154. if (!ApplicationCommands.Paste.CanExecute(null, (UIElement)e))
  155. {
  156. //menuItem1.IsEnabled = false;
  157. //menuItem1.Opacity = 0.5;
  158. menuItem1.Visibility = Visibility.Collapsed;
  159. separator1.Visibility = Visibility.Collapsed;
  160. }
  161. else
  162. {
  163. //menuItem1.IsEnabled = true;
  164. //menuItem1.Opacity = 1;
  165. menuItem1.Visibility = Visibility.Visible;
  166. separator1.Visibility = Visibility.Visible;
  167. }
  168. menuItem1.CommandTarget = (UIElement)e;
  169. menuItem1.Command = ApplicationCommands.Paste;
  170. break;
  171. case "AddAnnotation":
  172. if (menuItem1.Items.Count > 0)
  173. {
  174. SetAddAnnotation(menuItem1.Items);
  175. }
  176. break;
  177. case "HiddenAnnot":
  178. menuItem1.Click -= HiddenAnnot_Click;
  179. menuItem1.Click += HiddenAnnot_Click;
  180. SetMenuItemVisibility(menuItem1, "DisplayAnnot", "HiddenAnnot", BtnShowAnnotIsChecked);
  181. break;
  182. case "DisplayAnnot":
  183. menuItem1.Click -= DisplayAnnot_Click;
  184. menuItem1.Click += DisplayAnnot_Click;
  185. SetMenuItemVisibility(menuItem1, "DisplayAnnot", "HiddenAnnot", BtnShowAnnotIsChecked);
  186. break;
  187. case "AddBookMark":
  188. menuItem1.Command = AddBookMarkCommand;
  189. SetMenuItemVisibility(menuItem1, "DelBookMark", "AddBookMark", isAddBookMark);
  190. break;
  191. case "DelBookMark":
  192. menuItem1.Click -= DelBookMark_Click;
  193. menuItem1.Click += DelBookMark_Click;
  194. SetMenuItemVisibility(menuItem1, "DelBookMark", "AddBookMark", isAddBookMark);
  195. break;
  196. case "ToolMode":
  197. if (menuItem1.Items.Count > 0)
  198. {
  199. SetToolMode(menuItem1.Items);
  200. }
  201. break;
  202. case "ReadModel":
  203. SetMenuItemVisibility(menuItem1, "ReadModel", "UnReadModel", ViewContentViewModel.mainViewModel.IsBookMode);
  204. menuItem1.Click -= ReadModel_Click;
  205. menuItem1.Click += ReadModel_Click;
  206. break;
  207. case "UnReadModel":
  208. SetMenuItemVisibility(menuItem1, "ReadModel", "UnReadModel", ViewContentViewModel.mainViewModel.IsBookMode);
  209. menuItem1.Click -= UnReadModel_Click;
  210. menuItem1.Click += UnReadModel_Click;
  211. break;
  212. case "ViewZoom":
  213. InBookModeSetIsHidden(menuItem1);
  214. if (menuItem1.Items.Count > 0)
  215. {
  216. ViewZoom(menuItem1.Items);
  217. }
  218. break;
  219. case "PageDisplay":
  220. if (menuItem1.Items.Count > 0)
  221. {
  222. PageDisplay(menuItem1.Items);
  223. }
  224. break;
  225. case "Select":
  226. InBookModeSetIsHidden(menuItem1);
  227. menuItem1.Click -= Select_Click;
  228. menuItem1.Click += Select_Click;
  229. break;
  230. case "Print":
  231. InBookModeSetIsHidden(menuItem1);
  232. menuItem1.Command = ViewContentViewModel.PrintCommand;
  233. break;
  234. case "HighlightLinks":
  235. InBookModeSetIsHidden(menuItem1);
  236. if (OpenFileInfo != null)
  237. {
  238. menuItem1.IsChecked = OpenFileInfo.ShowHighLightLink;
  239. }
  240. menuItem1.Click -= HighlightLinks_Click;
  241. menuItem1.Click += HighlightLinks_Click;
  242. break;
  243. }
  244. }
  245. }
  246. }
  247. }
  248. private void HighlightLinks_Click(object sender, RoutedEventArgs e)
  249. {
  250. if (sender is MenuItem menuItem)
  251. {
  252. //if (OpenFileInfo != null)
  253. //{
  254. // menuItem.IsChecked = OpenFileInfo.ShowHighLightLink;
  255. //}
  256. if (menuItem.IsChecked)
  257. {
  258. PDFViewer.SetShowLink(true);
  259. }
  260. else
  261. {
  262. PDFViewer.SetShowLink(false);
  263. }
  264. if (OpenFileInfo != null)
  265. {
  266. OpenFileInfo.ShowHighLightLink = menuItem.IsChecked;
  267. }
  268. //if (menuItem.IsChecked == true)
  269. //{
  270. // menuItem.IsChecked = false;
  271. //}
  272. }
  273. }
  274. private void SetMenuItemVisibility(MenuItem menuItem1, string right, string deny, bool flag)
  275. {
  276. if (menuItem1.Tag.ToString() == right && flag)
  277. {
  278. menuItem1.Visibility = Visibility.Collapsed;
  279. }
  280. if (menuItem1.Tag.ToString() == right && flag == false)
  281. {
  282. menuItem1.Visibility = Visibility.Visible;
  283. }
  284. if (menuItem1.Tag.ToString() == deny && flag == false)
  285. {
  286. menuItem1.Visibility = Visibility.Collapsed;
  287. }
  288. if (menuItem1.Tag.ToString() == deny && flag)
  289. {
  290. menuItem1.Visibility = Visibility.Visible;
  291. }
  292. }
  293. private void CopyMenu_Click(object sender, RoutedEventArgs e)
  294. {
  295. //限制权限密码文档的图片复制
  296. if (!ViewContentViewModel.CheckPermissionBeforeOption())
  297. {
  298. return;
  299. }
  300. try
  301. {
  302. Clipboard.Clear();
  303. Dictionary<int, List<System.Drawing.Bitmap>> imageDict = PDFViewer?.GetSelectedImages();
  304. if (imageDict != null && imageDict.Count > 0)
  305. {
  306. foreach (int pageIndex in imageDict.Keys)
  307. {
  308. List<System.Drawing.Bitmap> imageList = imageDict[pageIndex];
  309. foreach (System.Drawing.Bitmap image in imageList)
  310. {
  311. MemoryStream ms = new MemoryStream();
  312. image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
  313. BitmapImage imageData = new BitmapImage();
  314. imageData.BeginInit();
  315. imageData.StreamSource = ms;
  316. imageData.CacheOption = BitmapCacheOption.OnLoad;
  317. imageData.EndInit();
  318. imageData.Freeze();
  319. Clipboard.SetImage(imageData);
  320. break;
  321. }
  322. }
  323. }
  324. }
  325. catch
  326. {
  327. }
  328. }
  329. /// <summary>
  330. /// 选择文本或者图像的右键菜单
  331. /// </summary>
  332. /// <param name="sender"></param>
  333. /// <param name="annotCommand"></param>
  334. /// <returns></returns>
  335. private ContextMenu SelectedTextOrImageContextMenu(object sender, AnnotCommandArgs annotCommand)
  336. {
  337. StrAnnotToolChecked = "";
  338. ContextMenu popMenu = new ContextMenu();
  339. popMenu.FontSize = 14;
  340. MenuItem menuItem = new MenuItem();
  341. menuItem = new MenuItem();
  342. menuItem.CommandTarget = (UIElement)sender;
  343. menuItem.Header = T_RightMenuSelectionCopy;
  344. menuItem.InputGestureText = "Ctrl+C";
  345. if (annotCommand.CommandTarget == TargetType.ImageSelection && PDFViewer.GetSelectImageCount() > 0)
  346. {
  347. menuItem.IsEnabled = true;
  348. PDFViewer.ClearCopyData();
  349. menuItem.Click -= CopyMenu_Click;
  350. menuItem.Click += CopyMenu_Click;
  351. }
  352. else
  353. {
  354. menuItem.Command = ApplicationCommands.Copy;
  355. }
  356. popMenu.Items.Add(menuItem);
  357. menuItem = new MenuItem();
  358. menuItem.Header = T_RightMenuSelectionPaste;
  359. if (!ApplicationCommands.Paste.CanExecute(null, (UIElement)sender))
  360. {
  361. //menuItem1.IsEnabled = false;
  362. //menuItem1.Opacity = 0.5;
  363. menuItem.Visibility = Visibility.Collapsed;
  364. }
  365. else
  366. {
  367. //menuItem1.IsEnabled = true;
  368. //menuItem1.Opacity = 1;
  369. menuItem.Visibility = Visibility.Visible;
  370. }
  371. menuItem.CommandTarget = (UIElement)sender;
  372. menuItem.Command = ApplicationCommands.Paste;
  373. popMenu.Items.Add(menuItem);
  374. Separator separator = null;
  375. if (annotCommand.CommandTarget == TargetType.ImageSelection)
  376. {
  377. separator = SetSeparator();
  378. popMenu.Items.Add(separator);
  379. SetSelectTextOrImageMenuItem(T_RightMenuSelectionExtractImage, "ExportPicture", annotCommand, out menuItem);
  380. if (PDFViewer.GetSelectImageCount() > 0)
  381. {
  382. menuItem.IsEnabled = true;
  383. }
  384. popMenu.Items.Add(menuItem);
  385. }
  386. else if (annotCommand.CommandTarget == TargetType.Annot)
  387. {
  388. separator = SetSeparator();
  389. popMenu.Items.Add(separator);
  390. SetSelectTextOrImageMenuItem(T_RightMenuSelectionHighlight, "HighLight", annotCommand, out menuItem);
  391. popMenu.Items.Add(menuItem);
  392. SetSelectTextOrImageMenuItem(T_RightMenuSelectionUnderline, "UnderLine", annotCommand, out menuItem);
  393. popMenu.Items.Add(menuItem);
  394. SetSelectTextOrImageMenuItem(T_RightMenuSelectionStrikethrough, "Strikeout", annotCommand, out menuItem);
  395. popMenu.Items.Add(menuItem);
  396. separator = SetSeparator();
  397. //popMenu.Items.Add(separator);
  398. SetSelectTextOrImageMenuItem(T_RightMenuSelectionText, "Freetext", annotCommand, out menuItem);
  399. //popMenu.Items.Add(menuItem);
  400. SetSelectTextOrImageMenuItem(T_RightMenuSelectionNote, "StickyNote", annotCommand, out menuItem);
  401. //popMenu.Items.Add(menuItem);
  402. separator = SetSeparator();
  403. popMenu.Items.Add(separator);
  404. SetSelectTextOrImageMenuItem(T_RightMenuSelectionRectangle, "Rect", annotCommand, out menuItem);
  405. popMenu.Items.Add(menuItem);
  406. SetSelectTextOrImageMenuItem(T_RightMenuSelectionOval, "Circle", annotCommand, out menuItem);
  407. popMenu.Items.Add(menuItem);
  408. SetSelectTextOrImageMenuItem(T_RightMenuSelectionStraightLine, "Line", annotCommand, out menuItem);
  409. //popMenu.Items.Add(menuItem);
  410. }
  411. separator = SetSeparator();
  412. popMenu.Items.Add(separator);
  413. InBookModeSetIsHidden(separator);
  414. SetSelectTextOrImageMenuItem(T_RightMenuSelectionAddLink, "Link", annotCommand, out menuItem);
  415. popMenu.Items.Add(menuItem);
  416. if (annotCommand.CommandTarget == TargetType.Annot)
  417. {
  418. SetSelectTextOrImageMenuItem(T_RightMenuSelectionAddOutline, "OutLine", annotCommand, out menuItem);
  419. popMenu.Items.Add(menuItem);
  420. SetSelectTextOrImageMenuItem("AI Translation", "Translation", annotCommand, out menuItem);
  421. popMenu.Items.Add(menuItem);
  422. }
  423. return popMenu;
  424. }
  425. private void MenuTranslate_Click(object sender, RoutedEventArgs eventArgs)
  426. {
  427. DialogParameters printValue = new DialogParameters();
  428. printValue.Add(ParameterNames.PDFViewer, PDFViewer);
  429. dialogs.ShowDialog(DialogNames.SelectedTranslation, printValue, e => { });
  430. }
  431. private void SetSelectTextOrImageMenuItem(string header, string tag, AnnotCommandArgs annotCommand, out MenuItem menuItem)
  432. {
  433. menuItem = new MenuItem();
  434. menuItem.Header = header;
  435. menuItem.Tag = tag;
  436. if (tag == "Translation") {
  437. menuItem.Click -= MenuTranslate_Click;
  438. menuItem.Click += MenuTranslate_Click;
  439. return;
  440. }
  441. if (tag == "OutLine" || tag == "Link")
  442. {
  443. InBookModeSetIsHidden(menuItem);
  444. }
  445. menuItem.Click -= AnnotToolMenu_Click;
  446. menuItem.Click += AnnotToolMenu_Click;
  447. menuItem.CommandParameter = annotCommand;
  448. }
  449. private Separator SetSeparator()
  450. {
  451. Separator separator = new Separator
  452. {
  453. Height = 1,
  454. BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#33000000")),
  455. BorderThickness = new Thickness(1),
  456. Style = (Style)App.Current.FindResource(System.Windows.Controls.ToolBar.SeparatorStyleKey)
  457. };
  458. return separator;
  459. }
  460. #endregion 阅读页 - 右键菜单
  461. #region 注释-右键菜单
  462. #region 注释-右键菜单文案
  463. //public string T_RightMenuAnnotCopy = App.MainPageLoader.GetString("ViewRightMenuSelection_Copy");
  464. //public string T_RightMenuAnnotPaste = App.MainPageLoader.GetString("ViewRightMenuSelection_Paste");
  465. //public string T_RightMenuAnnotHighlight = App.MainPageLoader.GetString("ViewRightMenuSelection_Highlight");
  466. //public string T_RightMenuAnnotUnderline = App.MainPageLoader.GetString("ViewRightMenuSelection_Underline");
  467. //public string T_RightMenuAnnotStrikethrough = App.MainPageLoader.GetString("ViewRightMenuSelection_Strikethrough");
  468. //public string T_RightMenuAnnotText = App.MainPageLoader.GetString("ViewRightMenuSelection_Text");
  469. //public string T_RightMenuAnnotNote = App.MainPageLoader.GetString("ViewRightMenuSelection_Note");
  470. public string T_RightMenuAnnotCopy = App.MainPageLoader.GetString("ViewRightMenuAnnot_Copy");
  471. public string T_RightMenuAnnotCut = App.MainPageLoader.GetString("ViewRightMenuAnnot_Cut");
  472. public string T_RightMenuAnnotPaste = App.MainPageLoader.GetString("ViewRightMenuAnnot_Paste");
  473. public string T_RightMenuAnnotDelete = App.MainPageLoader.GetString("ViewRightMenuAnnot_Delete");
  474. public string T_RightMenuAnnotAddNote = App.MainPageLoader.GetString("ViewRightMenuAnnot_AddNote");
  475. public string T_RightMenuAnnotDefault = App.MainPageLoader.GetString("ViewRightMenuAnnot_Default");
  476. public string T_RightMenuFreehandAnnotColor = App.MainPageLoader.GetString("ViewRightMenuFreehandAnnot_Color");
  477. public string T_RightMenuFreehandAnnotLineStyle = App.MainPageLoader.GetString("ViewRightMenuFreehandAnnot_LineStyle");
  478. public string T_RightMenuFreehandAnnotLineStyleSolid = App.MainPageLoader.GetString("ViewRightMenuFreehandAnnotLineStyle_SolidLine");
  479. public string T_RightMenuFreehandAnnotLineStyleDotted = App.MainPageLoader.GetString("ViewRightMenuFreehandAnnotLineStyle_DottedLine");
  480. public string T_RightMenuFreetextAnnotFontColor = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnot_FontColor");
  481. public string T_RightMenuFreetextAnnotFillColor = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnot_FillColor");
  482. public string T_RightMenuFreetextAnnotFont = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnot_Font");
  483. public string T_RightMenuFreetextAnnotFontCourierNew = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnotFont_CourierNew");
  484. public string T_RightMenuFreetextAnnotFontHelvetica = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnotFont_Helvetica");
  485. public string T_RightMenuFreetextAnnotFontTimesNewRoman = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnotFont_TimesNewRoman");
  486. public string T_RightMenuFreetextAnnotTextAlignment = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnot_TextAlignment");
  487. public string T_RightMenuFreetextAnnotTextAlignmentAlignLeft = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnotTextAlignment_AlignLeft");
  488. public string T_RightMenuFreetextAnnotTextAlignmentAlignCenter = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnotTextAlignment_AlignCenter");
  489. public string T_RightMenuFreetextAnnotTextAlignmentAlignRight = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnotTextAlignment_AlignRight");
  490. public string T_RightMenuFreetextAnnotTextAlignmentFullyJustified = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnotTextAlignment_FullyJustified");
  491. public string T_RightMenuStickyNoteAnnotColor = App.MainPageLoader.GetString("ViewRightMenuStickyNoteAnnot_Color");
  492. public string T_RightMenuStickyNoteAnnotEdit = App.MainPageLoader.GetString("ViewRightMenuStickyNoteAnnot_Edit");
  493. public string T_RightMenuSharpsNoteAnnotColor = App.MainPageLoader.GetString("ViewRightMenuSharpsAnnot_Color");
  494. public string T_RightMenuSharpsNoteAnnotLineStyleSolidline = App.MainPageLoader.GetString("ViewRightMenuSharpsAnnotLineStyle_SolidLine");
  495. public string T_RightMenuSharpsNoteAnnotLineStyleDottedLine = App.MainPageLoader.GetString("ViewRightMenuSharpsAnnotLineStyle_DottedLine");
  496. public string T_RightMenuSharpsNoteAnnotLineStyle = App.MainPageLoader.GetString("ViewRightMenuSharpsAnnot_LineStyle");
  497. public string T_RightMenuSharpsNoteAnnotDirection = App.MainPageLoader.GetString("ViewRightMenuSharpsAnnot_Direction");
  498. public string T_RightMenuSharpsNoteAnnotDirectionVertical = App.MainPageLoader.GetString("ViewRightMenuSharpsAnnotDirection_Vertical");
  499. public string T_RightMenuSharpsNoteAnnotDirectionHorizontal = App.MainPageLoader.GetString("ViewRightMenuSharpsAnnotDirection_Horizontal");
  500. public string T_RightMenuSharpsNoteAnnotBorderColor = App.MainPageLoader.GetString("ViewRightMenuSharpsAnnot_BorderColor");
  501. public string T_RightMenuSharpsNoteAnnotFillColor = App.MainPageLoader.GetString("ViewRightMenuSharpsAnnot_FillColor");
  502. public string T_RightMenuStampNoteAnnotExport = App.MainPageLoader.GetString("ViewRightMenuStampAnnot_Export");
  503. public string T_RightMenuStampNoteAnnotExportPNG = App.MainPageLoader.GetString("ViewRightMenuStampAnnotExport_PNG");
  504. public string T_RightMenuStampNoteAnnotExportPDF = App.MainPageLoader.GetString("ViewRightMenuStampAnnotExport_PDF");
  505. public string T_RightMenuTextNoteAnnotCopyText = App.MainPageLoader.GetString("ViewRightMenuTextAnnot_CopyText");
  506. public string T_RightMenuTextNoteAnnotDelete = App.MainPageLoader.GetString("ViewRightMenuTextAnnot_Delete");
  507. #endregion 注释-右键菜单文案
  508. private ColorMenuItem colorContent;
  509. /// <summary>
  510. /// 高亮注释,右键菜单
  511. /// </summary>
  512. ///
  513. private void InitSelectHightAnnotMenu()
  514. {
  515. var popMenu = new ContextMenu();
  516. PopMenu pop = new PopMenu(popMenu);
  517. colorContent = new ColorMenuItem();
  518. colorContent.Name = "hightcolor";
  519. colorContent.ColorChanged -= colorContent_SelectedColorHandler;
  520. colorContent.ColorChanged += colorContent_SelectedColorHandler;
  521. colorContent.VerticalAlignment = VerticalAlignment.Top;
  522. colorContent.Margin = new Thickness(0, 0, 0, -15);
  523. var menuItem = new MenuItem();
  524. menuItem.Name = "hightColor";
  525. menuItem.Height = 20 + 15;
  526. menuItem.Header = colorContent;
  527. var hightColorStyle = App.Current.FindResource("UIElementMenuItem") as Style;
  528. if (hightColorStyle != null)
  529. menuItem.Style = hightColorStyle;
  530. colorContent.DataContext = pop.AddItem(menuItem);
  531. pop.AddItem(GetSeparator());
  532. menuItem = new MenuItem();
  533. menuItem.Name = "hightCopyText";
  534. menuItem.Header = T_RightMenuTextNoteAnnotCopyText;
  535. pop.BindingEvent(pop.AddItem(menuItem), HightAnnotCopyText_MenuCommand);
  536. menuItem = new MenuItem();
  537. menuItem.Name = "hightdelete";
  538. menuItem.Header = T_RightMenuTextNoteAnnotDelete;
  539. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  540. pop.AddItem(GetSeparator());
  541. menuItem = new MenuItem();
  542. menuItem.Name = "hightAddNote";
  543. menuItem.Header = T_RightMenuAnnotAddNote;
  544. pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand);
  545. menuItem = new MenuItem();
  546. menuItem.Name = "hightdefault";
  547. menuItem.Header = T_RightMenuAnnotDefault;
  548. pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
  549. HightAnnotPopMenu = pop;
  550. }
  551. private Separator GetSeparator()
  552. {
  553. Separator separator = new Separator();
  554. separator.Height = 1;
  555. separator.BorderBrush = new SolidColorBrush(Color.FromArgb(0x33, 0x00, 0x00, 0x00));
  556. separator.BorderThickness = new Thickness(1);
  557. separator.Margin = new Thickness(-30, 0, 0, 0);
  558. return separator;
  559. }
  560. private async void colorContent_SelectedColorHandler(object sender, Color e)
  561. {
  562. if (e == null) return;
  563. if (sender is Ellipse)
  564. {
  565. var item = new ColorDropBoxPop();
  566. item.DataContext = (sender as Ellipse).DataContext;
  567. item.ColorSelected -= AnnotMenu_ColorSelected;
  568. item.ColorSelected += AnnotMenu_ColorSelected;
  569. if (popup == null)
  570. popup = new System.Windows.Controls.Primitives.Popup();
  571. ContentControl window = null;
  572. if (PDFViewer.Parent as ContentControl != null)
  573. window = PDFViewer.Parent as ContentControl;
  574. else
  575. window = App.Current.MainWindow;
  576. popup.Child = item;
  577. popup.PlacementRectangle = new Rect(Mouse.GetPosition(window), new Size(item.Width, item.Height));
  578. popup.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
  579. popup.PlacementTarget = window;
  580. popup.IsOpen = true;
  581. Window parentWnd = Window.GetWindow(App.Current.MainWindow);
  582. if (parentWnd != null)
  583. {
  584. parentWnd.MouseDown -= parentWnd_MouseDown;
  585. parentWnd.MouseDown += parentWnd_MouseDown;
  586. }
  587. while (popup.IsOpen)
  588. await Task.Delay(20);
  589. parentWnd.MouseDown -= parentWnd_MouseDown;
  590. popup = null;
  591. }
  592. else
  593. {
  594. var cusMenuItem = (sender as FrameworkElement).DataContext as CusMenuItem;
  595. if (cusMenuItem != null && cusMenuItem.Parameter != null)
  596. {
  597. if (cusMenuItem.Parameter is TextHighlightAnnotArgs textHighlightAnnotArgs)
  598. {
  599. var anvent = AnnotAttribEvent.GetAnnotAttribEvent(textHighlightAnnotArgs, textHighlightAnnotArgs.GetAnnotAttrib(), PDFViewer);
  600. anvent.UpdateAttrib(AnnotAttrib.Color, e);
  601. anvent.UpdateAnnot();
  602. }
  603. if (cusMenuItem.Parameter is TextUnderlineAnnotArgs textUnderlineAnnotArgs)
  604. {
  605. var anvent = AnnotAttribEvent.GetAnnotAttribEvent(textUnderlineAnnotArgs, textUnderlineAnnotArgs.GetAnnotAttrib(), PDFViewer);
  606. anvent.UpdateAttrib(AnnotAttrib.Color, e);
  607. anvent.UpdateAnnot();
  608. }
  609. if (cusMenuItem.Parameter is TextStrikeoutAnnotArgs textStrikeoutAnnotArgs)
  610. {
  611. var anvent = AnnotAttribEvent.GetAnnotAttribEvent(textStrikeoutAnnotArgs, textStrikeoutAnnotArgs.GetAnnotAttrib());
  612. anvent.UpdateAttrib(AnnotAttrib.Color, e);
  613. anvent.UpdateAnnot();
  614. }
  615. //var test = cusMenuItem.Parameter as TextHighlightAnnotArgs;
  616. //if (test != null)
  617. //{
  618. // var anvent = AnnotAttribEvent.GetAnnotAttribEvent(test, test.GetAnnotAttrib());
  619. // anvent.UpdateAttrib(AnnotAttrib.Color, e);
  620. // anvent.UpdateAnnot();
  621. //}
  622. }
  623. }
  624. }
  625. /// <summary>
  626. /// 手绘
  627. /// </summary>
  628. private void InitSelectFreeHandAnnotMenu()
  629. {
  630. var popMenu = new ContextMenu();
  631. PopMenu pop = new PopMenu(popMenu);
  632. var menuItem = new MenuItem();
  633. menuItem.Name = "FreeHandCopy";
  634. menuItem.Header = T_RightMenuAnnotCopy;
  635. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  636. menuItem = new MenuItem();
  637. menuItem.Name = "FreeHandCut";
  638. menuItem.Header = T_RightMenuAnnotCut;
  639. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  640. menuItem = new MenuItem();
  641. menuItem.Name = "FreeHandPaste";
  642. menuItem.Header = T_RightMenuAnnotPaste;
  643. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
  644. menuItem = new MenuItem();
  645. menuItem.Name = "FreeHandDelete";
  646. menuItem.Header = T_RightMenuAnnotDelete;
  647. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  648. pop.AddItem(GetSeparator());
  649. menuItem = new MenuItem();
  650. menuItem.Name = "FreeHandColor";
  651. menuItem.Header = T_RightMenuFreehandAnnotColor;
  652. menuItem.Tag = "Color";
  653. pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
  654. menuItem = new MenuItem();
  655. menuItem.Name = "FreeHandLineStyle";
  656. menuItem.Header = T_RightMenuFreehandAnnotLineStyle;
  657. pop.AddItem(menuItem);
  658. RadioButton radioButton = new RadioButton();
  659. radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
  660. radioButton.Background = new SolidColorBrush(Colors.Transparent);
  661. radioButton.Name = "FreeHandSolid";
  662. radioButton.Content = T_RightMenuFreehandAnnotLineStyleSolid;
  663. radioButton.GroupName = "LineStyle";
  664. radioButton.Tag = "Solid";
  665. pop.BindingEvent(pop.AddChild("FreeHandLineStyle", radioButton), FreeHandLineStyle_MenuCommand);
  666. radioButton = new RadioButton();
  667. radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
  668. radioButton.Background = new SolidColorBrush(Colors.Transparent);
  669. radioButton.Name = "FreeHandDash";
  670. radioButton.Content = T_RightMenuFreehandAnnotLineStyleDotted;
  671. radioButton.GroupName = "LineStyle";
  672. radioButton.Tag = "Dash";
  673. pop.BindingEvent(pop.AddChild("FreeHandLineStyle", radioButton), FreeHandLineStyle_MenuCommand);
  674. menuItem = new MenuItem();
  675. menuItem.Name = "FreeHandAddNote";
  676. menuItem.Header = T_RightMenuAnnotAddNote;
  677. pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand);
  678. menuItem = new MenuItem();
  679. menuItem.Name = "FreeHandDefault";
  680. menuItem.Header = T_RightMenuAnnotDefault;
  681. pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
  682. FreeHandAnnotPopMenu = pop;
  683. }
  684. /// <summary>
  685. /// 文本
  686. /// </summary>
  687. private void InitSelectFreeTextAnnotMenu()
  688. {
  689. var popMenu = new ContextMenu();
  690. PopMenu pop = new PopMenu(popMenu);
  691. var menuItem = new MenuItem();
  692. menuItem.Name = "FreeTextCopy";
  693. menuItem.Header = T_RightMenuAnnotCopy;
  694. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  695. menuItem = new MenuItem();
  696. menuItem.Name = "FreeTextCut";
  697. menuItem.Header = T_RightMenuAnnotCut;
  698. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  699. menuItem = new MenuItem();
  700. menuItem.Name = "FreeTextPaste";
  701. menuItem.Header = T_RightMenuAnnotPaste;
  702. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
  703. menuItem = new MenuItem();
  704. menuItem.Name = "FreeTextDelete";
  705. menuItem.Header = T_RightMenuAnnotDelete;
  706. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  707. pop.AddItem(GetSeparator());
  708. menuItem = new MenuItem();
  709. menuItem.Name = "FreeTextColor";
  710. menuItem.Header = T_RightMenuFreetextAnnotFontColor;
  711. menuItem.Tag = "FontColor";
  712. pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
  713. menuItem = new MenuItem();
  714. menuItem.Name = "FreeTextFillColor";
  715. menuItem.Header = T_RightMenuFreetextAnnotFillColor;
  716. menuItem.Tag = "FillColor";
  717. pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
  718. menuItem = new MenuItem();
  719. menuItem.Name = "FreeTextFontFamily";
  720. menuItem.Header = T_RightMenuFreetextAnnotFont;
  721. pop.AddItem(menuItem);
  722. var family = TextFont.GetFamily();
  723. foreach (var item in family)
  724. {
  725. RadioButton familyRdioBtn = new RadioButton();
  726. familyRdioBtn.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
  727. familyRdioBtn.Background = new SolidColorBrush(Colors.Transparent);
  728. familyRdioBtn.Name = item.ValueStr;
  729. familyRdioBtn.Tag = item.ValueStr;
  730. familyRdioBtn.GroupName = "FontFamily";
  731. familyRdioBtn.Content = item.Content;
  732. pop.BindingEvent(pop.AddChild("FreeTextFontFamily", familyRdioBtn), FreeTextFontFamily_MenuCommand);
  733. }
  734. menuItem = new MenuItem();
  735. menuItem.Name = "FreeTextAglin";
  736. menuItem.Header = T_RightMenuFreetextAnnotTextAlignment;
  737. pop.AddItem(menuItem);
  738. var radioButton = new RadioButton();
  739. radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
  740. radioButton.Background = new SolidColorBrush(Colors.Transparent);
  741. radioButton.Name = "FreeTextAglinLeft";
  742. radioButton.Tag = "Left";
  743. radioButton.GroupName = "Aglin";
  744. radioButton.Content = T_RightMenuFreetextAnnotTextAlignmentAlignLeft;
  745. pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
  746. radioButton = new RadioButton();
  747. radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
  748. radioButton.Background = new SolidColorBrush(Colors.Transparent);
  749. radioButton.Name = "FreeTextAglinCenter";
  750. radioButton.Tag = "Center";
  751. radioButton.GroupName = "Aglin";
  752. radioButton.Content = T_RightMenuFreetextAnnotTextAlignmentAlignCenter;
  753. pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
  754. radioButton = new RadioButton();
  755. radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
  756. radioButton.Background = new SolidColorBrush(Colors.Transparent);
  757. radioButton.Name = "FreeTextAglinRight";
  758. radioButton.Tag = "Right";
  759. radioButton.GroupName = "Aglin";
  760. radioButton.Content = T_RightMenuFreetextAnnotTextAlignmentAlignRight;
  761. pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
  762. radioButton = new RadioButton();
  763. radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
  764. radioButton.Background = new SolidColorBrush(Colors.Transparent);
  765. radioButton.Name = "FreeTextAglinJustify";
  766. radioButton.Tag = "Justify";
  767. radioButton.GroupName = "Aglin";
  768. radioButton.Content = T_RightMenuFreetextAnnotTextAlignmentFullyJustified;
  769. //pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
  770. menuItem = new MenuItem();
  771. menuItem.Name = "FreeHandDefault";
  772. menuItem.Header = T_RightMenuAnnotDefault;
  773. pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
  774. FreeTextAnnotPopMenu = pop;
  775. }
  776. /// <summary>
  777. /// 便签
  778. /// </summary>
  779. private void InitSelectStrickNoteAnnotMenu()
  780. {
  781. var popMenu = new ContextMenu();
  782. PopMenu pop = new PopMenu(popMenu);
  783. var menuItem = new MenuItem();
  784. menuItem.Name = "StrickNoteCopy";
  785. menuItem.Header = T_RightMenuAnnotCopy;
  786. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  787. menuItem = new MenuItem();
  788. menuItem.Name = "StrickNoteCut";
  789. menuItem.Header = T_RightMenuAnnotCut;
  790. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  791. menuItem = new MenuItem();
  792. menuItem.Name = "StrickNotePaste";
  793. menuItem.Header = T_RightMenuAnnotPaste;
  794. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
  795. menuItem = new MenuItem();
  796. menuItem.Name = "StrickNoteDelete";
  797. menuItem.Header = T_RightMenuAnnotDelete;
  798. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  799. pop.AddItem(GetSeparator());
  800. menuItem = new MenuItem();
  801. menuItem.Name = "StrickNoteColor";
  802. menuItem.Header = T_RightMenuStickyNoteAnnotColor;
  803. pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
  804. menuItem = new MenuItem();
  805. menuItem.Name = "StrickNoteEdit";
  806. menuItem.Header = T_RightMenuStickyNoteAnnotEdit;
  807. pop.BindingEvent(pop.AddItem(menuItem), StrikeNoteEditStrike_MenuCommand);
  808. menuItem = new MenuItem();
  809. menuItem.Name = "StrickNoteDefault";
  810. menuItem.Header = T_RightMenuAnnotDefault;
  811. pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
  812. StrickNoteAnnotPopMenu = pop;
  813. }
  814. /// <summary>
  815. /// 形状
  816. /// </summary>
  817. private void InitSelectShapeAnnotMenu()
  818. {
  819. var popMenu = new ContextMenu();
  820. PopMenu pop = new PopMenu(popMenu);
  821. var menuItem = new MenuItem();
  822. menuItem.Name = "ShapeCopy";
  823. menuItem.Header = T_RightMenuAnnotCopy;
  824. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  825. menuItem = new MenuItem();
  826. menuItem.Name = "ShapeCut";
  827. menuItem.Header = T_RightMenuAnnotCut;
  828. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  829. menuItem = new MenuItem();
  830. menuItem.Name = "ShapePaste";
  831. menuItem.Header = T_RightMenuAnnotPaste;
  832. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
  833. menuItem = new MenuItem();
  834. menuItem.Name = "ShapeDelete";
  835. menuItem.Header = T_RightMenuAnnotDelete;
  836. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  837. pop.AddItem(GetSeparator());
  838. menuItem = new MenuItem();
  839. menuItem.Name = "ShapeColor";
  840. menuItem.Header = T_RightMenuSharpsNoteAnnotBorderColor;
  841. menuItem.Tag = "Color";
  842. pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
  843. menuItem = new MenuItem();
  844. menuItem.Name = "ShapeFillColor";
  845. menuItem.Header = T_RightMenuSharpsNoteAnnotFillColor;
  846. menuItem.Tag = "FillColor";
  847. pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
  848. menuItem = new MenuItem();
  849. menuItem.Name = "ShapeLineStyle";
  850. menuItem.Header = T_RightMenuSharpsNoteAnnotLineStyle;
  851. pop.AddItem(menuItem);
  852. RadioButton radioButton = new RadioButton();
  853. radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
  854. radioButton.Background = new SolidColorBrush(Colors.Transparent);
  855. radioButton.Name = "ShapeSolid";
  856. radioButton.Content = T_RightMenuSharpsNoteAnnotLineStyleSolidline;
  857. radioButton.GroupName = "LineStyle";
  858. radioButton.Tag = "Solid";
  859. pop.BindingEvent(pop.AddChild("ShapeLineStyle", radioButton), ShapeLineStyle_MenuCommand);
  860. radioButton = new RadioButton();
  861. radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
  862. radioButton.Background = new SolidColorBrush(Colors.Transparent);
  863. radioButton.Name = "ShapeDash";
  864. radioButton.Content = T_RightMenuSharpsNoteAnnotLineStyleDottedLine;
  865. radioButton.GroupName = "LineStyle";
  866. radioButton.Tag = "Dash";
  867. pop.BindingEvent(pop.AddChild("ShapeLineStyle", radioButton), ShapeLineStyle_MenuCommand);
  868. menuItem = new MenuItem();
  869. menuItem.Name = "ShapeDirect";
  870. menuItem.Header = T_RightMenuSharpsNoteAnnotDirection;
  871. pop.AddItem(menuItem);
  872. menuItem = new MenuItem();
  873. menuItem.Name = "ShapeVer";
  874. menuItem.Header = T_RightMenuSharpsNoteAnnotDirectionVertical;
  875. menuItem.Tag = "Ver";
  876. pop.BindingEvent(pop.AddChild("ShapeDirect", menuItem), ShapeLineDirect_MenuCommand);
  877. menuItem = new MenuItem();
  878. menuItem.Name = "ShapeHor";
  879. menuItem.Header = T_RightMenuSharpsNoteAnnotDirectionHorizontal;
  880. menuItem.Tag = "Hor";
  881. pop.BindingEvent(pop.AddChild("ShapeDirect", menuItem), ShapeLineDirect_MenuCommand);
  882. menuItem = new MenuItem();
  883. menuItem.Name = "ShapeNoteText";
  884. menuItem.Header = T_RightMenuAnnotAddNote;
  885. pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand);
  886. menuItem = new MenuItem();
  887. menuItem.Name = "ShapeDefault";
  888. menuItem.Header = T_RightMenuAnnotDefault;
  889. pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
  890. ShapeAnnotPopMenu = pop;
  891. }
  892. /// <summary>
  893. /// 链接
  894. /// </summary>
  895. private void InitSelectLinkAnnotMenu()
  896. {
  897. var popMenu = new ContextMenu();
  898. PopMenu pop = new PopMenu(popMenu);
  899. var menuItem = new MenuItem();
  900. menuItem.Name = "LinkCopy";
  901. menuItem.Header = T_RightMenuAnnotCopy;
  902. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  903. menuItem = new MenuItem();
  904. menuItem.Name = "LinkCut";
  905. menuItem.Header = T_RightMenuAnnotCut;
  906. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  907. menuItem = new MenuItem();
  908. menuItem.Name = "LinkPaste";
  909. menuItem.Header = T_RightMenuAnnotPaste;
  910. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
  911. menuItem = new MenuItem();
  912. menuItem.Name = "LinkDelete";
  913. menuItem.Header = T_RightMenuAnnotDelete;
  914. //pop.BindingEvent(pop.AddItem(menuItem), Link_MenuCommand);
  915. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  916. LinkAnnotPopMenu = pop;
  917. }
  918. /// <summary>
  919. /// 图章、签名
  920. /// </summary>
  921. private void InitSelectStampAnnotMenu()
  922. {
  923. var popMenu = new ContextMenu();
  924. PopMenu pop = new PopMenu(popMenu);
  925. var menuItem = new MenuItem();
  926. menuItem.Name = "StampCopy";
  927. menuItem.Header = T_RightMenuAnnotCopy;
  928. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  929. menuItem = new MenuItem();
  930. menuItem.Name = "StampCut";
  931. menuItem.Header = T_RightMenuAnnotCut;
  932. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  933. menuItem = new MenuItem();
  934. menuItem.Name = "StampPaste";
  935. menuItem.Header = T_RightMenuAnnotPaste;
  936. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
  937. menuItem = new MenuItem();
  938. menuItem.Name = "StampDelete";
  939. menuItem.Header = T_RightMenuAnnotDelete;
  940. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  941. pop.AddItem(GetSeparator());
  942. menuItem = new MenuItem();
  943. menuItem.Name = "StampExportPicture";
  944. menuItem.Header = T_RightMenuStampNoteAnnotExport;
  945. pop.AddItem(menuItem);
  946. menuItem = new MenuItem();
  947. menuItem.Name = "StampExportPNG";
  948. menuItem.Header = T_RightMenuStampNoteAnnotExportPNG;
  949. menuItem.Tag = "PNG";
  950. pop.BindingEvent(pop.AddChild("StampExportPicture", menuItem), StampExportPicture_MenuCommand);
  951. //已跟设计确认,暂时不需要JPG格式
  952. //menuItem = new MenuItem();
  953. //menuItem.Name = "StampExportPNG";
  954. //menuItem.Header = "JPG";
  955. //menuItem.Tag = "JPG";
  956. //pop.BindingEvent(pop.AddChild("StampExportPicture", menuItem), StampExportPicture_MenuCommand);
  957. menuItem = new MenuItem();
  958. menuItem.Name = "StampExportPDF";
  959. menuItem.Header = T_RightMenuStampNoteAnnotExportPDF;
  960. menuItem.Tag = "PDF";
  961. pop.BindingEvent(pop.AddChild("StampExportPicture", menuItem), StampExportPicture_MenuCommand);
  962. menuItem = new MenuItem();
  963. menuItem.Name = "StampAddNote";
  964. menuItem.Header = T_RightMenuAnnotAddNote;
  965. pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand);
  966. StampAnnotPopMenu = pop;
  967. }
  968. /// <summary>
  969. /// 多选注释
  970. /// </summary>
  971. private void InitSelectMultiAnnotMenu()
  972. {
  973. var popMenu = new ContextMenu();
  974. PopMenu pop = new PopMenu(popMenu);
  975. var menuItem = new MenuItem();
  976. menuItem.Name = "MultiCopy";
  977. menuItem.Header = T_RightMenuAnnotCopy;
  978. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
  979. menuItem = new MenuItem();
  980. menuItem.Name = "MultiCut";
  981. menuItem.Header = T_RightMenuAnnotCut;
  982. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
  983. menuItem = new MenuItem();
  984. menuItem.Name = "MultiDelete";
  985. menuItem.Header = T_RightMenuAnnotDelete;
  986. pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
  987. MultiAnnotPopMenu = pop;
  988. }
  989. #endregion 注释-右键菜单
  990. }
  991. }