PolygonMeasureParam.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. CPoint[] pointArray = new CPoint[SavePoints.Count];
  73. SavePoints.CopyTo(pointArray);
  74. polygonTransfer.SavePoints = pointArray.ToList();
  75. }
  76. if (LineColor != null)
  77. {
  78. polygonTransfer.LineColor = (byte[])LineColor.Clone();
  79. }
  80. if (LineDash != null)
  81. {
  82. polygonTransfer.LineDash = (float[])LineDash.Clone();
  83. }
  84. if (EndLineColor != null)
  85. {
  86. polygonTransfer.EndLineColor = (byte[])EndLineColor.Clone();
  87. }
  88. if (EndLineDash != null)
  89. {
  90. polygonTransfer.EndLineDash = EndLineDash.Clone();
  91. }
  92. if (FontColor != null)
  93. {
  94. polygonTransfer.FontColor = (byte[])FontColor.Clone();
  95. }
  96. polygonTransfer.BorderEffector = BorderEffector;
  97. if (measureInfo != null && IsMeasure)
  98. {
  99. CPDFMeasureInfo cPDFMeasureInfo = new CPDFMeasureInfo()
  100. {
  101. Factor = measureInfo.Factor,
  102. Unit = measureInfo.Unit,
  103. DecimalSymbol = measureInfo.DecimalSymbol,
  104. ThousandSymbol = measureInfo.ThousandSymbol,
  105. Display = measureInfo.Display,
  106. Precision = measureInfo.Precision,
  107. UnitPrefix = measureInfo.UnitPrefix,
  108. UnitSuffix = measureInfo.UnitSuffix,
  109. UnitPosition = measureInfo.UnitPosition,
  110. RulerBase = measureInfo.RulerBase,
  111. RulerBaseUnit = measureInfo.RulerBaseUnit,
  112. RulerTranslateUnit = measureInfo.RulerTranslateUnit,
  113. CaptionType = measureInfo.CaptionType,
  114. RulerTranslate = measureInfo.RulerTranslate,
  115. };
  116. polygonTransfer.measureInfo = cPDFMeasureInfo;
  117. }
  118. polygonTransfer.HasFillColor = HasFillColor;
  119. polygonTransfer.LineWidth = LineWidth;
  120. polygonTransfer.EndLineWidth = EndLineWidth;
  121. polygonTransfer.EndTransparency = EndTransparency;
  122. polygonTransfer.FontName = FontName;
  123. polygonTransfer.FontSize = FontSize;
  124. polygonTransfer.IsBold = IsBold;
  125. polygonTransfer.IsItalic = IsItalic;
  126. polygonTransfer.BorderStyle = BorderStyle;
  127. return true;
  128. }
  129. }
  130. }