WatermarkData.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. using ComPDFKit.PDFWatermark;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Runtime.CompilerServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows.Media;
  9. namespace Compdfkit_Tools.PDFControl
  10. {
  11. public class WatermarkData
  12. {
  13. public event EventHandler ValueChanged;
  14. private C_Watermark_Type _type;
  15. public C_Watermark_Type Type
  16. {
  17. get => _type;
  18. set => UpdateProper(ref _type, value);
  19. }
  20. //Text--------------
  21. private string _text;
  22. public string Text
  23. {
  24. get => _text;
  25. set => UpdateProper(ref _text, value);
  26. }
  27. private string _fontName;
  28. public string FontName
  29. {
  30. get => _fontName;
  31. set => UpdateProper(ref _fontName, value);
  32. }
  33. private float _fontSize;
  34. public float FontSize
  35. {
  36. get => _fontSize;
  37. set => UpdateProper(ref _fontSize, value);
  38. }
  39. private byte[] _color;
  40. public byte[] Color
  41. {
  42. get => _color;
  43. set => UpdateProper(ref _color, value);
  44. }
  45. //----------------
  46. //Image---------
  47. private string _imagePath;
  48. public string ImagePath
  49. {
  50. get => _imagePath;
  51. set => UpdateProper(ref _imagePath, value);
  52. }
  53. private int _imageScale;
  54. public int ImageScale
  55. {
  56. get => _imageScale;
  57. set => UpdateProper(ref _imageScale, value);
  58. }
  59. //----------------
  60. private int _rotation;
  61. public int Rotation
  62. {
  63. get => _rotation;
  64. set => UpdateProper(ref _rotation, value);
  65. }
  66. private byte _opacity;
  67. public byte Opacity
  68. {
  69. get => _opacity;
  70. set => UpdateProper(ref _opacity, value);
  71. }
  72. private C_Watermark_Vertalign _vertalign;
  73. public C_Watermark_Vertalign Vertalign
  74. {
  75. get => _vertalign;
  76. set => UpdateProper(ref _vertalign, value);
  77. }
  78. private C_Watermark_Horizalign _horizalign;
  79. public C_Watermark_Horizalign Horizalign
  80. {
  81. get => _horizalign;
  82. set=> UpdateProper(ref _horizalign, value);
  83. }
  84. private float _vertOffset;
  85. public float VertOffset
  86. {
  87. get => _vertOffset;
  88. set => UpdateProper(ref _vertOffset, value);
  89. }
  90. private float _horizOffset;
  91. public float HorizOffset
  92. {
  93. get => _horizOffset;
  94. set => UpdateProper(ref _horizOffset, value);
  95. }
  96. private bool _isFront;
  97. public bool IsFront
  98. {
  99. get => _isFront;
  100. set => UpdateProper(ref _isFront, value);
  101. }
  102. private bool _isFullScreen;
  103. public bool IsFullScreen
  104. {
  105. get => _isFullScreen;
  106. set => UpdateProper(ref _isFullScreen, value);
  107. }
  108. private float _verticalSpacing;
  109. public float VerticalSpacing
  110. {
  111. get => _verticalSpacing;
  112. set => UpdateProper(ref _verticalSpacing, value);
  113. }
  114. private float _horizontalSpacing;
  115. public float HorizontalSpacing
  116. {
  117. get => _horizontalSpacing;
  118. set => UpdateProper(ref _horizontalSpacing, value);
  119. }
  120. public WatermarkData()
  121. {
  122. }
  123. protected void OnValueChanged(string propertyName = null)
  124. {
  125. ValueChanged?.Invoke(this, new EventArgs());
  126. }
  127. protected bool UpdateProper<T>(ref T properValue, T newValue, [CallerMemberName] string properName = "")
  128. {
  129. if (object.Equals(properValue, newValue))
  130. return false;
  131. properValue = newValue;
  132. OnValueChanged(properName);
  133. return true;
  134. }
  135. }
  136. public class TextWatermarkData : WatermarkData
  137. {
  138. }
  139. public class ImageWatermarkData : WatermarkData
  140. {
  141. }
  142. }