Beispiel #1
0
        internal static DxfSectionTypeSettings FromBuffer(DxfCodePairBufferReader buffer)
        {
            if (buffer.Peek()?.Code == 0)
            {
                return(null);
            }

            var settings = new DxfSectionTypeSettings();

            while (buffer.ItemsRemain)
            {
                var pair = buffer.Peek();
                if (pair.Code == 0)
                {
                    break;
                }

                switch (pair.Code)
                {
                case 1:
                    settings.DestinationFileName = pair.StringValue;
                    buffer.Advance();
                    break;

                case 2:
                    Debug.Assert(pair.StringValue == "SectionGeometrySettings");
                    buffer.Advance();
                    for (var geometry = DxfSectionGeometrySettings.FromBuffer(buffer); geometry != null; geometry = DxfSectionGeometrySettings.FromBuffer(buffer))
                    {
                        settings.GeometrySettings.Add(geometry);
                    }
                    break;

                case 3:
                    Debug.Assert(pair.StringValue == "SectionTypeSettingsEnd");
                    buffer.Advance();
                    break;

                case 90:
                    settings.SectionType = pair.IntegerValue;
                    buffer.Advance();
                    break;

                case 91:
                    settings.IsGenerationOption = pair.IntegerValue != 0;
                    buffer.Advance();
                    break;

                case 92:
                    var sourceObjectsCount = pair.IntegerValue;
                    buffer.Advance();
                    break;

                case 93:
                    var generationSettingsCount = pair.IntegerValue;
                    buffer.Advance();
                    break;

                case 330:
                    settings.SourceObjectHandles.Add(DxfCommonConverters.UIntHandle(pair.StringValue));
                    buffer.Advance();
                    break;

                case 331:
                    settings.DestinationObjectHandle = DxfCommonConverters.UIntHandle(pair.StringValue);
                    buffer.Advance();
                    break;

                default:
                    return(settings);
                }
            }

            return(settings);
        }
Beispiel #2
0
        internal static DxfSectionGeometrySettings FromBuffer(DxfCodePairBufferReader buffer)
        {
            var stillReading = true;
            var settings     = new DxfSectionGeometrySettings();

            if (buffer.Peek()?.Code != 90)
            {
                // only code 90 can start one of these
                return(null);
            }

            while (buffer.ItemsRemain && stillReading)
            {
                var pair = buffer.Peek();
                switch (pair.Code)
                {
                case 1:
                    settings.PlotstyleName = pair.StringValue;
                    break;

                case 2:
                    settings.HatchPatternName = pair.StringValue;
                    break;

                case 3:
                    Debug.Assert(pair.StringValue == "SectionGeometrySettingsEnd");
                    stillReading = false;
                    break;

                case 6:
                    settings.LinetypeName = pair.StringValue;
                    break;

                case 8:
                    settings.LayerName = pair.StringValue;
                    break;

                case 40:
                    settings.LinetypeScale = pair.DoubleValue;
                    break;

                case 41:
                    settings.HatchAngle = pair.DoubleValue;
                    break;

                case 42:
                    settings.HatchScale = pair.DoubleValue;
                    break;

                case 43:
                    settings.HatchSpacing = pair.DoubleValue;
                    break;

                case 63:
                    settings.Color = DxfColor.FromRawValue(pair.ShortValue);
                    break;

                case 70:
                    settings.FaceTransparency = pair.ShortValue;
                    break;

                case 71:
                    settings.EdgeTransparency = pair.ShortValue;
                    break;

                case 72:
                    settings.HatchPatternType = pair.ShortValue;
                    break;

                case 90:
                    settings.SectionType = pair.IntegerValue;
                    break;

                case 91:
                    settings.GeometryCount = pair.IntegerValue;
                    break;

                case 92:
                    settings.BitFlags = pair.IntegerValue;
                    break;

                case 370:
                    settings.LineWeight = pair.ShortValue;
                    break;

                default:
                    // unexpected end, return immediately without consuming the code pair
                    return(settings);
                }

                buffer.Advance();
            }

            return(settings);
        }