public EntityColor GetEntityColor(DrawContext context) { EntityColor entityColor; if (this.DxfColor == null) { if (this.entityColor_0 == EntityColor.ByBlock) { entityColor = context.ByBlockDxfColor == null ? context.ByBlockColor : EntityColor.CreateFrom(context.ByBlockDxfColor.Color); } else if (this.entityColor_0 == EntityColor.ByLayer) { DxfLayer layer = this.GetLayer(context); entityColor = layer == null?EntityColor.CreateFromColorIndex((short)7) : EntityColor.CreateFrom(layer.GetColor(context.Viewport)); } else { entityColor = this.Color; } } else { entityColor = EntityColor.CreateFrom(this.DxfColor.Color); } return(entityColor); }
protected DrawContext(DrawContext from) { this.image_0 = from.image_0; this.graphics_0 = from.graphics_0; this.dxfModel_0 = from.dxfModel_0; this.dxfLayout_0 = from.dxfLayout_0; this.graphicsConfig_0 = from.graphicsConfig_0; this.dxfLayer_0 = from.dxfLayer_0; this.dxfLayer_1 = from.dxfLayer_1; this.dxfEntity_0 = from.dxfEntity_0; this.dxfBlock_0 = from.dxfBlock_0; this.drawContext_0 = from.drawContext_0; this.dxfEntity_1 = from.dxfEntity_1; this.entityColor_0 = from.entityColor_0; this.transparency_0 = from.transparency_0; this.dxfColor_0 = from.dxfColor_0; this.dxfLineType_0 = from.dxfLineType_0; this.short_0 = from.short_0; this.int_0 = from.int_0; this.int_1 = from.int_1; this.dxfWipeoutVariables_0 = from.dxfWipeoutVariables_0; this.dictionary_0 = from.dictionary_0; this.double_0 = from.double_0; this.double_1 = from.double_1; }
internal static DxfScale smethod_4(DxfLayer layer, out DxfLayer oldLayer) { oldLayer = (DxfLayer)null; if (layer.ExtensionDictionary == null) { return((DxfScale)null); } IDictionaryEntry first = layer.ExtensionDictionary.Entries.GetFirst("ASDK_XREC_ANNO_SCALE_INFO"); if (first == null) { return((DxfScale)null); } DxfXRecord dxfXrecord = first.Value as DxfXRecord; if (dxfXrecord == null) { return((DxfScale)null); } if (dxfXrecord.Values.Count < 2) { return((DxfScale)null); } DxfScale dxfScale = dxfXrecord.Values[1].Value as DxfScale; if (dxfXrecord.Values.Count > 2) { oldLayer = dxfXrecord.Values[2].Value as DxfLayer; } return(dxfScale); }
public ArgbColor GetPlotColor(DxfEntity localBlockContext, WW.Cad.Model.Color color) { ArgbColor argbColor; if (this.graphicsConfig_0.PlotStyleManager != null) { argbColor = this.graphicsConfig_0.PlotStyleManager((IPlotPropertyOwner) new Class1065((IPlotPropertyOwner)localBlockContext, color), this).Color; } else if (color == WW.Cad.Model.Color.ByBlock) { if (localBlockContext.Color == EntityColor.ByLayer) { DxfLayer layer = localBlockContext.GetLayer(this); argbColor = layer == null ? DxfIndexedColor.DefaultColor : layer.Color.ToArgbColor(this.graphicsConfig_0.IndexedColors); } else { argbColor = localBlockContext.DxfColor != null?localBlockContext.DxfColor.Color.ToArgbColor(this.graphicsConfig_0.IndexedColors) : (!(localBlockContext.Color == EntityColor.ByBlock) ? localBlockContext.Color.ToArgbColor(this.graphicsConfig_0.IndexedColors) : (this.dxfColor_0 == null ? this.entityColor_0.ToArgbColor(this.graphicsConfig_0.IndexedColors) : this.dxfColor_0.Color.ToArgbColor(this.graphicsConfig_0.IndexedColors))); } } else if (color == WW.Cad.Model.Color.ByLayer) { DxfLayer layer = localBlockContext.GetLayer(this); argbColor = layer == null ? DxfIndexedColor.DefaultColor : layer.Color.ToArgbColor(this.graphicsConfig_0.IndexedColors); } else { argbColor = color.ToArgbColor(this.graphicsConfig_0.IndexedColors); } return(argbColor); }
public short GetLineWeight(DrawContext context) { if (!context.Model.Header.DisplayLineWeight && (!context.Layout.PaperSpace || (context.Layout.PlotLayoutFlags & PlotLayoutFlags.PrintLineweights) == PlotLayoutFlags.None)) { return(context.Config.DefaultLineWeight); } short effectiveLineWeight = this.EffectiveLineWeight; switch (effectiveLineWeight) { case -3: return(context.Config.DefaultLineWeight); case -2: short num = context.ByBlockLineWeight; if (num < (short)0) { num = context.Config.DefaultLineWeight; } return(num); case -1: DxfLayer layer = this.GetLayer(context); if (layer != null) { return(layer.GetLineWeight(context.Viewport, context.Config)); } return(context.Config.DefaultLineWeight); default: return(effectiveLineWeight); } }
public override void ResolveReferences(Class374 modelBuilder) { base.ResolveReferences(modelBuilder); DxfLayer handledObject = (DxfLayer)this.HandledObject; if (this.ulong_3 != 0UL) { DxfLineType dxfLineType = modelBuilder.method_4 <DxfLineType>(this.ulong_3); if (dxfLineType != null) { handledObject.LineType = dxfLineType; } } if (string.IsNullOrEmpty(this.string_0)) { return; } string[] strArray = this.string_0.Split('$'); if (strArray == null || strArray.Length != 2) { return; } string colorBookName = strArray[0]; string name = strArray[1]; handledObject.Color = Color.smethod_1(handledObject.Color.Data, colorBookName, name); }
public ArgbColor GetColor(DrawContext context) { ArgbColor baseColor; if (this.DxfColor == null) { if (this.entityColor_0 == EntityColor.ByBlock) { baseColor = context.ByBlockDxfColor == null?context.ByBlockColor.ToArgbColor(context.Config.IndexedColors) : context.ByBlockDxfColor.Color.ToArgbColor(context.Config.IndexedColors); } else if (this.entityColor_0 == EntityColor.ByLayer) { DxfLayer layer = this.GetLayer(context); baseColor = layer == null ? context.Config.IndexedColors[7] : layer.GetColor(context.Viewport).ToArgbColor(context.Config.IndexedColors); } else { baseColor = this.Color.ToArgbColor(context.Config.IndexedColors); } } else { baseColor = this.DxfColor.Color.ToArgbColor(context.Config.IndexedColors); } byte alpha = this.GetAlpha(context); if (alpha != byte.MaxValue) { return(ArgbColor.FromArgb((int)alpha, baseColor)); } return(baseColor); }
/// <summary> /// Visits the specified entity. /// See the <see cref="IEntityVisitor"/> for more details. /// </summary> public override void Visit(DxfInsert insert) { InsertInfo info = insertStack.Peek(); BlockData blockData = blockDataByName[insert.Block.Name]; DxfLayer effectiveLayer = info.GetEffectiveLayer(insert); DxfBlock block = blockData.GetBlock(effectiveLayer); if (block.Entities.Count == 0) { // no need to keep insert if block is empty info.currentCollection.RemoveAt(info.currentIndex); } else { // overwrite block with reduced one insert.Block = block; // take care of attributes for (int a = insert.Attributes.Count - 1; a >= 0; --a) { DxfAttribute attrib = insert.Attributes[a]; DxfLayer attribLayer = attrib.Layer.IsZeroLayer ? effectiveLayer : attrib.Layer; if (IsRemovedLayer(attribLayer)) { insert.Attributes.RemoveAt(a); } } } }
private ArgbColor method_13(DrawContext context, DxfLayer layer) { int index = this.list_0[0].Elements.Count - 1; DxfMLineStyle style = this.Style; return(index < 0 || index >= style.Elements.Count ? context.GetPlotColor((DxfEntity)this) : DxfEntity.GetColor(context.Config.IndexedColors, style.Elements[index].Color, context.ByBlockColor, context.ByBlockDxfColor, layer)); }
public static ArgbColor GetColor( WW.Cad.Model.Color color, EntityColor byBlockColor, DxfColor byBlockDxfColor, DxfLayer layer) { switch (color.ColorType) { case ColorType.ByLayer: if (layer != null) { return(layer.Color.ToArgbColor()); } return(ArgbColors.White); case ColorType.ByBlock: if (byBlockDxfColor != null) { return(byBlockDxfColor.Color.ToArgbColor()); } return(byBlockColor.ToArgbColor()); case ColorType.ByColor: case ColorType.ByColorIndex: case ColorType.ByPenIndex: case ColorType.Foreground: return(color.ToArgbColor()); default: return(DxfIndexedColor.Color[0]); } }
public void WriteLayersTableTest() { var layer = new DxfLayer("layer-name"); layer.ExtensionDataGroups.Add(new DxfCodePairGroup("APP_NAME", new IDxfCodePairOrGroup[] { new DxfCodePair(1, "foo"), new DxfCodePair(2, "bar"), })); var file = new DxfFile(); file.Layers.Add(layer); VerifyFileContains(file, @" 0 LAYER 5 # 102 {APP_NAME 1 foo 2 bar 102 } "); }
public bool Matches(DxfLayer layer, EntityColor byBlockColor, DxfLineType byBlockLineType) { if (this.graphicElementBlock2_0 == null) { return(false); } return(this.graphicElementBlock2_0.Matches(layer, byBlockColor, byBlockLineType)); }
public DxfLayer GetEffectiveLayer(DxfLayer insertLayer) { if (this.dxfEntity_0.Layer.IsZeroLayer) { return(this.dxfEntity_0.Layer.GetEffectiveLayer(this.renderedEntityInfo_0 != null ? this.renderedEntityInfo_0.GetEffectiveLayer(insertLayer) : insertLayer)); } return(this.dxfEntity_0.Layer); }
public bool Matches(DxfLayer layer, EntityColor byBlockColor, DxfLineType byBlockLineType) { if (layer.Enabled == this.bool_0 && layer.Frozen == this.bool_1 && (layer.Color.ToArgb() == this.color_0.ToArgb() && layer.LineType == this.ByLayerLineType && byBlockColor.ToArgb() == this.entityColor_0.ToArgb())) { return(byBlockLineType == this.ByBlockLineType); } return(false); }
protected bool IsEntityVisibleInContext(DrawContext context, bool useLayerEnabled) { if (!this.Visible) { return(false); } DxfLayer layer = this.GetLayer(context); return(this.IsVisibleOnLayer(context, layer, useLayerEnabled) && context.IsVisible(this)); }
private static IEnumerable <IPdfPathItem> ConvertLine(DxfLine line, DxfLayer layer, Matrix4 affine) { var p1 = affine.Transform(line.P1).ToPdfPoint(PdfMeasurementType.Point); var p2 = affine.Transform(line.P2).ToPdfPoint(PdfMeasurementType.Point); var pdfStreamState = new PdfStreamState( strokeColor: GetPdfColor(line, layer), strokeWidth: GetStrokeWidth(line, layer)); yield return(new PdfLine(p1, p2, pdfStreamState)); }
private static IEnumerable <IPdfPathItem> ConvertCircle(DxfCircle circle, DxfLayer layer, Matrix4 affine, Matrix4 scale) { var pdfStreamState = new PdfStreamState( strokeColor: GetPdfColor(circle, layer), strokeWidth: GetStrokeWidth(circle, layer)); // a circle becomes an ellipse, unless aspect ratio is kept. var center = affine.Transform(circle.Center).ToPdfPoint(PdfMeasurementType.Point); var radius = scale.Transform(new Vector(circle.Radius, circle.Radius, circle.Radius)) .ToPdfPoint(PdfMeasurementType.Point); yield return(new PdfEllipse(center, radius.X, radius.Y, state: pdfStreamState)); }
public static void DrawTopRFTLeftDims(DxfModel model, int nSpans, double[] comSpanVals) { //04.TopRFT Left Dims/*----------------*/ DxfLayer TopRFTDimLayerLt = new DxfLayer("DIMENSIONSTopRFTLt"); model.Layers.Add(TopRFTDimLayerLt); DxfBlock blockTopRFTDimLt = new DxfBlock("ALIGNED_DIMENSIONSTopRFTLt"); model.Blocks.Add(blockTopRFTDimLt); DxfInsert insertTopRFTDimLt = new DxfInsert(blockTopRFTDimLt, new Point3D(0, DXFPoints.startPointsTop[0].Y + 0.15, 0)); insertTopRFTDimLt.Layer = TopRFTDimLayerLt; model.Entities.Add(insertTopRFTDimLt); { DxfDimension.Aligned[] TopRFTDimArrLt = new DxfDimension.Aligned[nSpans + 1]; for (int i = 1; i < TopRFTDimArrLt.Length - 2; i++) { // Dimension with text aligned with dimension line. DxfDimension.Aligned dimension = new DxfDimension.Aligned(model.CurrentDimensionStyle); dimension.DimensionStyleOverrides.ArrowSize = 0.2d; dimension.DimensionStyleOverrides.TextInsideHorizontal = false; dimension.DimensionStyleOverrides.TextAboveDimensionLine = true; dimension.Layer = TopRFTDimLayerLt; dimension.DimensionLineLocation = new Point3D(0, 0, 0); dimension.ExtensionLine1StartPoint = new Point3D(DXFPoints.endPointsTop[i - 1].X - Math.Max(0.33 * DXFRebar.Ln[i - 1], 0.33 * DXFRebar.Ln[i]) - 0.25, 0, 0); dimension.ExtensionLine2StartPoint = new Point3D(DXFPoints.endPointsTop[i - 1].X, 0, 0); dimension.UseTextMiddlePoint = true; dimension.TextMiddlePoint = new Point3D(comSpanVals[0] + 0.50 * (DXFPoints.endPointsTop[i - 1].X - Math.Max(0.33 * DXFRebar.Ln[i - 1], 0.33 * DXFRebar.Ln[i]) - 0.25 + DXFPoints.endPointsTop[i - 1].X), 0.2d, 0d); blockTopRFTDimLt.Entities.Add(dimension); } //Case of Cantilever at end if (GeometryEditorVM.GeometryEditor.RestraintsCollection[RFTCanvas.SpanVals.Length].SelectedRestraint != Restraints.NoRestraints) { // Dimension with text aligned with dimension line. DxfDimension.Aligned dimension = new DxfDimension.Aligned(model.CurrentDimensionStyle); dimension.DimensionStyleOverrides.ArrowSize = 0.2d; dimension.DimensionStyleOverrides.TextInsideHorizontal = false; dimension.DimensionStyleOverrides.TextAboveDimensionLine = true; dimension.Layer = TopRFTDimLayerLt; dimension.DimensionLineLocation = new Point3D(0, 0, 0); dimension.ExtensionLine1StartPoint = new Point3D(DXFPoints.endPointsTop[TopRFTDimArrLt.Length - 1 - 1].X - Math.Max(0.33 * DXFRebar.Ln[TopRFTDimArrLt.Length - 1 - 1], 0.33 * DXFRebar.Ln[TopRFTDimArrLt.Length - 1]) - 0.25, 0, 0); dimension.ExtensionLine2StartPoint = new Point3D(DXFPoints.endPointsTop[TopRFTDimArrLt.Length - 1 - 1].X, 0, 0); dimension.UseTextMiddlePoint = true; dimension.TextMiddlePoint = new Point3D(comSpanVals[0] + 0.50 * (DXFPoints.endPointsTop[TopRFTDimArrLt.Length - 1 - 1].X - Math.Max(0.33 * DXFRebar.Ln[TopRFTDimArrLt.Length - 1 - 1], 0.33 * DXFRebar.Ln[TopRFTDimArrLt.Length - 1]) - 0.25 + DXFPoints.endPointsTop[TopRFTDimArrLt.Length - 1 - 1].X), 0.2d, 0d); blockTopRFTDimLt.Entities.Add(dimension); } } }
/// <summary> /// Add the entities associated with a given element to the appropriate /// layer, adding a new layer if necessary. /// </summary> public void AddElementToLayer(DxfFile document, Element e, IEnumerable <DxfEntity> entities, DxfRenderContext context) { try { var config = context.MappingConfiguration; if (config == null) { // TODO: add a default configuration return; } var layerConfigForElement = FindLayerForElement(config, e); if (layerConfigForElement == null) { return; } var matchingLayer = document.Layers.FirstOrDefault((l) => l.Name == layerConfigForElement.LayerName); if (matchingLayer == null) { var layer = new DxfLayer(layerConfigForElement.LayerName, layerConfigForElement.LayerColor.ToDxfColor()); if (layerConfigForElement.Lineweight != 0) { // lineweight value is in 1/100ths of a millimeter layer.LineWeight = new DxfLineWeight { Value = (short)layerConfigForElement.Lineweight }; } document.Layers.Add(layer); matchingLayer = layer; } foreach (var entity in entities) { entity.Layer = matchingLayer.Name; if (layerConfigForElement.ElementColorSetting == MappingConfiguration.ElementColorSetting.TryGetColorFromMaterial) { if (e is GeometricElement ge) { var materialColor = ge.Material.Color; var entityColor = materialColor.ToDxfColor(); entity.Color = entityColor; entity.Color24Bit = materialColor.To24BitColor(); } } } } catch (Exception ex) { // TODO: Implement exception logging Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } }
/// <summary> /// Handles a simple entity. /// </summary> /// <remarks> /// This just evaluates the effective layer and removes the entity if the layer is not the keep layer. /// </remarks> /// <param name="entity">The entity.</param> /// <returns><c>true</c> if the entity was removed.</returns> private bool HandleEntity(DxfEntity entity) { InsertInfo info = insertStack.Peek(); DxfLayer effectiveLayer = info.GetEffectiveLayer(entity); if (IsRemovedLayer(effectiveLayer)) { // remove entity on incorrect index info.currentCollection.RemoveAt(info.currentIndex); return(true); } return(false); }
protected internal bool IsVisibleOnLayer( DrawContext context, DxfLayer layer, bool useLayerEnabled) { bool flag = true; if (layer != null && (useLayerEnabled && (!layer.Enabled || context.Config.Plot && !layer.PlotEnabled) && !context.Config.ShowDisabledLayers || layer.Frozen && !context.Config.ShowFrozenLayers)) { flag = false; } return(flag); }
public DxfLayer GetEffectiveLayer(DxfLayer candidate) { DxfLayer dxfLayer = this.dxfLayer_0 == null || candidate != null && !candidate.IsZeroLayer ? candidate : this.dxfLayer_0; if (dxfLayer != null && this.dxfBlock_0 != null) { DxfLayer layerWithName = this.dxfBlock_0.Model.GetLayerWithName(this.dxfBlock_0.Name + "|" + dxfLayer.Name); if (layerWithName != null) { dxfLayer = layerWithName; } } return(dxfLayer); }
public GraphicElementBlock2 GetGraphicElementBlock( DxfLayer layer, EntityColor byBlockColor, DxfLineType byBlockLineType) { foreach (GraphicElementBlock2 graphicElementBlock2 in this.list_0) { if (graphicElementBlock2.Matches(layer, byBlockColor, byBlockLineType)) { return(graphicElementBlock2); } } return((GraphicElementBlock2)null); }
public override void ResolveReferences(Class374 modelBuilder) { base.ResolveReferences(modelBuilder); DxfEntity entity = this.Entity; if (this.ulong_2 != 0UL) { DxfLayer dxfLayer = modelBuilder.method_4 <DxfLayer>(this.ulong_2); if (dxfLayer != null) { entity.Layer = dxfLayer; } } if (this.nullable_0.HasValue) { byte? nullable0 = this.nullable_0; ref byte?local = ref nullable0; byte valueOrDefault = local.GetValueOrDefault(); if (local.HasValue) { switch (valueOrDefault) { case 0: entity.LineType = modelBuilder.Model.ByLayerLineType; break; case 1: entity.LineType = modelBuilder.Model.ByBlockLineType; break; case 2: entity.LineType = modelBuilder.Model.ContinuousLineType; break; case 3: if (this.ulong_3 != 0UL) { DxfLineType dxfLineType = modelBuilder.method_4 <DxfLineType>(this.ulong_3); if (dxfLineType != null) { entity.LineType = dxfLineType; break; } break; } break; } } }
private static IEnumerable <IPdfPathItem> ConvertArc(DxfArc arc, DxfLayer layer, Matrix4 affine, Matrix4 scale) { var pdfStreamState = new PdfStreamState( strokeColor: GetPdfColor(arc, layer), strokeWidth: GetStrokeWidth(arc, layer)); var center = affine.Transform(arc.Center).ToPdfPoint(PdfMeasurementType.Point); var radius = scale.Transform(new Vector(arc.Radius, arc.Radius, arc.Radius)) .ToPdfPoint(PdfMeasurementType.Point); const double rotation = 0; double startAngleRad = arc.StartAngle * Math.PI / 180; double endAngleRad = arc.EndAngle * Math.PI / 180; yield return(new PdfEllipse(center, radius.X, radius.Y, rotation, startAngleRad, endAngleRad, pdfStreamState)); }
protected DrawContext(DxfModel model, DxfLayout layout, GraphicsConfig config) { this.dxfModel_0 = model; this.dxfLayout_0 = layout; this.graphicsConfig_0 = config; this.dxfLineType_0 = model.ContinuousLineType; this.short_0 = (short)-3; this.dxfLayer_0 = model.ZeroLayer; this.dxfLayer_1 = model.method_14(); this.dxfWipeoutVariables_0 = model.DictionaryRoot.Entries.GetFirstValue("ACAD_WIPEOUT_VARS") as DxfWipeoutVariables ?? new DxfWipeoutVariables(); this.dictionary_0 = new Dictionary <DxfEntity, object>(); this.image_0 = (Image) new Bitmap(1, 1); this.graphics_0 = Class940.smethod_0(this.image_0); this.method_0(); }
private static PdfText ConvertText(DxfText text, DxfLayer layer, Matrix4 affine, Matrix4 scale) { // TODO horizontal and vertical justification (manual calculation for PDF, measure text?) // TODO Thickness, Rotation, TextStyleName, SecondAlignmentPoint // TODO IsTextUpsideDown, IsTextBackwards // TODO RelativeXScaleFactor // TODO TextHeight unit? Same as other scale? // TODO TextStyleName probably maps to something meaningfull (bold, italic, etc?) PdfMeasurement fontSize = scale.Transform(new Vector(0, text.TextHeight, 0)) .ToPdfPoint(PdfMeasurementType.Point).Y; PdfPoint location = affine.Transform(text.Location).ToPdfPoint(PdfMeasurementType.Point); var pdfStreamState = new PdfStreamState(GetPdfColor(text, layer)); return(new PdfText(text.Value, Font, fontSize, location, pdfStreamState)); }
public GraphicElementInsert GetGraphicElementInsert( DxfLayer layer, EntityColor byBlockColor, DxfLineType byBlockLineType) { foreach (IGraphicElement graphicElement in this.list_0) { GraphicElementInsert graphicElementInsert = graphicElement as GraphicElementInsert; if (graphicElementInsert != null && graphicElementInsert.Matches(layer, byBlockColor, byBlockLineType)) { return(graphicElementInsert); } } return((GraphicElementInsert)null); }
private static IEnumerable <IPdfPathItem> ConvertPoint(DxfModelPoint point, DxfLayer layer, Matrix4 affine, Matrix4 scale) { var p = affine.Transform(point.Location).ToPdfPoint(PdfMeasurementType.Point); var thickness = scale.Transform(new Vector(point.Thickness, 0, 0)).ToPdfPoint(PdfMeasurementType.Point).X; if (thickness.RawValue < 1) { thickness = PdfMeasurement.Points(1); } // TODO fill circle? For now fake it via stroke thickness. var pdfStreamState = new PdfStreamState( strokeColor: GetPdfColor(point, layer), strokeWidth: thickness); yield return(new PdfCircle(p, thickness / 2, pdfStreamState)); }
private static DxfColor GetFinalDxfColor(DxfEntity entity, DxfLayer layer) { DxfColor c = entity.Color; if (c == null || c.IsByLayer) { return(layer.Color); } if (c.IsIndex) { return(c); } // we could build a Dictionary<DxfBlock, DxfColor> for the c.IsByBlock case // not sure how to retrieve color for the remaining cases return(null); }
public void WriteLayersTableTest() { var layer = new DxfLayer("layer-name"); layer.ExtensionDataGroups.Add(new DxfCodePairGroup("APP_NAME", new DxfCodePairOrGroup[] { new DxfCodePair(1, "foo"), new DxfCodePair(2, "bar"), })); var file = new DxfFile(); file.Layers.Add(layer); VerifyFileContains(file, @" 0 LAYER 5 A 102 {APP_NAME 1 foo 2 bar 102 } "); }
internal static DxfLayer FromBuffer(DxfCodePairBufferReader buffer) { var item = new DxfLayer(); while (buffer.ItemsRemain) { var pair = buffer.Peek(); if (pair.Code == 0) { break; } buffer.Advance(); switch (pair.Code) { case 70: item.StandardFlags = (int)pair.ShortValue; break; case DxfCodePairGroup.GroupCodeNumber: var groupName = DxfCodePairGroup.GetGroupName(pair.StringValue); item.ExtensionDataGroups.Add(DxfCodePairGroup.FromBuffer(buffer, groupName)); break; case 62: item.Color = DxfColor.FromRawValue(pair.ShortValue); break; case 6: item.LinetypeName = (pair.StringValue); break; case 290: item.IsLayerPlotted = (pair.BoolValue); break; case 370: item.LineWeight = DxfLineWeight.FromRawValue(pair.ShortValue); break; case 390: item.PlotStylePointer = UIntHandle(pair.StringValue); break; case 347: item.MaterialHandle = UIntHandle(pair.StringValue); break; case (int)DxfXDataType.ApplicationName: item.XData = DxfXData.FromBuffer(buffer, pair.StringValue); break; default: item.TrySetPair(pair); break; } } return item; }