/// <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); }
private static void Write(Stream stream, LayerState ls) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } if (ls == null) { throw new ArgumentNullException(nameof(ls)); } TextCodeValueWriter chunk = new TextCodeValueWriter(new StreamWriter(stream)); chunk.Write(0, LayerStateDictionary); chunk.Write(0, LayerStateName); chunk.Write(1, ls.Name); chunk.Write(91, 2047); // unknown code functionality <- 32-bit integer value chunk.Write(301, ls.Description); chunk.Write(290, ls.PaperSpace); chunk.Write(302, ls.CurrentLayer); foreach (LayerStateProperties lp in ls.Properties.Values) { chunk.Write(8, lp.Name); chunk.Write(90, (int)lp.Flags); chunk.Write(62, lp.Color.Index); chunk.Write(370, (short)lp.Lineweight); chunk.Write(6, lp.LinetypeName); //chunk.Write(2, properties.PlotStyleName); chunk.Write(440, lp.Transparency.Value == 0 ? 0 : Transparency.ToAlphaValue(lp.Transparency)); if (lp.Color.UseTrueColor) { // this code only appears if the layer color has been defined as true color chunk.Write(92, AciColor.ToTrueColor(lp.Color)); } } chunk.Flush(); }
private static LayerState ReadLayerState(TextCodeValueReader chunk) { string name = string.Empty; string description = string.Empty; string currentLayer = Layer.DefaultName; bool paperSpace = false; List <LayerStateProperties> layerProperties = new List <LayerStateProperties>(); if (chunk.Code == 0) { if (chunk.ReadString() != LayerStateName) { throw new Exception("File not valid."); } } else { throw new Exception("File not valid."); } chunk.Next(); while (chunk.Code != 0) { switch (chunk.Code) { case 1: name = chunk.ReadString(); chunk.Next(); break; case 91: // unknown code chunk.Next(); break; case 301: description = chunk.ReadString(); chunk.Next(); break; case 290: paperSpace = chunk.ReadBool(); chunk.Next(); break; case 302: // active layer currentLayer = chunk.ReadString(); chunk.Next(); break; case 8: // begin reading layer properties layerProperties.Add(ReadLayerProperties(chunk)); break; default: chunk.Next(); break; } } LayerState states = new LayerState(name) { Description = description, CurrentLayer = currentLayer, PaperSpace = paperSpace }; foreach (LayerStateProperties lp in layerProperties) { if (!states.Properties.ContainsKey(lp.Name)) { states.Properties.Add(lp.Name, lp); } } return(states); }