CPDFAnnotationData.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. using ComPDFKit.PDFAnnotation;
  2. using compdfkit_tools.PDFControl;
  3. using ComPDFKitViewer.AnnotEvent;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. namespace compdfkit_tools.Data
  13. {
  14. public enum AnnotationType
  15. {
  16. None = 0,
  17. Highlight,
  18. Underline,
  19. Strikeout,
  20. Squiggly,
  21. Freetext,
  22. Note,
  23. Circle,
  24. Square,
  25. Arrow,
  26. Line,
  27. Stamp,
  28. Signature,
  29. Link,
  30. Sound
  31. }
  32. public static class CPDFAnnotationDictionary
  33. {
  34. public static Dictionary<string, AnnotationType> GetAnnotationFromTag = new Dictionary<string, AnnotationType>() {
  35. { "Highlight", AnnotationType.Highlight },
  36. { "Underline", AnnotationType.Underline },
  37. { "Strikeout", AnnotationType.Strikeout },
  38. { "Squiggly", AnnotationType.Squiggly },
  39. { "Square", AnnotationType.Square },
  40. { "Circle", AnnotationType.Circle },
  41. { "Line", AnnotationType.Line },
  42. { "Stamp", AnnotationType.Stamp },
  43. { "Arrow", AnnotationType.Arrow }
  44. };
  45. public static Dictionary<int, C_LINE_TYPE> GetLineTypeFromIndex = new Dictionary<int, C_LINE_TYPE>()
  46. {
  47. { 0, C_LINE_TYPE.LINETYPE_NONE },
  48. { 1, C_LINE_TYPE.LINETYPE_ARROW },
  49. { 2, C_LINE_TYPE.LINETYPE_CLOSEDARROW },
  50. { 3, C_LINE_TYPE.LINETYPE_SQUARE },
  51. { 4, C_LINE_TYPE.LINETYPE_CIRCLE },
  52. { 5, C_LINE_TYPE.LINETYPE_DIAMOND },
  53. { 6, C_LINE_TYPE.LINETYPE_BUTT },
  54. { 7, C_LINE_TYPE.LINETYPE_ROPENARROW },
  55. { 8, C_LINE_TYPE.LINETYPE_RCLOSEDARROW },
  56. { 9, C_LINE_TYPE.LINETYPE_SLASH }
  57. };
  58. }
  59. public class LineType
  60. {
  61. public C_LINE_TYPE HeadLineType;
  62. public C_LINE_TYPE TailLineType;
  63. }
  64. /// <summary>
  65. /// 用于换算的dash
  66. /// </summary>
  67. public class CPDFDash
  68. {
  69. public bool IsSolid = true;
  70. public int DashSpacing = 1;
  71. }
  72. public abstract class CPDFAnnotationData
  73. {
  74. public AnnotationType AnnotationType;
  75. public string Note = string.Empty;
  76. public string Author = "ComPDFKit";
  77. public bool IsLocked = false;
  78. }
  79. public class CPDFMarkupData : CPDFAnnotationData
  80. {
  81. public double Opacity = 1;
  82. public Color Color = Color.FromRgb(255, 0, 0);
  83. }
  84. public class CPDFShapeData : CPDFAnnotationData
  85. {
  86. public Color BorderColor = Color.FromRgb(255, 0, 0);
  87. public Color FillColor = Color.FromRgb(255, 255, 255);
  88. public double Opacity = 1;
  89. public double Thickness = 1;
  90. public DashStyle DashStyle = DashStyles.Solid;
  91. }
  92. public class CPDFLineShapeData : CPDFAnnotationData
  93. {
  94. public Color BorderColor = Color.FromRgb(255, 0, 0);
  95. public double Opacity = 1;
  96. public double Thickness = 1;
  97. public DashStyle DashStyle = DashStyles.Solid;
  98. public LineType LineType = new LineType() { HeadLineType = C_LINE_TYPE.LINETYPE_NONE, TailLineType = C_LINE_TYPE.LINETYPE_NONE };
  99. }
  100. public class CPDFStampData : CPDFAnnotationData, INotifyPropertyChanged
  101. {
  102. public event PropertyChangedEventHandler PropertyChanged;
  103. public void RaisePropertyChanged(string PropertyName)
  104. {
  105. if (this.PropertyChanged != null)
  106. {
  107. this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(PropertyName));
  108. }
  109. }
  110. private string stampText;
  111. public string StampText
  112. {
  113. get { return stampText; }
  114. set
  115. {
  116. stampText=value;
  117. RaisePropertyChanged("StampText");
  118. }
  119. }
  120. private string sourcePath;
  121. public string SourcePath
  122. {
  123. get { return sourcePath; }
  124. set
  125. {
  126. sourcePath = value;
  127. RaisePropertyChanged("SourcePath");
  128. }
  129. }
  130. private int maxWidth;
  131. public int MaxWidth
  132. {
  133. get { return maxWidth; }
  134. set
  135. {
  136. maxWidth = value;
  137. RaisePropertyChanged("MaxWidth");
  138. }
  139. }
  140. private int maxHeight;
  141. public int MaxHeight
  142. {
  143. get { return maxHeight; }
  144. set
  145. {
  146. maxHeight = value;
  147. RaisePropertyChanged("MaxHeight");
  148. }
  149. }
  150. private StampType type = StampType.UNKNOWN_STAMP;
  151. public StampType Type
  152. {
  153. get { return type; }
  154. set
  155. {
  156. type = value;
  157. RaisePropertyChanged("Type");
  158. }
  159. }
  160. private double opacity;
  161. public double Opacity
  162. {
  163. get { return opacity; }
  164. set
  165. {
  166. opacity = value;
  167. RaisePropertyChanged("Opacity");
  168. }
  169. }
  170. private BitmapSource imageSource;
  171. public BitmapSource ImageSource
  172. {
  173. get { return imageSource; }
  174. set
  175. {
  176. imageSource = value;
  177. RaisePropertyChanged("ImageSource");
  178. }
  179. }
  180. public TextStampColor TextColor = TextStampColor.TEXTSTAMP_WHITE;
  181. public string StampTextDate = "";
  182. public TextStampSharp TextSharp = TextStampSharp.TEXTSTAMP_NONE;
  183. public bool IsCheckedDate=false;
  184. public bool IsCheckedTime=false;
  185. }
  186. public class CustomStampList : List<CPDFStampData>
  187. {
  188. }
  189. }