LwPolyline.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using FastReport.Export.Dxf.Utils;
  2. using System.Drawing;
  3. namespace FastReport.Export.Dxf.Sections.Entities
  4. {
  5. public class LwPolyLine : EntityBase
  6. {
  7. #region Private Fields
  8. private bool isClosedPolyline;
  9. private PointF[] points;
  10. private byte[] pointTypes;
  11. private Color polyLineColor;
  12. private LineStyle polyLineStyle;
  13. private float polyLineWidth;
  14. private float x;
  15. private float y;
  16. #endregion Private Fields
  17. #region Public Constructors
  18. public LwPolyLine(float x, float y, PointF[] points, byte[] pointTypes, Color polyLineColor, float polyLineWidth,
  19. LineStyle polyLineStyle, bool isClosedPolyline) : base()
  20. {
  21. this.points = points;
  22. this.pointTypes = pointTypes;
  23. this.polyLineColor = polyLineColor;
  24. this.polyLineWidth = polyLineWidth;
  25. this.polyLineStyle = polyLineStyle;
  26. this.x = x;
  27. this.y = y;
  28. this.isClosedPolyline = isClosedPolyline;
  29. InitGroups();
  30. }
  31. #endregion Public Constructors
  32. #region Private Methods
  33. private void AddVertex(PointF point)
  34. {
  35. AddPrimary2DPoint(x + point.X, y + point.Y);
  36. }
  37. private void InitGroups()
  38. {
  39. // 0
  40. // LWPOLYLINE
  41. // 8
  42. // Layer_1
  43. // 62
  44. // 7
  45. // 90
  46. // 4
  47. // 70
  48. // 1
  49. // 10
  50. // 42.763123
  51. // 20
  52. // 220.497360
  53. // 30
  54. // 0.0
  55. // 10
  56. // 117.598587
  57. // 20
  58. // 220.497360
  59. // 30
  60. // 0.0
  61. // 10
  62. // 117.598587
  63. // 20
  64. // 154.214515
  65. // 30
  66. // 0.0
  67. // 10
  68. // 42.763123
  69. // 20
  70. // 154.214515
  71. // 30
  72. // 0.0
  73. AddTypeName("LWPOLYLINE");
  74. AddGroup(8, "Layer_1");
  75. if (polyLineStyle != LineStyle.Solid)
  76. AddLineStyle(polyLineStyle);
  77. byte aciColor = ACIDictionary.GetAciColor(polyLineColor);
  78. AddColor(aciColor);
  79. AddEntityThickness(polyLineWidth);
  80. // Number of vertices
  81. AddGroup(90, points.Length);
  82. // Polyline flag (bit-coded); default is 0:
  83. // 1 = Closed; 128 = Plinegen
  84. if (isClosedPolyline)
  85. AddGroup(70, 1);
  86. else
  87. AddGroup(70, 0);
  88. //// Default start width (optional; default = 0)
  89. //AddGroup(40, 0);
  90. //// Default end width (optional; default = 0)
  91. //AddGroup(41, 0);
  92. // add VERTEX-es
  93. for (int i = 0; i < points.Length; i++)
  94. {
  95. PointF point = points[i];
  96. AddVertex(point);
  97. }
  98. }
  99. #endregion Private Methods
  100. }
  101. }