Ellipse.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using FastReport.Export.Dxf.Utils;
  2. using System.Drawing;
  3. namespace FastReport.Export.Dxf.Sections.Entities
  4. {
  5. internal class Ellipse : EntityBase
  6. {
  7. #region Private Fields
  8. private Color borderColor;
  9. private LineStyle borderStyle;
  10. private float borderWidth;
  11. private float height;
  12. private float width;
  13. private float x;
  14. private float y;
  15. #endregion Private Fields
  16. #region Public Constructors
  17. public Ellipse(float x, float y, float width, float height, Color borderColor, float borderWidth,
  18. LineStyle borderStyle) : base()
  19. {
  20. this.x = x;
  21. this.y = y;
  22. this.borderColor = borderColor;
  23. this.borderWidth = borderWidth;
  24. this.borderStyle = borderStyle;
  25. this.width = width;
  26. this.height = height;
  27. InitGroups();
  28. }
  29. #endregion Public Constructors
  30. #region Private Methods
  31. private void InitGroups()
  32. {
  33. // 0
  34. // ELLIPSE
  35. // 6
  36. // BYLAYER
  37. // 10
  38. // - 13.720
  39. // 20
  40. // 5.42
  41. // 30
  42. // 0
  43. // 11
  44. // 0
  45. // 21
  46. // 3.45
  47. // 31
  48. // 0
  49. // 40
  50. // 0.98
  51. // 41
  52. // 0
  53. // 42
  54. // 6.28
  55. AddTypeName("ELLIPSE");
  56. AddGroup(8, "Layer_1");
  57. byte aciColor = ACIDictionary.GetAciColor(borderColor);
  58. AddColor(aciColor);
  59. AddEntityThickness(borderWidth);
  60. if (borderStyle != LineStyle.Solid)
  61. AddLineStyle(borderStyle);
  62. float Ax = x;
  63. float Ay = y;
  64. // center
  65. float Cx = Ax + width / 2;
  66. float Cy = Ay - height / 2;
  67. // major axis
  68. float MjX = 0;
  69. float MjY = height / 2;
  70. // Ratio of minor axis to major axis
  71. float minToMajRatio = (Cx - Ax) / (Ay - Cy);
  72. // Center point (in WCS)
  73. AddPrimary2DPoint(Cx, Cy);
  74. // Endpoint of major axis, relative to the center (in WCS)
  75. AddSecondPoint(MjX, MjY);
  76. // Ratio of minor axis to major axis
  77. AddGroup(40, minToMajRatio);
  78. // Start parameter (this value is 0.0 for a full ellipse)
  79. AddGroup(41, 0);
  80. // End parameter (this value is 2pi for a full ellipse)
  81. AddGroup(42, 6.28);
  82. }
  83. #endregion Private Methods
  84. }
  85. }