CPDFAnnotationData.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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 BorderColor = Color.FromRgb(255, 0, 0);
  160. public Color FillColor = Color.FromRgb(255, 255, 255);
  161. public double Opacity = 1;
  162. public int Thickness = 1;
  163. public bool IsMeasured = false;
  164. public DashStyle DashStyle = DashStyles.Solid;
  165. }
  166. public class CPDFLineShapeData : CPDFAnnotationData
  167. {
  168. public Color BorderColor = Color.FromRgb(255, 0, 0);
  169. public double Opacity = 1;
  170. public int Thickness = 1;
  171. public DashStyle DashStyle = DashStyles.Solid;
  172. public LineType LineType = new LineType() { HeadLineType = C_LINE_TYPE.LINETYPE_NONE, TailLineType = C_LINE_TYPE.LINETYPE_NONE };
  173. }
  174. public class CPDFFreeTextData : CPDFAnnotationData
  175. {
  176. public Color BorderColor = Color.FromRgb(255, 0, 0);
  177. public double Opacity = 1;
  178. public string FontFamily = "Helvetica";
  179. public int FontSize = 20;
  180. public bool IsBold = false;
  181. public bool IsItalic = false;
  182. public TextAlignment TextAlignment = TextAlignment.Left;
  183. }
  184. public class CPDFNoteData : CPDFAnnotationData
  185. {
  186. public Color BorderColor = Color.FromRgb(255, 0, 0);
  187. }
  188. public class CPDFFreehandData : CPDFAnnotationData
  189. {
  190. public Color BorderColor = Color.FromRgb(255, 0, 0);
  191. public double Opacity = 1;
  192. public double Thickness = 1;
  193. }
  194. public class CPDFStampData : CPDFAnnotationData, INotifyPropertyChanged
  195. {
  196. public event PropertyChangedEventHandler PropertyChanged;
  197. public void RaisePropertyChanged(string PropertyName)
  198. {
  199. if (this.PropertyChanged != null)
  200. {
  201. this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(PropertyName));
  202. }
  203. }
  204. private string stampText;
  205. public string StampText
  206. {
  207. get { return stampText; }
  208. set
  209. {
  210. stampText = value;
  211. RaisePropertyChanged("StampText");
  212. }
  213. }
  214. private string sourcePath;
  215. public string SourcePath
  216. {
  217. get { return sourcePath; }
  218. set
  219. {
  220. sourcePath = value;
  221. RaisePropertyChanged("SourcePath");
  222. }
  223. }
  224. private int maxWidth;
  225. public int MaxWidth
  226. {
  227. get { return maxWidth; }
  228. set
  229. {
  230. maxWidth = value;
  231. RaisePropertyChanged("MaxWidth");
  232. }
  233. }
  234. private int maxHeight;
  235. public int MaxHeight
  236. {
  237. get { return maxHeight; }
  238. set
  239. {
  240. maxHeight = value;
  241. RaisePropertyChanged("MaxHeight");
  242. }
  243. }
  244. private C_STAMP_TYPE type = C_STAMP_TYPE.UNKNOWN_STAMP;
  245. public C_STAMP_TYPE Type
  246. {
  247. get { return type; }
  248. set
  249. {
  250. type = value;
  251. RaisePropertyChanged("Type");
  252. }
  253. }
  254. public string TypeText
  255. {
  256. get
  257. {
  258. if (Type == C_STAMP_TYPE.TEXT_STAMP)
  259. {
  260. return "Text Stamp";
  261. }
  262. if (Type == C_STAMP_TYPE.IMAGE_STAMP)
  263. {
  264. return "Image Stamp";
  265. }
  266. return type.ToString();
  267. }
  268. }
  269. private double opacity;
  270. public double Opacity
  271. {
  272. get { return opacity; }
  273. set
  274. {
  275. opacity = value;
  276. RaisePropertyChanged("Opacity");
  277. }
  278. }
  279. private BitmapSource imageSource;
  280. public BitmapSource ImageSource
  281. {
  282. get { return imageSource; }
  283. set
  284. {
  285. imageSource = value;
  286. RaisePropertyChanged("ImageSource");
  287. }
  288. }
  289. public C_TEXTSTAMP_COLOR TextColor = C_TEXTSTAMP_COLOR.TEXTSTAMP_WHITE;
  290. public string StampTextDate = "";
  291. public C_TEXTSTAMP_SHAPE TextSharp = C_TEXTSTAMP_SHAPE.TEXTSTAMP_NONE;
  292. public bool IsCheckedDate = false;
  293. public bool IsCheckedTime = false;
  294. }
  295. public class CustomStampList : List<CPDFStampData>
  296. {
  297. }
  298. public class CPDFSignatureData : CPDFAnnotationData, INotifyPropertyChanged
  299. {
  300. public event PropertyChangedEventHandler PropertyChanged;
  301. public void RaisePropertyChanged(string PropertyName)
  302. {
  303. if (this.PropertyChanged != null)
  304. {
  305. this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(PropertyName));
  306. }
  307. }
  308. private string sourcePath;
  309. public string SourcePath
  310. {
  311. get { return sourcePath; }
  312. set
  313. {
  314. sourcePath = value;
  315. RaisePropertyChanged("SourcePath");
  316. }
  317. }
  318. private string drawingPath;
  319. public string DrawingPath
  320. {
  321. get { return drawingPath; }
  322. set
  323. {
  324. drawingPath = value;
  325. RaisePropertyChanged("DrawingPath");
  326. }
  327. }
  328. public SignatureType Type { get; set; }
  329. public double inkThickness { get; set; }
  330. public Color inkColor { get; set; }
  331. }
  332. public class SignatureList : List<CPDFSignatureData>
  333. {
  334. }
  335. }