Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <c>MLine</c> class.
        /// </summary>
        /// <param name="vertexes">MLine <see cref="Vector2">vertex</see> location list in object coordinates.</param>
        /// <param name="style">MLine <see cref="MLineStyle">style.</see></param>
        /// <param name="scale">MLine scale.</param>
        /// <param name="isClosed">Sets if the multiline is closed</param>
        public MLine(IEnumerable <Vector2> vertexes, MLineStyle style, double scale, bool isClosed = false)
            : base(EntityType.MLine, DxfObjectCode.MLine)
        {
            this.scale = scale;
            if (style == null)
            {
                throw new ArgumentNullException("style", "The MLine style cannot be null.");
            }
            if (isClosed)
            {
                this.flags = MLineFlags.Has | MLineFlags.Closed;
            }
            else
            {
                this.flags = MLineFlags.Has;
            }

            this.style         = style;
            this.justification = MLineJustification.Zero;
            this.isClosed      = isClosed;
            this.noStartCaps   = false;
            this.noEndCaps     = false;
            this.elevation     = 0.0;
            if (vertexes == null)
            {
                throw new ArgumentNullException("vertexes");
            }
            this.SetVertexes(vertexes);
        }
        /// <summary>
        /// Initializes a new instance of the <c>MLine</c> class.
        /// </summary>
        /// <param name="vertexes">MLine <see cref="Vector2">vertex</see> location list in object coordinates.</param>
        /// <param name="style">MLine <see cref="MLineStyle">style.</see></param>
        /// <param name="scale">MLine scale.</param>
        /// <param name="isClosed">Sets if the multiline is closed  (default: false).</param>
        public MLine(IEnumerable <Vector2> vertexes, MLineStyle style, double scale, bool isClosed)
            : base(EntityType.MLine, DxfObjectCode.MLine)
        {
            this.scale = scale;
            if (style == null)
            {
                throw new ArgumentNullException(nameof(style));
            }
            if (isClosed)
            {
                this.flags = MLineFlags.Has | MLineFlags.Closed;
            }
            else
            {
                this.flags = MLineFlags.Has;
            }

            this.style         = style;
            this.justification = MLineJustification.Zero;
            this.elevation     = 0.0;
            if (vertexes == null)
            {
                throw new ArgumentNullException(nameof(vertexes));
            }
            this.vertexes = new List <MLineVertex>();
            foreach (Vector2 point in vertexes)
            {
                this.vertexes.Add(new MLineVertex(point, Vector2.Zero, Vector2.Zero, null));
            }
            this.Update();
        }
Esempio n. 3
0
        public override void CopyFrom(DxfHandledObject from, CloneContext cloneContext)
        {
            base.CopyFrom(from, cloneContext);
            DxfMLine dxfMline = (DxfMLine)from;

            if (dxfMline.Style != null)
            {
                if (cloneContext.SourceModel == cloneContext.TargetModel)
                {
                    this.Style = dxfMline.Style;
                }
                else if ((this.Style = cloneContext.TargetModel.MLineStyles.Find(dxfMline.Style.Name)) == null)
                {
                    switch (cloneContext.ReferenceResolutionType)
                    {
                    case ReferenceResolutionType.IgnoreMissing:
                        this.Style = cloneContext.TargetModel.DefaultMLineStyle;
                        break;

                    case ReferenceResolutionType.CloneMissing:
                        DxfMLineStyle dxfMlineStyle = (DxfMLineStyle)dxfMline.Style.Clone(cloneContext);
                        if (!cloneContext.CloneExact)
                        {
                            cloneContext.TargetModel.MLineStyles.Add(dxfMlineStyle);
                        }
                        this.Style = dxfMlineStyle;
                        break;

                    case ReferenceResolutionType.FailOnMissing:
                        throw new DxfException(string.Format("Could not resolve reference to mline style with name {0}.", (object)dxfMline.Style.Name));
                    }
                }
            }
            this.double_1         = dxfMline.double_1;
            this.mlineAlignment_0 = dxfMline.mlineAlignment_0;
            this.mlineFlags_0     = dxfMline.mlineFlags_0;
            this.point3D_0        = dxfMline.point3D_0;
            this.vector3D_0       = dxfMline.vector3D_0;
            foreach (DxfMLine.Segment segment in dxfMline.list_0)
            {
                this.list_0.Add(segment.Clone(cloneContext));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <c>MLine</c> class.
        /// </summary>
        /// <param name="vertexes">MLine <see cref="Vector2">vertex</see> location list in object coordinates.</param>
        /// <param name="style">MLine <see cref="MLineStyle">style.</see></param>
        /// <param name="scale">MLine scale.</param>
        /// <param name="isClosed">Sets if the multiline is closed</param>
        public MLine(ICollection<Vector2> vertexes, MLineStyle style, double scale, bool isClosed = false)
            : base(EntityType.MLine, DxfObjectCode.MLine)
        {
            this.scale = scale;
            if (style == null)
                throw new ArgumentNullException("style", "The MLine style cannot be null.");
            if (isClosed)
                this.flags = MLineFlags.Has | MLineFlags.Closed;
            else
                this.flags = MLineFlags.Has;

            this.style = style;
            this.justification = MLineJustification.Zero;
            this.elevation = 0.0;
            if (vertexes == null)
                throw new ArgumentNullException("vertexes");
            this.SetVertexes(vertexes);
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <c>MLine</c> class.
        /// </summary>
        /// <param name="vertexes">MLine <see cref="Vector2">vertex</see> location list in object coordinates.</param>
        /// <param name="style">MLine <see cref="MLineStyle">style.</see></param>
        /// <param name="scale">MLine scale.</param>
        /// <param name="isClosed">Sets if the multiline is closed  (default: false).</param>
        public MLine(IEnumerable<Vector2> vertexes, MLineStyle style, double scale, bool isClosed)
            : base(EntityType.MLine, DxfObjectCode.MLine)
        {
            this.scale = scale;
            if (style == null)
                throw new ArgumentNullException(nameof(style));
            if (isClosed)
                this.flags = MLineFlags.Has | MLineFlags.Closed;
            else
                this.flags = MLineFlags.Has;

            this.style = style;
            this.justification = MLineJustification.Zero;
            this.elevation = 0.0;
            if (vertexes == null)
                throw new ArgumentNullException(nameof(vertexes));
            this.vertexes = new List<MLineVertex>();
            foreach (Vector2 point in vertexes)
                this.vertexes.Add(new MLineVertex(point, Vector2.Zero, Vector2.Zero, null));
            this.Update();
        }
Esempio n. 6
0
 public static bool HasFlag(this MLineFlags flags, MLineFlags flag)
 {
     return((flags & flag) != 0);
 }