LineMeasureParam.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 LineMeasureParam : AnnotParam
  13. {
  14. public LineMeasureParam()
  15. {
  16. CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_LINE;
  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; } = new float[] { };
  22. public CPoint HeadPoint { get; set; }
  23. public CPoint TailPoint { get; set; }
  24. public C_LINE_TYPE HeadLineType { get; set; } = C_LINE_TYPE.LINETYPE_ARROW;
  25. public C_LINE_TYPE TailLineType { get; set; } = C_LINE_TYPE.LINETYPE_ARROW;
  26. public string FontName { get; set; } = "Arial";
  27. public double FontSize { get; set; } = 14;
  28. public byte[] FontColor { get; set; } = new byte[] { 255, 0, 0 };
  29. public bool IsBold { get; set; } = false;
  30. public bool IsItalic { get; set; } = false;
  31. public C_BORDER_STYLE BorderStyle { get; set; } = C_BORDER_STYLE.BS_SOLID;
  32. public CPDFMeasureInfo measureInfo { get; set; }
  33. = new CPDFMeasureInfo
  34. {
  35. Unit = CPDFMeasure.CPDF_CM,
  36. Precision = CPDFMeasure.PRECISION_VALUE_TWO,
  37. RulerBase = 1,
  38. RulerBaseUnit = CPDFMeasure.CPDF_CM,
  39. RulerTranslate = 1,
  40. RulerTranslateUnit = CPDFMeasure.CPDF_CM,
  41. CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH,
  42. };
  43. public override bool CopyTo(AnnotParam transfer)
  44. {
  45. LineMeasureParam polygonTransfer = transfer as LineMeasureParam;
  46. if (polygonTransfer == null)
  47. {
  48. return false;
  49. }
  50. if (!base.CopyTo(polygonTransfer))
  51. {
  52. return false;
  53. }
  54. if (LineColor != null)
  55. {
  56. polygonTransfer.LineColor = (byte[])LineColor.Clone();
  57. }
  58. if (LineDash != null)
  59. {
  60. polygonTransfer.LineDash = (float[])LineDash.Clone();
  61. }
  62. if (FontColor != null)
  63. {
  64. polygonTransfer.FontColor = (byte[])FontColor.Clone();
  65. }
  66. if (measureInfo != null)
  67. {
  68. CPDFMeasureInfo cPDFMeasureInfo = new CPDFMeasureInfo()
  69. {
  70. Factor = measureInfo.Factor,
  71. Unit = measureInfo.Unit,
  72. DecimalSymbol = measureInfo.DecimalSymbol,
  73. ThousandSymbol = measureInfo.ThousandSymbol,
  74. Display = measureInfo.Display,
  75. Precision = measureInfo.Precision,
  76. UnitPrefix = measureInfo.UnitPrefix,
  77. UnitSuffix = measureInfo.UnitSuffix,
  78. UnitPosition = measureInfo.UnitPosition,
  79. RulerBase = measureInfo.RulerBase,
  80. RulerBaseUnit = measureInfo.RulerBaseUnit,
  81. RulerTranslateUnit = measureInfo.RulerTranslateUnit,
  82. RulerTranslate = measureInfo.RulerTranslate,
  83. CaptionType = measureInfo.CaptionType,
  84. };
  85. polygonTransfer.measureInfo = cPDFMeasureInfo;
  86. }
  87. polygonTransfer.LineWidth = LineWidth;
  88. polygonTransfer.HeadLineType = HeadLineType;
  89. polygonTransfer.TailLineType = TailLineType;
  90. polygonTransfer.FontName = FontName;
  91. polygonTransfer.FontSize = FontSize;
  92. polygonTransfer.IsBold = IsBold;
  93. polygonTransfer.IsItalic = IsItalic;
  94. polygonTransfer.HeadPoint = HeadPoint;
  95. polygonTransfer.TailPoint = TailPoint;
  96. polygonTransfer.BorderStyle = BorderStyle;
  97. return true;
  98. }
  99. }
  100. }