/// <summary> /// Initializes a new instance of the <c>Leader</c> class. /// </summary> public Leader(Block block, IEnumerable <Vector2> vertexes, DimensionStyle style) : base(EntityType.Leader, DxfObjectCode.Leader) { if (vertexes == null) { throw new ArgumentNullException(nameof(vertexes)); } this.vertexes = new List <Vector2>(vertexes); if (this.vertexes.Count < 2) { throw new ArgumentOutOfRangeException(nameof(vertexes), this.vertexes.Count, "The leader vertexes list requires at least two points."); } if (style == null) { throw new ArgumentNullException(nameof(style)); } this.style = style; hasHookline = false; showArrowhead = true; pathType = LeaderPathType.StraightLineSegements; lineColor = AciColor.ByLayer; elevation = 0.0; offset = Vector2.Zero; styleOverrides = new DimensionStyleOverrideDictionary(); styleOverrides.BeforeAddItem += StyleOverrides_BeforeAddItem; styleOverrides.AddItem += StyleOverrides_AddItem; styleOverrides.BeforeRemoveItem += StyleOverrides_BeforeRemoveItem; styleOverrides.RemoveItem += StyleOverrides_RemoveItem; annotation = BuildAnnotation(block); annotation.AddReactor(this); }
/// <summary> /// Creates a list of entities that represents the boundary of the hatch and optionally associates to it. /// </summary> /// <param name="linkBoundary">Indicates if the new boundary will be associated with the hatch, turning the associative property to true.</param> /// <returns>A list of entities that makes the boundary of the hatch.</returns> /// <remarks> /// If the actual hatch is already associative, the old boundary entities will be unlinked, but not deleted from the hatch document. /// The new boundary entities will be added to the same layout and document as the hatch, in case it belongs to one.<br/> /// All entities are in world coordinates except the LwPolyline boundary path since by definition its vertexes are expressed in object coordinates. /// </remarks> public List <EntityObject> CreateBoundary(bool linkBoundary) { if (this.associative) { this.UnLinkBoundary(); } this.associative = linkBoundary; List <EntityObject> boundary = new List <EntityObject>(); Matrix3 trans = MathHelper.ArbitraryAxis(this.normal); Vector3 pos = trans * new Vector3(0.0, 0.0, this.elevation); foreach (HatchBoundaryPath path in this.boundaryPaths) { foreach (HatchBoundaryPath.Edge edge in path.Edges) { EntityObject entity = edge.ConvertTo(); switch (entity.Type) { case EntityType.Arc: boundary.Add(ProcessArc((Arc)entity, trans, pos)); break; case EntityType.Circle: boundary.Add(ProcessCircle((Circle)entity, trans, pos)); break; case EntityType.Ellipse: boundary.Add(ProcessEllipse((Ellipse)entity, trans, pos)); break; case EntityType.Line: boundary.Add(ProcessLine((Line)entity, trans, pos)); break; case EntityType.LightWeightPolyline: // LwPolylines need an special treatment since their vertexes are expressed in object coordinates. boundary.Add(ProcessLwPolyline((LwPolyline)entity, this.normal, this.elevation)); break; case EntityType.Spline: boundary.Add(ProcessSpline((Spline)entity, trans, pos)); break; } if (this.associative) { path.AddContour(entity); entity.AddReactor(this); this.OnHatchBoundaryPathAddedEvent(path); } } } return(boundary); }