PolygonMeasureParam.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using ComPDFKit.Import;
  2. using ComPDFKit.Measure;
  3. using ComPDFKit.PDFAnnotation;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Net;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Media;
  12. namespace ComPDFKit.Tool
  13. {
  14. public class PolygonMeasureParam : AnnotParam
  15. {
  16. public PolygonMeasureParam()
  17. {
  18. CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON;
  19. }
  20. public byte[] FillColor { get; set; } = new byte[] { 255, 0, 0, };
  21. public bool HasFillColor { get; set; }
  22. public byte[] LineColor
  23. {
  24. get;
  25. set;
  26. }
  27. public float LineWidth { get; set; }
  28. public float[] LineDash { get; set; }
  29. public List<CPoint> SavePoints { get; set; }
  30. public byte[] EndLineColor { get; set; }
  31. public double EndLineWidth { get; set; }
  32. public double EndTransparency { get; set; }
  33. public DashStyle EndLineDash { get; set; }
  34. public CPDFBorderEffector BorderEffector
  35. {
  36. get;
  37. set;
  38. }
  39. public string FontName { get; set; }
  40. public double FontSize { get; set; }
  41. public byte[] FontColor { get; set; }
  42. public bool IsBold { get; set; }
  43. public bool IsItalic { get; set; }
  44. public bool IsMeasure
  45. {
  46. get;
  47. set;
  48. } = true;
  49. public C_BORDER_STYLE BorderStyle { get; set; }
  50. public CPDFMeasureInfo measureInfo
  51. {
  52. get;
  53. set;
  54. }
  55. public override bool CopyTo(AnnotParam transfer)
  56. {
  57. PolygonMeasureParam polygonTransfer = transfer as PolygonMeasureParam;
  58. if (polygonTransfer == null)
  59. {
  60. return false;
  61. }
  62. if (!base.CopyTo(polygonTransfer))
  63. {
  64. return false;
  65. }
  66. if (FillColor != null)
  67. {
  68. polygonTransfer.FillColor = (byte[])FillColor.Clone();
  69. }
  70. if (SavePoints != null)
  71. {
  72. polygonTransfer.SavePoints.CopyTo(SavePoints.ToArray());
  73. }
  74. if (LineColor != null)
  75. {
  76. polygonTransfer.LineColor = (byte[])LineColor.Clone();
  77. }
  78. if (LineDash != null)
  79. {
  80. polygonTransfer.LineDash = (float[])LineDash.Clone();
  81. }
  82. if (EndLineColor != null)
  83. {
  84. polygonTransfer.EndLineColor = (byte[])EndLineColor.Clone();
  85. }
  86. if (EndLineDash != null)
  87. {
  88. polygonTransfer.EndLineDash = EndLineDash.Clone();
  89. }
  90. if (FontColor != null)
  91. {
  92. polygonTransfer.FontColor = (byte[])FontColor.Clone();
  93. }
  94. polygonTransfer.BorderEffector = BorderEffector;
  95. if (measureInfo != null && IsMeasure)
  96. {
  97. CPDFMeasureInfo cPDFMeasureInfo = new CPDFMeasureInfo()
  98. {
  99. Factor = measureInfo.Factor,
  100. Unit = measureInfo.Unit,
  101. DecimalSymbol = measureInfo.DecimalSymbol,
  102. ThousandSymbol = measureInfo.ThousandSymbol,
  103. Display = measureInfo.Display,
  104. Precision = measureInfo.Precision,
  105. UnitPrefix = measureInfo.UnitPrefix,
  106. UnitSuffix = measureInfo.UnitSuffix,
  107. UnitPosition = measureInfo.UnitPosition,
  108. RulerBase = measureInfo.RulerBase,
  109. RulerBaseUnit = measureInfo.RulerBaseUnit,
  110. RulerTranslateUnit = measureInfo.RulerTranslateUnit,
  111. CaptionType = measureInfo.CaptionType,
  112. RulerTranslate = measureInfo.RulerTranslate,
  113. };
  114. polygonTransfer.measureInfo = cPDFMeasureInfo;
  115. }
  116. polygonTransfer.HasFillColor = HasFillColor;
  117. polygonTransfer.LineWidth = LineWidth;
  118. polygonTransfer.EndLineWidth = EndLineWidth;
  119. polygonTransfer.EndTransparency = EndTransparency;
  120. polygonTransfer.FontName = FontName;
  121. polygonTransfer.FontSize = FontSize;
  122. polygonTransfer.IsBold = IsBold;
  123. polygonTransfer.IsItalic = IsItalic;
  124. polygonTransfer.BorderStyle = BorderStyle;
  125. return true;
  126. }
  127. }
  128. }