CPDFAnnotationData.cs 10 KB

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