CPDFAnnotationData.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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;
  11. using System.Windows.Markup;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. namespace compdfkit_tools.Data
  15. {
  16. public enum CPDFAnnotationType
  17. {
  18. Unknow = 0,
  19. Highlight,
  20. Underline,
  21. Strikeout,
  22. Squiggly,
  23. FreeText,
  24. Freehand,
  25. Note,
  26. Circle,
  27. Square,
  28. Arrow,
  29. Line,
  30. Stamp,
  31. Signature,
  32. Link,
  33. Audio
  34. }
  35. public enum SignatureType
  36. {
  37. TextType,
  38. Drawing,
  39. ImageType
  40. }
  41. public class LineType : INotifyPropertyChanged
  42. {
  43. private C_LINE_TYPE _headLineType;
  44. public C_LINE_TYPE HeadLineType
  45. {
  46. get { return _headLineType; }
  47. set { _headLineType = value; OnPropertyChanged(nameof(HeadLineType)); }
  48. }
  49. private C_LINE_TYPE _tailLineType;
  50. public C_LINE_TYPE TailLineType
  51. {
  52. get { return _tailLineType; }
  53. set { _tailLineType = value; OnPropertyChanged(nameof(TailLineType)); }
  54. }
  55. public event PropertyChangedEventHandler PropertyChanged;
  56. protected virtual void OnPropertyChanged(string propertyName)
  57. {
  58. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  59. }
  60. }
  61. public static class CPDFAnnotationDictionary
  62. {
  63. public static Dictionary<string, CPDFAnnotationType> GetAnnotationFromTag = new Dictionary<string, CPDFAnnotationType>() {
  64. { "Highlight", CPDFAnnotationType.Highlight },
  65. { "Underline", CPDFAnnotationType.Underline },
  66. { "Strikeout", CPDFAnnotationType.Strikeout },
  67. { "Squiggly", CPDFAnnotationType.Squiggly },
  68. { "Square", CPDFAnnotationType.Square },
  69. { "Circle", CPDFAnnotationType.Circle },
  70. { "Line", CPDFAnnotationType.Line },
  71. { "Arrow", CPDFAnnotationType.Arrow },
  72. { "Freehand", CPDFAnnotationType.Freehand },
  73. { "FreeText", CPDFAnnotationType.FreeText },
  74. { "Note", CPDFAnnotationType.Note },
  75. { "Stamp", CPDFAnnotationType.Stamp },
  76. { "Signature", CPDFAnnotationType.Signature },
  77. { "Link", CPDFAnnotationType.Link },
  78. {"Audio", CPDFAnnotationType.Audio }
  79. };
  80. public static Dictionary<int, C_LINE_TYPE> GetLineTypeFromIndex = new Dictionary<int, C_LINE_TYPE>()
  81. {
  82. { 0, C_LINE_TYPE.LINETYPE_NONE },
  83. { 1, C_LINE_TYPE.LINETYPE_ARROW },
  84. { 2, C_LINE_TYPE.LINETYPE_CLOSEDARROW },
  85. { 3, C_LINE_TYPE.LINETYPE_SQUARE },
  86. { 4, C_LINE_TYPE.LINETYPE_CIRCLE },
  87. { 5, C_LINE_TYPE.LINETYPE_DIAMOND },
  88. { 6, C_LINE_TYPE.LINETYPE_BUTT },
  89. { 7, C_LINE_TYPE.LINETYPE_ROPENARROW },
  90. { 8, C_LINE_TYPE.LINETYPE_RCLOSEDARROW },
  91. { 9, C_LINE_TYPE.LINETYPE_SLASH }
  92. };
  93. public static Dictionary<AnnotArgsType, CPDFAnnotationType> GetAnnotArgsTypeFromAnnotationType = new Dictionary<AnnotArgsType, CPDFAnnotationType>()
  94. {
  95. { AnnotArgsType.AnnotHighlight, CPDFAnnotationType.Highlight},
  96. { AnnotArgsType.AnnotUnderline, CPDFAnnotationType.Underline },
  97. {AnnotArgsType.AnnotSquiggly , CPDFAnnotationType.Squiggly },
  98. {AnnotArgsType.AnnotStrikeout , CPDFAnnotationType.Strikeout},
  99. {AnnotArgsType.AnnotSquare , CPDFAnnotationType.Square },
  100. {AnnotArgsType.AnnotCircle , CPDFAnnotationType.Circle },
  101. {AnnotArgsType.AnnotLine , CPDFAnnotationType.Line},
  102. };
  103. }
  104. /// <summary>
  105. /// 用于换算的dash
  106. /// </summary>
  107. public class CPDFDashData
  108. {
  109. public bool IsSolid = true;
  110. public int DashSpacing = 1;
  111. }
  112. public class CPDFFontData
  113. {
  114. public string FontFamily = "Helvetica";
  115. public int FontSize = 20;
  116. public bool IsBold = false;
  117. public bool IsItalic = false;
  118. public TextAlignment TextAlignment = TextAlignment.Left;
  119. }
  120. public abstract class CPDFAnnotationData
  121. {
  122. public CPDFAnnotationType AnnotationType;
  123. public string Note = string.Empty;
  124. public string Author = "ComPDFKit";
  125. public bool IsLocked = false;
  126. }
  127. public class CPDFMarkupData : CPDFAnnotationData
  128. {
  129. public double Opacity = 1;
  130. public Color Color = Color.FromRgb(255, 0, 0);
  131. }
  132. public class CPDFShapeData : CPDFAnnotationData
  133. {
  134. public Color BorderColor = Color.FromRgb(255, 0, 0);
  135. public Color FillColor = Color.FromRgb(255, 255, 255);
  136. public double Opacity = 1;
  137. public int Thickness = 1;
  138. public DashStyle DashStyle = DashStyles.Solid;
  139. }
  140. public class CPDFLineShapeData : CPDFAnnotationData
  141. {
  142. public Color BorderColor = Color.FromRgb(255, 0, 0);
  143. public double Opacity = 1;
  144. public int Thickness = 1;
  145. public DashStyle DashStyle = DashStyles.Solid;
  146. public LineType LineType = new LineType() { HeadLineType = C_LINE_TYPE.LINETYPE_NONE, TailLineType = C_LINE_TYPE.LINETYPE_NONE };
  147. }
  148. public class CPDFFreeTextData : CPDFAnnotationData
  149. {
  150. public Color BorderColor = Color.FromRgb(255, 0, 0);
  151. public double Opacity = 1;
  152. public CPDFFontData Font = new CPDFFontData();
  153. }
  154. public class CPDFNoteData : CPDFAnnotationData
  155. {
  156. public Color BorderColor = Color.FromRgb(255, 0, 0);
  157. }
  158. public class CPDFFreehandData : CPDFAnnotationData
  159. {
  160. public Color BorderColor = Color.FromRgb(255, 0, 0);
  161. public double Opacity = 1;
  162. public double Thickness = 1;
  163. }
  164. public class CPDFStampData : CPDFAnnotationData, INotifyPropertyChanged
  165. {
  166. public event PropertyChangedEventHandler PropertyChanged;
  167. public void RaisePropertyChanged(string PropertyName)
  168. {
  169. if (this.PropertyChanged != null)
  170. {
  171. this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(PropertyName));
  172. }
  173. }
  174. private string stampText;
  175. public string StampText
  176. {
  177. get { return stampText; }
  178. set
  179. {
  180. stampText = value;
  181. RaisePropertyChanged("StampText");
  182. }
  183. }
  184. private string sourcePath;
  185. public string SourcePath
  186. {
  187. get { return sourcePath; }
  188. set
  189. {
  190. sourcePath = value;
  191. RaisePropertyChanged("SourcePath");
  192. }
  193. }
  194. private int maxWidth;
  195. public int MaxWidth
  196. {
  197. get { return maxWidth; }
  198. set
  199. {
  200. maxWidth = value;
  201. RaisePropertyChanged("MaxWidth");
  202. }
  203. }
  204. private int maxHeight;
  205. public int MaxHeight
  206. {
  207. get { return maxHeight; }
  208. set
  209. {
  210. maxHeight = value;
  211. RaisePropertyChanged("MaxHeight");
  212. }
  213. }
  214. private StampType type = StampType.UNKNOWN_STAMP;
  215. public StampType Type
  216. {
  217. get { return type; }
  218. set
  219. {
  220. type = value;
  221. RaisePropertyChanged("Type");
  222. }
  223. }
  224. private double opacity;
  225. public double Opacity
  226. {
  227. get { return opacity; }
  228. set
  229. {
  230. opacity = value;
  231. RaisePropertyChanged("Opacity");
  232. }
  233. }
  234. private BitmapSource imageSource;
  235. public BitmapSource ImageSource
  236. {
  237. get { return imageSource; }
  238. set
  239. {
  240. imageSource = value;
  241. RaisePropertyChanged("ImageSource");
  242. }
  243. }
  244. public TextStampColor TextColor = TextStampColor.TEXTSTAMP_WHITE;
  245. public string StampTextDate = "";
  246. public TextStampSharp TextSharp = TextStampSharp.TEXTSTAMP_NONE;
  247. public bool IsCheckedDate = false;
  248. public bool IsCheckedTime = false;
  249. }
  250. public class CustomStampList : List<CPDFStampData>
  251. {
  252. }
  253. public class CPDFSignatureData : CPDFAnnotationData, INotifyPropertyChanged
  254. {
  255. public event PropertyChangedEventHandler PropertyChanged;
  256. public void RaisePropertyChanged(string PropertyName)
  257. {
  258. if (this.PropertyChanged != null)
  259. {
  260. this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(PropertyName));
  261. }
  262. }
  263. private string sourcePath;
  264. public string SourcePath
  265. {
  266. get { return sourcePath; }
  267. set
  268. {
  269. sourcePath = value;
  270. RaisePropertyChanged("SourcePath");
  271. }
  272. }
  273. private string drawingPath;
  274. public string DrawingPath
  275. {
  276. get { return drawingPath; }
  277. set
  278. {
  279. drawingPath = value;
  280. RaisePropertyChanged("DrawingPath");
  281. }
  282. }
  283. public SignatureType Type { get; set; }
  284. public double inkThickness { get; set; }
  285. public Color inkColor { get; set; }
  286. }
  287. public class SignatureList : List<CPDFSignatureData>
  288. {
  289. }
  290. }