LineMeasureParam.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 double LeadLength { get; set; }
  44. public double LeadExtension { get; set; }
  45. public double LeadOffset { get; set; }
  46. public override bool CopyTo(AnnotParam transfer)
  47. {
  48. LineMeasureParam lineTransfer = transfer as LineMeasureParam;
  49. if (lineTransfer == null)
  50. {
  51. return false;
  52. }
  53. if (!base.CopyTo(lineTransfer))
  54. {
  55. return false;
  56. }
  57. if (LineColor != null)
  58. {
  59. lineTransfer.LineColor = (byte[])LineColor.Clone();
  60. }
  61. if (LineDash != null)
  62. {
  63. lineTransfer.LineDash = (float[])LineDash.Clone();
  64. }
  65. if (FontColor != null)
  66. {
  67. lineTransfer.FontColor = (byte[])FontColor.Clone();
  68. }
  69. if (measureInfo != null)
  70. {
  71. CPDFMeasureInfo cPDFMeasureInfo = new CPDFMeasureInfo()
  72. {
  73. Factor = measureInfo.Factor,
  74. Unit = measureInfo.Unit,
  75. DecimalSymbol = measureInfo.DecimalSymbol,
  76. ThousandSymbol = measureInfo.ThousandSymbol,
  77. Display = measureInfo.Display,
  78. Precision = measureInfo.Precision,
  79. UnitPrefix = measureInfo.UnitPrefix,
  80. UnitSuffix = measureInfo.UnitSuffix,
  81. UnitPosition = measureInfo.UnitPosition,
  82. RulerBase = measureInfo.RulerBase,
  83. RulerBaseUnit = measureInfo.RulerBaseUnit,
  84. RulerTranslateUnit = measureInfo.RulerTranslateUnit,
  85. RulerTranslate = measureInfo.RulerTranslate,
  86. CaptionType = measureInfo.CaptionType,
  87. };
  88. lineTransfer.measureInfo = cPDFMeasureInfo;
  89. }
  90. lineTransfer.LineWidth = LineWidth;
  91. lineTransfer.HeadLineType = HeadLineType;
  92. lineTransfer.TailLineType = TailLineType;
  93. lineTransfer.FontName = FontName;
  94. lineTransfer.FontSize = FontSize;
  95. lineTransfer.IsBold = IsBold;
  96. lineTransfer.IsItalic = IsItalic;
  97. lineTransfer.HeadPoint = HeadPoint;
  98. lineTransfer.TailPoint = TailPoint;
  99. lineTransfer.BorderStyle = BorderStyle;
  100. lineTransfer.LeadExtension=LeadExtension;
  101. lineTransfer.LeadLength = LeadLength;
  102. lineTransfer.LeadOffset = LeadOffset;
  103. return true;
  104. }
  105. }
  106. }