CPDFAnnotationData.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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 string FontFamily = "Helvetica";
  153. public int FontSize = 20;
  154. public bool IsBold = false;
  155. public bool IsItalic = false;
  156. public TextAlignment TextAlignment = TextAlignment.Left;
  157. }
  158. public class CPDFNoteData : CPDFAnnotationData
  159. {
  160. public Color BorderColor = Color.FromRgb(255, 0, 0);
  161. }
  162. public class CPDFFreehandData : CPDFAnnotationData
  163. {
  164. public Color BorderColor = Color.FromRgb(255, 0, 0);
  165. public double Opacity = 1;
  166. public double Thickness = 1;
  167. }
  168. public class CPDFStampData : CPDFAnnotationData, INotifyPropertyChanged
  169. {
  170. public event PropertyChangedEventHandler PropertyChanged;
  171. public void RaisePropertyChanged(string PropertyName)
  172. {
  173. if (this.PropertyChanged != null)
  174. {
  175. this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(PropertyName));
  176. }
  177. }
  178. private string stampText;
  179. public string StampText
  180. {
  181. get { return stampText; }
  182. set
  183. {
  184. stampText = value;
  185. RaisePropertyChanged("StampText");
  186. }
  187. }
  188. private string sourcePath;
  189. public string SourcePath
  190. {
  191. get { return sourcePath; }
  192. set
  193. {
  194. sourcePath = value;
  195. RaisePropertyChanged("SourcePath");
  196. }
  197. }
  198. private int maxWidth;
  199. public int MaxWidth
  200. {
  201. get { return maxWidth; }
  202. set
  203. {
  204. maxWidth = value;
  205. RaisePropertyChanged("MaxWidth");
  206. }
  207. }
  208. private int maxHeight;
  209. public int MaxHeight
  210. {
  211. get { return maxHeight; }
  212. set
  213. {
  214. maxHeight = value;
  215. RaisePropertyChanged("MaxHeight");
  216. }
  217. }
  218. private StampType type = StampType.UNKNOWN_STAMP;
  219. public StampType Type
  220. {
  221. get { return type; }
  222. set
  223. {
  224. type = value;
  225. RaisePropertyChanged("Type");
  226. }
  227. }
  228. private double opacity;
  229. public double Opacity
  230. {
  231. get { return opacity; }
  232. set
  233. {
  234. opacity = value;
  235. RaisePropertyChanged("Opacity");
  236. }
  237. }
  238. private BitmapSource imageSource;
  239. public BitmapSource ImageSource
  240. {
  241. get { return imageSource; }
  242. set
  243. {
  244. imageSource = value;
  245. RaisePropertyChanged("ImageSource");
  246. }
  247. }
  248. public TextStampColor TextColor = TextStampColor.TEXTSTAMP_WHITE;
  249. public string StampTextDate = "";
  250. public TextStampSharp TextSharp = TextStampSharp.TEXTSTAMP_NONE;
  251. public bool IsCheckedDate = false;
  252. public bool IsCheckedTime = false;
  253. }
  254. public class CustomStampList : List<CPDFStampData>
  255. {
  256. }
  257. public class CPDFSignatureData : CPDFAnnotationData, INotifyPropertyChanged
  258. {
  259. public event PropertyChangedEventHandler PropertyChanged;
  260. public void RaisePropertyChanged(string PropertyName)
  261. {
  262. if (this.PropertyChanged != null)
  263. {
  264. this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(PropertyName));
  265. }
  266. }
  267. private string sourcePath;
  268. public string SourcePath
  269. {
  270. get { return sourcePath; }
  271. set
  272. {
  273. sourcePath = value;
  274. RaisePropertyChanged("SourcePath");
  275. }
  276. }
  277. private string drawingPath;
  278. public string DrawingPath
  279. {
  280. get { return drawingPath; }
  281. set
  282. {
  283. drawingPath = value;
  284. RaisePropertyChanged("DrawingPath");
  285. }
  286. }
  287. public SignatureType Type { get; set; }
  288. public double inkThickness { get; set; }
  289. public Color inkColor { get; set; }
  290. }
  291. public class SignatureList : List<CPDFSignatureData>
  292. {
  293. }
  294. }