/// <summary> /// Initializes a new instance of the <c>LayerStateProperties</c> class. /// </summary> /// <param name="layer">Layer from which copy the properties.</param> public LayerStateProperties(Layer layer) { this.name = layer.Name; if (!layer.IsVisible) { this.flags |= LayerPropertiesFlags.Hidden; } if (layer.IsFrozen) { this.flags |= LayerPropertiesFlags.Frozen; } if (layer.IsLocked) { this.flags |= LayerPropertiesFlags.Locked; } if (layer.Plot) { this.flags |= LayerPropertiesFlags.Plot; } this.linetype = layer.Linetype.Name; this.color = (AciColor)layer.Color.Clone(); this.lineweight = layer.Lineweight; this.transparency = (Transparency)layer.Transparency.Clone(); //this.plotStyle = "Color_" + layer.Color.Index; }
///// <summary> ///// Layer properties plot style name. ///// </summary> //public string PlotStyleName //{ // get { return this.plotStyle; } // set { this.plotStyle = value; } //} #endregion #region public methods /// <summary> /// Copy the layer to the current layer state properties. /// </summary> /// <param name="layer">Layer from which copy the properties.</param> /// <param name="options">Layer properties to copy.</param> public void CopyFrom(Layer layer, LayerPropertiesRestoreFlags options) { if (!string.Equals(this.name, layer.Name, StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException("Only a layer with the same name can be copied.", nameof(layer)); } this.flags = LayerPropertiesFlags.None; if (options.HasFlag(LayerPropertiesRestoreFlags.Hidden)) { if (!layer.IsVisible) { this.flags |= LayerPropertiesFlags.Hidden; } } if (options.HasFlag(LayerPropertiesRestoreFlags.Frozen)) { if (layer.IsFrozen) { this.flags |= LayerPropertiesFlags.Frozen; } } if (options.HasFlag(LayerPropertiesRestoreFlags.Locked)) { if (layer.IsLocked) { this.flags |= LayerPropertiesFlags.Locked; } } if (options.HasFlag(LayerPropertiesRestoreFlags.Plot)) { if (layer.Plot) { this.flags |= LayerPropertiesFlags.Plot; } } if (options.HasFlag(LayerPropertiesRestoreFlags.Linetype)) { this.linetype = layer.Linetype.Name; } if (options.HasFlag(LayerPropertiesRestoreFlags.Color)) { this.color = (AciColor)layer.Color.Clone(); } if (options.HasFlag(LayerPropertiesRestoreFlags.Lineweight)) { this.lineweight = layer.Lineweight; } if (options.HasFlag(LayerPropertiesRestoreFlags.Transparency)) { this.transparency = (Transparency)layer.Transparency.Clone(); } }
//private string plotStyle; #endregion #region constructor /// <summary> /// Initializes a new instance of the <c>LayerStateProperties</c> class. /// </summary> /// <param name="name">Name of the layer state properties.</param> public LayerStateProperties(string name) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name)); } this.name = name; this.flags = LayerPropertiesFlags.Plot; this.linetype = Linetype.DefaultName; this.color = AciColor.Default; this.lineweight = Lineweight.Default; this.transparency = new Transparency(0); //this.plotStyle = "Color_7"; }
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); }