CPDFAnnotationData.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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. };
  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. }
  94. /// <summary>
  95. /// The dash data for conversion.
  96. /// </summary>
  97. public class CPDFDashData
  98. {
  99. public event PropertyChangedEventHandler PropertyChanged;
  100. public void RaisePropertyChanged(string PropertyName)
  101. {
  102. if (this.PropertyChanged != null)
  103. {
  104. this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(PropertyName));
  105. }
  106. }
  107. private bool _isSolid = true;
  108. public bool IsSolid
  109. {
  110. get => _isSolid;
  111. set
  112. {
  113. _isSolid = value;
  114. RaisePropertyChanged("IsSolid");
  115. }
  116. }
  117. private int _dashSpacing = 1;
  118. public int DashSpacing {
  119. get => _dashSpacing;
  120. set
  121. {
  122. _dashSpacing = value;
  123. RaisePropertyChanged("IsSolid");
  124. }
  125. }
  126. }
  127. public class CPDFFontData
  128. {
  129. public string FontFamily = "Helvetica";
  130. public int FontSize = 20;
  131. public bool IsBold = false;
  132. public bool IsItalic = false;
  133. public TextAlignment TextAlignment = TextAlignment.Left;
  134. }
  135. public abstract class CPDFAnnotationData
  136. {
  137. public CPDFAnnotationType AnnotationType;
  138. public string Note = string.Empty;
  139. public static string Author;
  140. public bool IsLocked = false;
  141. }
  142. public class CPDFMarkupData : CPDFAnnotationData
  143. {
  144. public double Opacity = 1;
  145. public Color Color = Color.FromRgb(255, 0, 0);
  146. }
  147. public class CPDFShapeData : CPDFAnnotationData
  148. {
  149. public Color BorderColor = Color.FromRgb(255, 0, 0);
  150. public Color FillColor = Color.FromRgb(255, 255, 255);
  151. public double Opacity = 1;
  152. public int Thickness = 1;
  153. public DashStyle DashStyle = DashStyles.Solid;
  154. }
  155. public class CPDFLineShapeData : CPDFAnnotationData
  156. {
  157. public Color BorderColor = Color.FromRgb(255, 0, 0);
  158. public double Opacity = 1;
  159. public int Thickness = 1;
  160. public DashStyle DashStyle = DashStyles.Solid;
  161. public LineType LineType = new LineType() { HeadLineType = C_LINE_TYPE.LINETYPE_NONE, TailLineType = C_LINE_TYPE.LINETYPE_NONE };
  162. }
  163. public class CPDFFreeTextData : CPDFAnnotationData
  164. {
  165. public Color BorderColor = Color.FromRgb(255, 0, 0);
  166. public double Opacity = 1;
  167. public string FontFamily = "Helvetica";
  168. public int FontSize = 20;
  169. public bool IsBold = false;
  170. public bool IsItalic = false;
  171. public TextAlignment TextAlignment = TextAlignment.Left;
  172. }
  173. public class CPDFNoteData : CPDFAnnotationData
  174. {
  175. public Color BorderColor = Color.FromRgb(255, 0, 0);
  176. }
  177. public class CPDFFreehandData : CPDFAnnotationData
  178. {
  179. public Color BorderColor = Color.FromRgb(255, 0, 0);
  180. public double Opacity = 1;
  181. public double Thickness = 1;
  182. }
  183. public class CPDFStampData : CPDFAnnotationData, INotifyPropertyChanged
  184. {
  185. public event PropertyChangedEventHandler PropertyChanged;
  186. public void RaisePropertyChanged(string PropertyName)
  187. {
  188. if (this.PropertyChanged != null)
  189. {
  190. this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(PropertyName));
  191. }
  192. }
  193. private string stampText;
  194. public string StampText
  195. {
  196. get { return stampText; }
  197. set
  198. {
  199. stampText = value;
  200. RaisePropertyChanged("StampText");
  201. }
  202. }
  203. private string sourcePath;
  204. public string SourcePath
  205. {
  206. get { return sourcePath; }
  207. set
  208. {
  209. sourcePath = value;
  210. RaisePropertyChanged("SourcePath");
  211. }
  212. }
  213. private int maxWidth;
  214. public int MaxWidth
  215. {
  216. get { return maxWidth; }
  217. set
  218. {
  219. maxWidth = value;
  220. RaisePropertyChanged("MaxWidth");
  221. }
  222. }
  223. private int maxHeight;
  224. public int MaxHeight
  225. {
  226. get { return maxHeight; }
  227. set
  228. {
  229. maxHeight = value;
  230. RaisePropertyChanged("MaxHeight");
  231. }
  232. }
  233. private C_STAMP_TYPE type = C_STAMP_TYPE.UNKNOWN_STAMP;
  234. public C_STAMP_TYPE Type
  235. {
  236. get { return type; }
  237. set
  238. {
  239. type = value;
  240. RaisePropertyChanged("Type");
  241. }
  242. }
  243. public string TypeText
  244. {
  245. get
  246. {
  247. if(Type == C_STAMP_TYPE.TEXT_STAMP)
  248. {
  249. return "Text Stamp";
  250. }
  251. if (Type == C_STAMP_TYPE.IMAGE_STAMP)
  252. {
  253. return "Image Stamp";
  254. }
  255. return type.ToString();
  256. }
  257. }
  258. private double opacity;
  259. public double Opacity
  260. {
  261. get { return opacity; }
  262. set
  263. {
  264. opacity = value;
  265. RaisePropertyChanged("Opacity");
  266. }
  267. }
  268. private BitmapSource imageSource;
  269. public BitmapSource ImageSource
  270. {
  271. get { return imageSource; }
  272. set
  273. {
  274. imageSource = value;
  275. RaisePropertyChanged("ImageSource");
  276. }
  277. }
  278. public C_TEXTSTAMP_COLOR TextColor = C_TEXTSTAMP_COLOR.TEXTSTAMP_WHITE;
  279. public string StampTextDate = "";
  280. public C_TEXTSTAMP_SHAPE TextSharp = C_TEXTSTAMP_SHAPE.TEXTSTAMP_NONE;
  281. public bool IsCheckedDate = false;
  282. public bool IsCheckedTime = false;
  283. }
  284. public class CustomStampList : List<CPDFStampData>
  285. {
  286. }
  287. public class CPDFSignatureData : CPDFAnnotationData, INotifyPropertyChanged
  288. {
  289. public event PropertyChangedEventHandler PropertyChanged;
  290. public void RaisePropertyChanged(string PropertyName)
  291. {
  292. if (this.PropertyChanged != null)
  293. {
  294. this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(PropertyName));
  295. }
  296. }
  297. private string sourcePath;
  298. public string SourcePath
  299. {
  300. get { return sourcePath; }
  301. set
  302. {
  303. sourcePath = value;
  304. RaisePropertyChanged("SourcePath");
  305. }
  306. }
  307. private string drawingPath;
  308. public string DrawingPath
  309. {
  310. get { return drawingPath; }
  311. set
  312. {
  313. drawingPath = value;
  314. RaisePropertyChanged("DrawingPath");
  315. }
  316. }
  317. public SignatureType Type { get; set; }
  318. public double inkThickness { get; set; }
  319. public Color inkColor { get; set; }
  320. }
  321. public class SignatureList : List<CPDFSignatureData>
  322. {
  323. }
  324. }