AnnotationListItemViewModel.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using ComPDFKitViewer.AnnotEvent;
  2. using PDF_Office.Helper;
  3. using Prism.Commands;
  4. using Prism.Mvvm;
  5. using Prism.Regions;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. using System.Windows.Controls;
  13. using System.Windows.Media;
  14. namespace PDF_Office.ViewModels.BOTA
  15. {
  16. internal class AnnotationListItemViewModel : BindableBase
  17. {
  18. private Visibility pathTxtIcoVisibility = Visibility.Collapsed;
  19. public Visibility PathTxtIcoVisibility
  20. {
  21. get { return pathTxtIcoVisibility; }
  22. set
  23. {
  24. SetProperty(ref pathTxtIcoVisibility, value);
  25. }
  26. }
  27. public DelegateCommand<object> GridIcoLoadedCommand { get; set; }
  28. public AnnotationListItemViewModel()
  29. {
  30. GridIcoLoadedCommand = new DelegateCommand<object>(GridIcoLoaded);
  31. }
  32. private void GridIcoLoaded(object obj)
  33. {
  34. if (obj is CompositeCommandParameter commandParameter)
  35. {
  36. if (commandParameter.EventArgs is RoutedEventArgs eventArgs && commandParameter.Parameter is object[] parameters)
  37. {
  38. if ((eventArgs.Source as Grid).DataContext is AnnotHandlerEventArgs data)
  39. {
  40. TextBlock txbContext = parameters[0] as TextBlock;
  41. TextBlock txbMarkUpContent = parameters[1] as TextBlock;
  42. Grid grid = parameters[2] as Grid;
  43. switch (data.EventType)
  44. {
  45. case AnnotArgsType.AnnotFreeText:
  46. PathTxtIcoVisibility = Visibility.Visible;
  47. txbMarkUpContent.Foreground = new SolidColorBrush((data as FreeTextAnnotArgs).FontColor);
  48. //txtContext.FontSize = (data as FreeTextAnnotArgs).FontSize;
  49. //txtContext.FontFamily = (data as FreeTextAnnotArgs).Family;
  50. if ((data as FreeTextAnnotArgs).HasBgColor)
  51. {
  52. txbContext.Background = new SolidColorBrush((data as FreeTextAnnotArgs).BgColor);
  53. }
  54. break;
  55. //case AnnotArgsType.AnnotHighlight:
  56. // highlight.Visibility = Visibility.Visible;
  57. // highlightcolor.Fill = new SolidColorBrush((data as TextHighlightAnnotArgs).Color);
  58. // txtContext.Text = data.Content;
  59. // // txtContext.Background = new SolidColorBrush((data as TextHighlightAnnotArgs).HighlightColor);
  60. // break;
  61. //case AnnotArgsType.AnnotFreehand:
  62. // freehand.Visibility = Visibility.Visible;
  63. // freehandcolor.Fill = new SolidColorBrush((data as FreehandAnnotArgs).InkColor);
  64. // break;
  65. //case AnnotArgsType.AnnotLine:
  66. // if ((data as LineAnnotArgs).HeadLineType >= (C_LINE_TYPE)1 || (data as LineAnnotArgs).TailLineType >= (C_LINE_TYPE)1)
  67. // {
  68. // arrow.Visibility = Visibility.Visible;
  69. // arrow.Fill = new SolidColorBrush((data as LineAnnotArgs).LineColor);
  70. // }
  71. // else
  72. // {
  73. // line.Stroke = new SolidColorBrush((data as LineAnnotArgs).LineColor);
  74. // line.Visibility = Visibility.Visible;
  75. // }
  76. // break;
  77. //case AnnotArgsType.AnnotSquiggly://波浪线
  78. // AnnotSquiggly.Visibility = Visibility.Visible;
  79. // AnnotSquigglycolor.Stroke = new SolidColorBrush((data as TextSquigglyAnnotArgs).Color);
  80. // txtContext.Text = data.Content;
  81. // TextDecoration mySquiggly = new TextDecoration();
  82. // Pen myPen = new Pen();
  83. // myPen.Brush = new SolidColorBrush((data as TextSquigglyAnnotArgs).Color);
  84. // myPen.Brush.Opacity = 0.8;
  85. // myPen.Thickness = 2;
  86. // myPen.DashStyle = DashStyles.Dash;
  87. // mySquiggly.Pen = myPen;
  88. // mySquiggly.PenThicknessUnit = TextDecorationUnit.FontRecommended;
  89. // TextDecorationCollection myCollection = new TextDecorationCollection();
  90. // myCollection.Add(mySquiggly);
  91. // //txtContext.TextDecorations = myCollection;
  92. // break;
  93. //case AnnotArgsType.AnnotStamp:
  94. // stamp.Visibility = Visibility.Visible;
  95. // break;
  96. //case AnnotArgsType.AnnotStrikeout://删除线
  97. // AnnotStrikeout.Visibility = Visibility.Visible;
  98. // AnnotStrikeoutycolor.Stroke = new SolidColorBrush((data as TextStrikeoutAnnotArgs).Color);
  99. // AnnotStrikeoutycolor.VerticalAlignment = VerticalAlignment.Center;
  100. // txtContext.Text = data.Content;
  101. // TextDecoration myStrikeout = new TextDecoration();
  102. // Pen myPen2 = new Pen();
  103. // myPen2.Brush = new SolidColorBrush((data as TextStrikeoutAnnotArgs).Color);
  104. // myPen2.Brush.Opacity = 0.8;
  105. // myPen2.Thickness = 1;
  106. // myStrikeout.Pen = myPen2;
  107. // myStrikeout.PenOffset = -3;
  108. // myStrikeout.PenThicknessUnit = TextDecorationUnit.FontRecommended;
  109. // TextDecorationCollection myCollection2 = new TextDecorationCollection();
  110. // myCollection2.Add(myStrikeout);
  111. // //因为波浪线无法实现 暂时只显示文字 不显示下划线,删除线等
  112. // //txtContext.TextDecorations = myCollection2;
  113. // break;
  114. //case AnnotArgsType.AnnotSticky://便签
  115. // sticky.Visibility = Visibility;
  116. // sticky.Fill = new SolidColorBrush((data as StickyAnnotArgs).Color);
  117. // break;
  118. //case AnnotArgsType.AnnotUnderline:
  119. // AnnotStrikeout.Visibility = Visibility.Visible;
  120. // AnnotStrikeoutycolor.VerticalAlignment = VerticalAlignment.Bottom;
  121. // txtContext.Text = data.Content;
  122. // AnnotStrikeoutycolor.Stroke = new SolidColorBrush((data as TextUnderlineAnnotArgs).Color);
  123. // TextDecoration myUnderline = new TextDecoration();
  124. // Pen myPen1 = new Pen();
  125. // myPen1.Brush = new SolidColorBrush((data as TextUnderlineAnnotArgs).Color);
  126. // myPen1.Brush.Opacity = 0.8;
  127. // myPen1.Thickness = 2;
  128. // myUnderline.Pen = myPen1;
  129. // myUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended;
  130. // TextDecorationCollection myCollection1 = new TextDecorationCollection();
  131. // myCollection1.Add(myUnderline);
  132. // //txtContext.TextDecorations = myCollection1;
  133. // break;
  134. //case AnnotArgsType.AnnotSquare:
  135. // rect.Visibility = Visibility.Visible;
  136. // rect.Stroke = new SolidColorBrush((data as SquareAnnotArgs).LineColor);
  137. // rect.Fill = new SolidColorBrush((data as SquareAnnotArgs).BgColor);
  138. // break;
  139. //case AnnotArgsType.AnnotCircle:
  140. // circle.Visibility = Visibility.Visible;
  141. // circle.Stroke = new SolidColorBrush((data as CircleAnnotArgs).LineColor);
  142. // circle.Fill = new SolidColorBrush((data as CircleAnnotArgs).BgColor);
  143. // break;
  144. default:
  145. break;
  146. }
  147. }
  148. }
  149. }
  150. }
  151. }
  152. }