CPDFAnnotationData.cs 10.0 KB

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