Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new LayerState that is a copy of the current instance.
        /// </summary>
        /// <param name="newName">LayerState name of the copy.</param>
        /// <returns>A new LayerState that is a copy of this instance.</returns>
        public override TableObject Clone(string newName)
        {
            LayerState ls = new LayerState(newName)
            {
                Description  = this.description,
                CurrentLayer = this.currentLayer
            };

            foreach (LayerStateProperties item in this.properties.Values)
            {
                LayerStateProperties lp = (LayerStateProperties)item.Clone();
                ls.Properties.Add(lp.Name, lp);
            }

            return(ls);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <c>LayerState</c> class from a specified list of layers.
        /// </summary>
        /// <param name="name">Layer state name.</param>
        /// <param name="layers">List of layers.</param>
        public LayerState(string name, IEnumerable <Layer> layers)
            : base(name, DxfObjectCode.LayerStates, true)
        {
            this.description  = string.Empty;
            this.currentLayer = Layer.DefaultName;
            this.paperSpace   = false;

            this.properties = new ObservableDictionary <string, LayerStateProperties>();
            this.properties.BeforeAddItem += this.Properties_BeforeAddItem;

            if (layers == null)
            {
                throw new ArgumentNullException(nameof(layers));
            }

            foreach (Layer layer in layers)
            {
                LayerStateProperties prop = new LayerStateProperties(layer);
                this.properties.Add(prop.Name, prop);
            }
        }
Ejemplo n.º 3
0
        private static LayerStateProperties ReadLayerProperties(TextCodeValueReader chunk)
        {
            LayerPropertiesFlags flags = LayerPropertiesFlags.Plot;
            string lineType            = String.Empty;
            //string plotStyle = string.Empty;
            AciColor     color        = AciColor.Default;
            Lineweight   lineweight   = Lineweight.Default;
            Transparency transparency = new Transparency(0);

            string name = chunk.ReadString();

            chunk.Next();

            while (chunk.Code != 8 && chunk.Code != 0)
            {
                switch (chunk.Code)
                {
                case 90:
                    flags = (LayerPropertiesFlags)chunk.ReadInt();
                    chunk.Next();
                    break;

                case 62:
                    color = AciColor.FromCadIndex(chunk.ReadShort());
                    chunk.Next();
                    break;

                case 370:
                    lineweight = (Lineweight)chunk.ReadShort();
                    chunk.Next();
                    break;

                case 6:
                    lineType = chunk.ReadString();
                    chunk.Next();
                    break;

                case 2:
                    //plotStyle = chunk.ReadString();
                    chunk.Next();
                    break;

                case 440:
                    int alpha = chunk.ReadInt();
                    transparency = alpha == 0 ? new Transparency(0) : Transparency.FromAlphaValue(alpha);
                    chunk.Next();
                    break;

                case 92:
                    color = AciColor.FromTrueColor(chunk.ReadInt());
                    chunk.Next();
                    break;

                default:
                    chunk.Next();
                    break;
                }
            }

            if (string.IsNullOrEmpty(name))
            {
                return(null);
            }

            LayerStateProperties properties = new LayerStateProperties(name)
            {
                Flags        = flags,
                Color        = color,
                Lineweight   = lineweight,
                LinetypeName = lineType,
                //PlotStyleName = plotStyle,
                Transparency = transparency
            };

            return(properties);
        }