CPDFAnnotationData.cs 11 KB

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