PolyLineMeasureParam.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Media;
  10. namespace ComPDFKit.Tool
  11. {
  12. public class PolyLineMeasureParam : AnnotParam
  13. {
  14. public PolyLineMeasureParam()
  15. {
  16. CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE;
  17. Transparency = 255;
  18. }
  19. public byte[] LineColor { get; set; } = new byte[] { 255, 0, 0, };
  20. public float LineWidth { get; set; } = 2;
  21. public float[] LineDash { get; set; }
  22. public List<CPoint> SavePoints { get; set; }
  23. public string FontName { get; set; } = "Arial";
  24. public double FontSize { get; set; } = 14;
  25. public byte[] FontColor { get; set; } = new byte[] { 255, 0, 0, };
  26. public bool IsBold { get; set; }
  27. public bool IsItalic { get; set; }
  28. public C_BORDER_STYLE BorderStyle { get; set; }
  29. public CPDFMeasureInfo measureInfo { get; set; } =
  30. new CPDFMeasureInfo
  31. {
  32. Unit = CPDFMeasure.CPDF_CM,
  33. Precision = CPDFMeasure.PRECISION_VALUE_TWO,
  34. RulerBase = 1,
  35. RulerBaseUnit = CPDFMeasure.CPDF_CM,
  36. RulerTranslate = 1,
  37. RulerTranslateUnit = CPDFMeasure.CPDF_CM,
  38. CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH,
  39. };
  40. public override bool CopyTo(AnnotParam transfer)
  41. {
  42. PolyLineMeasureParam polygonTransfer = transfer as PolyLineMeasureParam;
  43. if (polygonTransfer == null)
  44. {
  45. return false;
  46. }
  47. if (!base.CopyTo(polygonTransfer))
  48. {
  49. return false;
  50. }
  51. if (LineColor != null)
  52. {
  53. polygonTransfer.LineColor = (byte[])LineColor.Clone();
  54. }
  55. if (LineDash != null)
  56. {
  57. polygonTransfer.LineDash = (float[])LineDash.Clone();
  58. }
  59. if (SavePoints != null)
  60. {
  61. polygonTransfer.SavePoints.CopyTo(SavePoints.ToArray());
  62. }
  63. if (FontColor != null)
  64. {
  65. polygonTransfer.FontColor = (byte[])FontColor.Clone();
  66. }
  67. if (measureInfo != null)
  68. {
  69. CPDFMeasureInfo cPDFMeasureInfo = new CPDFMeasureInfo()
  70. {
  71. Factor = measureInfo.Factor,
  72. Unit = measureInfo.Unit,
  73. DecimalSymbol = measureInfo.DecimalSymbol,
  74. ThousandSymbol = measureInfo.ThousandSymbol,
  75. Display = measureInfo.Display,
  76. Precision = measureInfo.Precision,
  77. UnitPrefix = measureInfo.UnitPrefix,
  78. UnitSuffix = measureInfo.UnitSuffix,
  79. UnitPosition = measureInfo.UnitPosition,
  80. RulerBase = measureInfo.RulerBase,
  81. RulerBaseUnit = measureInfo.RulerBaseUnit,
  82. RulerTranslateUnit = measureInfo.RulerTranslateUnit,
  83. CaptionType = measureInfo.CaptionType,
  84. RulerTranslate = measureInfo.RulerTranslate,
  85. };
  86. polygonTransfer.measureInfo = cPDFMeasureInfo;
  87. }
  88. polygonTransfer.LineWidth = LineWidth;
  89. polygonTransfer.FontName = FontName;
  90. polygonTransfer.FontSize = FontSize;
  91. polygonTransfer.IsBold = IsBold;
  92. polygonTransfer.IsItalic = IsItalic;
  93. polygonTransfer.BorderStyle = BorderStyle;
  94. return true;
  95. }
  96. }
  97. }