AnnotationListItem.xaml.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. using ComPDFKit.Import;
  2. using ComPDFKit.PDFAnnotation;
  3. using ComPDFKit.PDFDocument;
  4. using ComPDFKit.PDFPage;
  5. using ComPDFKitViewer;
  6. using ComPDFKitViewer.AnnotEvent;
  7. using ComPDFKitViewer.PdfViewer;
  8. using PDF_Master.Helper;
  9. using PDF_Master.Model.BOTA;
  10. using PDF_Master.ViewModels.BOTA;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.IO;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Text.RegularExpressions;
  17. using System.Threading.Tasks;
  18. using System.Windows;
  19. using System.Windows.Controls;
  20. using System.Windows.Data;
  21. using System.Windows.Documents;
  22. using System.Windows.Forms;
  23. using System.Windows.Input;
  24. using System.Windows.Media;
  25. using System.Windows.Media.Imaging;
  26. using System.Windows.Navigation;
  27. using System.Windows.Shapes;
  28. using static Dropbox.Api.Files.SearchMatchTypeV2;
  29. namespace PDF_Master.Views.BOTA
  30. {
  31. /// <summary>
  32. /// AnnotationListItem.xaml 的交互逻辑
  33. /// </summary>
  34. public partial class AnnotationListItem : System.Windows.Controls.UserControl
  35. {
  36. //private Brush strikeoutColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
  37. public AnnotationListItem()
  38. {
  39. InitializeComponent();
  40. }
  41. private void GridIco_Loaded(object sender, RoutedEventArgs e)
  42. {
  43. if (e.Source is Grid grid)
  44. {
  45. if (grid.DataContext == null)
  46. {
  47. //var data= this.DataContext as AnnotationHandlerEventArgs;
  48. }
  49. if (grid.DataContext is AnnotationHandlerEventArgs args)
  50. {
  51. //var args = grid.DataContext as AnnotationHandlerEventArgs;
  52. AnnotHandlerEventArgs data = args.AnnotHandlerEventArgs;
  53. if (data == null)
  54. {
  55. return;
  56. }
  57. TxbMarkupContent.Text = data.MarkupContent;
  58. TxbContent.Text = data.Content;
  59. switch (data.EventType)
  60. {
  61. case AnnotArgsType.AnnotFreeText:
  62. if (data is FreeTextAnnotArgs freeTextAnnotArgs)
  63. {
  64. BtnAnnotFreeText.Visibility = Visibility.Visible;
  65. //TxbContent.Foreground = new SolidColorBrush(freeTextAnnotArgs.FontColor);
  66. }
  67. //BOTA - 注释,MVP不处理高亮 / 下划线 / 删除线的样式,只显示文字
  68. //文本注释、便签、链接、表格不支持添加附注
  69. TxbMarkupContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  70. TxbMarkupContent.Text = "";
  71. break;
  72. case AnnotArgsType.AnnotHighlight:
  73. if (data is TextHighlightAnnotArgs textHighlightAnnotArgs)
  74. {
  75. BtnHighlight.Visibility = Visibility.Visible;
  76. PathHighlight.Background = new SolidColorBrush(textHighlightAnnotArgs.Color);
  77. //PathHighlight.Opacity = textHighlightAnnotArgs.Transparency;
  78. //BOTA - 注释,MVP不处理高亮 / 下划线 / 删除线的样式,只显示文字
  79. //文本注释、便签、链接、表格不支持添加附注
  80. //高亮、下划线、删除线,不是文本注释
  81. TxbContent.Text = Regex.Replace(data.MarkupContent, "[\r\n]", " ");
  82. TxbMarkupContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  83. }
  84. break;
  85. case AnnotArgsType.AnnotFreehand:
  86. if (data is FreehandAnnotArgs freehandAnnotArgs)
  87. {
  88. BtnFreeHand.Visibility = Visibility.Visible;
  89. PathFreehand.Fill = new SolidColorBrush(freehandAnnotArgs.InkColor);
  90. ImageContext.Visibility = Visibility.Visible;
  91. TxbContent.Visibility = Visibility.Collapsed;
  92. SetImageContext(args, freehandAnnotArgs);
  93. //var encoder = new PngBitmapEncoder();
  94. //encoder.Frames.Add(BitmapFrame.Create((BitmapSource)ImageContext.Source));
  95. //FileStream file = new FileStream(String.Format($@"C:\Users\oyxh\Desktop\images\PDFText\{data.AnnotIndex}.png"), FileMode.Create);
  96. //encoder.Save(file);
  97. //file.Close();
  98. }
  99. if (string.IsNullOrEmpty(data.Content) == false)
  100. {
  101. TxbMarkupContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  102. }
  103. break;
  104. case AnnotArgsType.AnnotSquiggly://波浪线
  105. if (data is TextSquigglyAnnotArgs textSquigglyAnnotArgs)
  106. {
  107. AnnotSquiggly.Visibility = Visibility.Visible;
  108. AnnotSquigglycolor.Stroke = new SolidColorBrush(textSquigglyAnnotArgs.Color);
  109. }
  110. #region TO DO
  111. //TextDecoration mySquiggly = new TextDecoration();
  112. //Pen myPen = new Pen();
  113. //myPen.Brush = new SolidColorBrush((data as TextSquigglyAnnotArgs).Color);
  114. //myPen.Brush.Opacity = 0.8;
  115. //myPen.Thickness = 2;
  116. //myPen.DashStyle = DashStyles.Dash;
  117. //mySquiggly.Pen = myPen;
  118. //mySquiggly.PenThicknessUnit = TextDecorationUnit.FontRecommended;
  119. //TextDecorationCollection myCollection = new TextDecorationCollection();
  120. //myCollection.Add(mySquiggly);
  121. //TxbContext.TextDecorations = myCollection;
  122. #endregion TO DO
  123. break;
  124. case AnnotArgsType.AnnotStamp:
  125. BtnAnnotStamp.Visibility = Visibility.Visible;
  126. if (string.IsNullOrEmpty(data.Content) == false)
  127. {
  128. TxbContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  129. TxbContent.Text = "";
  130. TxbMarkupContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  131. }
  132. break;
  133. case AnnotArgsType.AnnotStrikeout://删除线
  134. if (data is TextStrikeoutAnnotArgs textStrikeoutAnnotArgs)
  135. {
  136. BtnAnnotStrikeout.Visibility = Visibility.Visible;
  137. PathStrikeoutyColor.Fill = new SolidColorBrush(textStrikeoutAnnotArgs.Color);
  138. //BOTA - 注释,MVP不处理高亮 / 下划线 / 删除线的样式,只显示文字
  139. //文本注释、便签、链接、表格不支持添加附注
  140. //高亮、下划线、删除线,不是文本注释
  141. TxbContent.Text = Regex.Replace(data.MarkupContent, "[\r\n]", " ");
  142. TxbMarkupContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  143. }
  144. #region to do
  145. //TextDecoration myStrikeout = new TextDecoration();
  146. //Pen myPen2 = new Pen();
  147. //myPen2.Brush = new SolidColorBrush((data as TextStrikeoutAnnotArgs).Color);
  148. //myPen2.Brush.Opacity = 0.8;
  149. //myPen2.Thickness = 2;
  150. //myStrikeout.Pen = myPen2;
  151. //myStrikeout.PenOffset = -4;
  152. //myStrikeout.PenThicknessUnit = TextDecorationUnit.FontRecommended;
  153. //TextDecorationCollection myCollection2 = new TextDecorationCollection();
  154. //myCollection2.Add(myStrikeout);
  155. ////因为波浪线无法实现 暂时只显示文字 不显示下划线,删除线等
  156. //TxbMarkupContent.TextDecorations = myCollection2;
  157. #endregion to do
  158. break;
  159. case AnnotArgsType.AnnotSticky://便签
  160. if (data is StickyAnnotArgs stickyAnnotArgs)
  161. {
  162. BtnAnnotSticky.Visibility = Visibility;
  163. PathSticky.Fill = new SolidColorBrush(stickyAnnotArgs.Color);
  164. }
  165. //BOTA - 注释,MVP不处理高亮 / 下划线 / 删除线的样式,只显示文字
  166. //文本注释、便签、链接、表格不支持添加附注
  167. TxbMarkupContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  168. TxbMarkupContent.Text = "";
  169. break;
  170. case AnnotArgsType.AnnotUnderline:
  171. if (data is TextUnderlineAnnotArgs textUnderlineAnnotArgs)
  172. {
  173. BtnUnderLine.Visibility = Visibility.Visible;
  174. RectangleUnderline.Fill = new SolidColorBrush(textUnderlineAnnotArgs.Color);
  175. }
  176. //BOTA - 注释,MVP不处理高亮 / 下划线 / 删除线的样式,只显示文字
  177. //文本注释、便签、链接、表格不支持添加附注
  178. //高亮、下划线、删除线,不是文本注释
  179. TxbContent.Text = Regex.Replace(data.MarkupContent, "[\r\n]", " ");
  180. TxbMarkupContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  181. //TxbMarkupContent.Text = "";
  182. #region TO DO
  183. //TextDecoration myUnderline = new TextDecoration();
  184. //Pen myPen1 = new Pen();
  185. //myPen1.Brush = new SolidColorBrush((data as TextUnderlineAnnotArgs).Color);
  186. //myPen1.Brush.Opacity = 0.8;
  187. //myPen1.Thickness = 2;
  188. //myUnderline.Pen = myPen1;
  189. //myUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended;
  190. //TextDecorationCollection myCollection1 = new TextDecorationCollection();
  191. //myCollection1.Add(myUnderline);
  192. //TxbMarkupContent.TextDecorations = myCollection1;
  193. #endregion TO DO
  194. break;
  195. case AnnotArgsType.AnnotLine:
  196. if (data is LineAnnotArgs lineAnnotArgs)
  197. {
  198. if (lineAnnotArgs.HeadLineType >= (C_LINE_TYPE)1 || lineAnnotArgs.TailLineType >= (C_LINE_TYPE)1)
  199. {
  200. BtnSharpArrow.Visibility = Visibility.Visible;
  201. PathArrow.Fill = new SolidColorBrush(lineAnnotArgs.LineColor);
  202. }
  203. else
  204. {
  205. PathSharpLine.Fill = new SolidColorBrush(lineAnnotArgs.LineColor);
  206. BtnSharpLine.Visibility = Visibility.Visible;
  207. }
  208. ///对于形状注释等只有Note 的处理
  209. if (!string.IsNullOrEmpty(data.Content) && string.IsNullOrEmpty(data.MarkupContent))
  210. {
  211. TxbContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  212. TxbContent.Text = "";
  213. }
  214. if (string.IsNullOrEmpty(data.Content) == false)
  215. {
  216. TxbMarkupContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  217. }
  218. }
  219. break;
  220. case AnnotArgsType.AnnotSquare:
  221. if (data is SquareAnnotArgs squareAnnotArgs)
  222. {
  223. BtnAnnotSquare.Visibility = Visibility.Visible;
  224. RectAnnotSquare.Stroke = new SolidColorBrush(squareAnnotArgs.LineColor);
  225. RectAnnotSquare.Fill = new SolidColorBrush(squareAnnotArgs.BgColor);
  226. ///对于形状注释等只有Note 的处理
  227. if (!string.IsNullOrEmpty(data.Content) && string.IsNullOrEmpty(data.MarkupContent))
  228. {
  229. TxbContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  230. TxbContent.Text = "";
  231. }
  232. }
  233. if (string.IsNullOrEmpty(data.Content) == false)
  234. {
  235. TxbMarkupContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  236. }
  237. break;
  238. case AnnotArgsType.AnnotCircle:
  239. if (data is CircleAnnotArgs circleAnnotArgs)
  240. {
  241. BtnAnnotCircle.Visibility = Visibility.Visible;
  242. EllipseCircle.Stroke = new SolidColorBrush(circleAnnotArgs.LineColor);
  243. EllipseCircle.Fill = new SolidColorBrush(circleAnnotArgs.BgColor);
  244. ///对于形状注释等只有Note 的处理
  245. if (!string.IsNullOrEmpty(data.Content) && string.IsNullOrEmpty(data.MarkupContent))
  246. {
  247. TxbContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  248. TxbContent.Text = "";
  249. }
  250. }
  251. if (string.IsNullOrEmpty(data.Content) == false)
  252. {
  253. TxbMarkupContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  254. }
  255. break;
  256. case AnnotArgsType.AnnotLink:
  257. BtnAnnotLink.Visibility = Visibility.Visible;
  258. if (data is LinkAnnotArgs linkAnnotArgs)
  259. {
  260. if (string.IsNullOrEmpty(linkAnnotArgs.Content))
  261. {
  262. if (linkAnnotArgs.DestIndex != -1)
  263. {
  264. TxbContent.Text = string.Format($"To Page {linkAnnotArgs.DestIndex + 1}");
  265. }
  266. else
  267. {
  268. TxbContent.Text = string.Format($"{linkAnnotArgs.URI}");
  269. }
  270. }
  271. }
  272. break;
  273. default:
  274. break;
  275. }
  276. }
  277. }
  278. }
  279. private void SetImageContext(AnnotationHandlerEventArgs args, FreehandAnnotArgs freehandAnnotArgs)
  280. {
  281. if (args == null && freehandAnnotArgs == null)
  282. {
  283. return;
  284. }
  285. if (args.WriteableBitmap == null)
  286. {
  287. return;
  288. }
  289. double width = args.WriteableBitmap.Width;
  290. double height = args.WriteableBitmap.Height;
  291. CPDFDocument doc = args.Document;
  292. if (doc != null)
  293. {
  294. CPDFPage docPage = doc.PageAtIndex(args.PageIndex, false);
  295. if (docPage != null)
  296. {
  297. double maxWidth = docPage.PageSize.Width;
  298. double maxHeight = docPage.PageSize.Height;
  299. ImageContext.MaxHeight = maxHeight;
  300. if (width > 168)
  301. {
  302. ImageContext.Stretch = Stretch.Uniform;
  303. }
  304. else
  305. {
  306. if (height >= maxHeight / 2)
  307. {
  308. //ImageContext.MaxHeight = 900;
  309. ImageContext.Stretch = Stretch.None;
  310. }
  311. if (height < maxHeight / 2)
  312. {
  313. if (height <= 20)
  314. {
  315. ImageContext.MinHeight = height;
  316. ImageContext.Height = 30;
  317. }
  318. ImageContext.Stretch = Stretch.None;
  319. }
  320. //else
  321. //{
  322. // ImageContext.Stretch = Stretch.Uniform;
  323. //}
  324. }
  325. }
  326. }
  327. }
  328. private void GridIco_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
  329. {
  330. if (e.NewValue is AnnotationHandlerEventArgs args)
  331. {
  332. //var args = grid.DataContext as AnnotationHandlerEventArgs;
  333. AnnotHandlerEventArgs data = args.AnnotHandlerEventArgs;
  334. if (data == null)
  335. {
  336. return;
  337. }
  338. TxbMarkupContent.Text = data.MarkupContent;
  339. TxbContent.Text = data.Content;
  340. switch (data.EventType)
  341. {
  342. case AnnotArgsType.AnnotFreeText:
  343. if (data is FreeTextAnnotArgs freeTextAnnotArgs)
  344. {
  345. BtnAnnotFreeText.Visibility = Visibility.Visible;
  346. //TxbContent.Foreground = new SolidColorBrush(freeTextAnnotArgs.FontColor);
  347. }
  348. //文本注释、便签、链接、表格不支持添加附注
  349. TxbMarkupContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  350. TxbMarkupContent.Text = "";
  351. break;
  352. case AnnotArgsType.AnnotHighlight:
  353. if (data is TextHighlightAnnotArgs textHighlightAnnotArgs)
  354. {
  355. BtnHighlight.Visibility = Visibility.Visible;
  356. PathHighlight.Background = new SolidColorBrush(textHighlightAnnotArgs.Color);
  357. //PathHighlight.Opacity = textHighlightAnnotArgs.Transparency;
  358. //文本注释、便签、链接、表格不支持添加附注
  359. //高亮、下划线、删除线,不是文本注释
  360. TxbContent.Text = Regex.Replace(data.MarkupContent, "[\r\n]", " ");
  361. TxbMarkupContent.Text = data.Content;
  362. }
  363. break;
  364. case AnnotArgsType.AnnotFreehand:
  365. if (data is FreehandAnnotArgs freehandAnnotArgs)
  366. {
  367. BtnFreeHand.Visibility = Visibility.Visible;
  368. PathFreehand.Fill = new SolidColorBrush(freehandAnnotArgs.InkColor);
  369. ImageContext.Visibility = Visibility.Visible;
  370. TxbContent.Visibility = Visibility.Collapsed;
  371. SetImageContext(args, freehandAnnotArgs);
  372. //var encoder = new PngBitmapEncoder();
  373. //encoder.Frames.Add(BitmapFrame.Create((BitmapSource)ImageContext.Source));
  374. //FileStream file = new FileStream(String.Format($@"C:\Users\oyxh\Desktop\images\PDFText\{data.AnnotIndex}.png"), FileMode.Create);
  375. //encoder.Save(file);
  376. //file.Close();
  377. }
  378. if (string.IsNullOrEmpty(data.Content) == false)
  379. {
  380. TxbMarkupContent.Text = data.Content;
  381. }
  382. break;
  383. case AnnotArgsType.AnnotSquiggly://波浪线
  384. if (data is TextSquigglyAnnotArgs textSquigglyAnnotArgs)
  385. {
  386. AnnotSquiggly.Visibility = Visibility.Visible;
  387. AnnotSquigglycolor.Stroke = new SolidColorBrush(textSquigglyAnnotArgs.Color);
  388. }
  389. #region TO DO
  390. //TextDecoration mySquiggly = new TextDecoration();
  391. //Pen myPen = new Pen();
  392. //myPen.Brush = new SolidColorBrush((data as TextSquigglyAnnotArgs).Color);
  393. //myPen.Brush.Opacity = 0.8;
  394. //myPen.Thickness = 2;
  395. //myPen.DashStyle = DashStyles.Dash;
  396. //mySquiggly.Pen = myPen;
  397. //mySquiggly.PenThicknessUnit = TextDecorationUnit.FontRecommended;
  398. //TextDecorationCollection myCollection = new TextDecorationCollection();
  399. //myCollection.Add(mySquiggly);
  400. //TxbContext.TextDecorations = myCollection;
  401. #endregion TO DO
  402. break;
  403. case AnnotArgsType.AnnotStamp:
  404. BtnAnnotStamp.Visibility = Visibility.Visible;
  405. if (string.IsNullOrEmpty(data.Content) == false)
  406. {
  407. TxbContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  408. TxbContent.Text = "";
  409. TxbMarkupContent.Text = data.Content;
  410. }
  411. break;
  412. case AnnotArgsType.AnnotStrikeout://删除线
  413. if (data is TextStrikeoutAnnotArgs textStrikeoutAnnotArgs)
  414. {
  415. BtnAnnotStrikeout.Visibility = Visibility.Visible;
  416. PathStrikeoutyColor.Fill = new SolidColorBrush(textStrikeoutAnnotArgs.Color);
  417. //文本注释、便签、链接、表格不支持添加附注
  418. //高亮、下划线、删除线,不是文本注释
  419. TxbContent.Text = Regex.Replace(data.MarkupContent, "[\r\n]", " ");
  420. TxbMarkupContent.Text = data.Content;
  421. }
  422. #region to do
  423. //TextDecoration myStrikeout = new TextDecoration();
  424. //Pen myPen2 = new Pen();
  425. //myPen2.Brush = new SolidColorBrush((data as TextStrikeoutAnnotArgs).Color);
  426. //myPen2.Brush.Opacity = 0.8;
  427. //myPen2.Thickness = 2;
  428. //myStrikeout.Pen = myPen2;
  429. //myStrikeout.PenOffset = -4;
  430. //myStrikeout.PenThicknessUnit = TextDecorationUnit.FontRecommended;
  431. //TextDecorationCollection myCollection2 = new TextDecorationCollection();
  432. //myCollection2.Add(myStrikeout);
  433. ////因为波浪线无法实现 暂时只显示文字 不显示下划线,删除线等
  434. //TxbMarkupContent.TextDecorations = myCollection2;
  435. #endregion to do
  436. break;
  437. case AnnotArgsType.AnnotSticky://便签
  438. if (data is StickyAnnotArgs stickyAnnotArgs)
  439. {
  440. BtnAnnotSticky.Visibility = Visibility;
  441. PathSticky.Fill = new SolidColorBrush(stickyAnnotArgs.Color);
  442. }
  443. //BOTA - 注释,MVP不处理高亮 / 下划线 / 删除线的样式,只显示文字
  444. //文本注释、便签、链接、表格不支持添加附注
  445. TxbMarkupContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  446. TxbMarkupContent.Text = "";
  447. break;
  448. case AnnotArgsType.AnnotUnderline:
  449. if (data is TextUnderlineAnnotArgs textUnderlineAnnotArgs)
  450. {
  451. BtnUnderLine.Visibility = Visibility.Visible;
  452. RectangleUnderline.Fill = new SolidColorBrush(textUnderlineAnnotArgs.Color);
  453. }
  454. //文本注释、便签、链接、表格不支持添加附注
  455. //高亮、下划线、删除线,不是文本注释
  456. TxbContent.Text = Regex.Replace(data.MarkupContent, "[\r\n]", " ");
  457. TxbMarkupContent.Text = data.Content;
  458. //TxbMarkupContent.Text = "";
  459. #region TO DO
  460. //TextDecoration myUnderline = new TextDecoration();
  461. //Pen myPen1 = new Pen();
  462. //myPen1.Brush = new SolidColorBrush((data as TextUnderlineAnnotArgs).Color);
  463. //myPen1.Brush.Opacity = 0.8;
  464. //myPen1.Thickness = 2;
  465. //myUnderline.Pen = myPen1;
  466. //myUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended;
  467. //TextDecorationCollection myCollection1 = new TextDecorationCollection();
  468. //myCollection1.Add(myUnderline);
  469. //TxbMarkupContent.TextDecorations = myCollection1;
  470. #endregion TO DO
  471. break;
  472. case AnnotArgsType.AnnotLine:
  473. if (data is LineAnnotArgs lineAnnotArgs)
  474. {
  475. if (lineAnnotArgs.HeadLineType >= (C_LINE_TYPE)1 || lineAnnotArgs.TailLineType >= (C_LINE_TYPE)1)
  476. {
  477. BtnSharpArrow.Visibility = Visibility.Visible;
  478. PathArrow.Fill = new SolidColorBrush(lineAnnotArgs.LineColor);
  479. }
  480. else
  481. {
  482. PathSharpLine.Fill = new SolidColorBrush(lineAnnotArgs.LineColor);
  483. BtnSharpLine.Visibility = Visibility.Visible;
  484. }
  485. ///对于形状注释等只有Note 的处理
  486. if (!string.IsNullOrEmpty(data.Content) && string.IsNullOrEmpty(data.MarkupContent))
  487. {
  488. TxbContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  489. TxbContent.Text = "";
  490. }
  491. if (string.IsNullOrEmpty(data.Content) == false)
  492. {
  493. TxbMarkupContent.Text = data.Content;
  494. }
  495. }
  496. break;
  497. case AnnotArgsType.AnnotSquare:
  498. if (data is SquareAnnotArgs squareAnnotArgs)
  499. {
  500. BtnAnnotSquare.Visibility = Visibility.Visible;
  501. RectAnnotSquare.Stroke = new SolidColorBrush(squareAnnotArgs.LineColor);
  502. RectAnnotSquare.Fill = new SolidColorBrush(squareAnnotArgs.BgColor);
  503. ///对于形状注释等只有Note 的处理
  504. if (!string.IsNullOrEmpty(data.Content) && string.IsNullOrEmpty(data.MarkupContent))
  505. {
  506. TxbContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  507. TxbContent.Text = "";
  508. }
  509. }
  510. if (string.IsNullOrEmpty(data.Content) == false)
  511. {
  512. TxbMarkupContent.Text = data.Content;
  513. }
  514. break;
  515. case AnnotArgsType.AnnotCircle:
  516. if (data is CircleAnnotArgs circleAnnotArgs)
  517. {
  518. BtnAnnotCircle.Visibility = Visibility.Visible;
  519. EllipseCircle.Stroke = new SolidColorBrush(circleAnnotArgs.LineColor);
  520. EllipseCircle.Fill = new SolidColorBrush(circleAnnotArgs.BgColor);
  521. ///对于形状注释等只有Note 的处理
  522. if (!string.IsNullOrEmpty(data.Content) && string.IsNullOrEmpty(data.MarkupContent))
  523. {
  524. TxbContent.Text = Regex.Replace(data.Content, "[\r\n]", " ");
  525. TxbContent.Text = "";
  526. }
  527. }
  528. if (string.IsNullOrEmpty(data.Content) == false)
  529. {
  530. TxbMarkupContent.Text = data.Content;
  531. }
  532. break;
  533. case AnnotArgsType.AnnotLink:
  534. BtnAnnotLink.Visibility = Visibility.Visible;
  535. if (data is LinkAnnotArgs linkAnnotArgs)
  536. {
  537. if (string.IsNullOrEmpty(linkAnnotArgs.Content))
  538. {
  539. if (linkAnnotArgs.DestIndex != -1)
  540. {
  541. TxbContent.Text = string.Format($"To Page {linkAnnotArgs.DestIndex + 1}");
  542. }
  543. else
  544. {
  545. TxbContent.Text = string.Format($"{linkAnnotArgs.URI}");
  546. }
  547. }
  548. }
  549. break;
  550. default:
  551. break;
  552. }
  553. }
  554. }
  555. }
  556. }