CPDFAnnotationData.cs 11 KB

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