예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <c>DxfObject</c> class.
 /// </summary>
 /// <param name="codename"><see cref="DxfObjectCode">DXF object name</see>.</param>
 protected DxfObject(string codename)
 {
     this.codename            = codename;
     this.handle              = null;
     this.owner               = null;
     this.xData               = new XDataDictionary();
     this.xData.AddAppReg    += this.XData_AddAppReg;
     this.xData.RemoveAppReg += this.XData_RemoveAppReg;
 }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <c>BlockRecord</c> class.
 /// </summary>
 /// <param name="name">Block definition name.</param>
 public BlockRecord(string name)
     : base(DxfObjectCode.BlockRecord)
 {
     if (string.IsNullOrEmpty(name))
         throw new ArgumentNullException(nameof(name));
     this.name = name;
     this.layout = null;
     this.units = DefaultUnits;
     this.allowExploding = true;
     this.scaleUniformly = false;
     this.xData = new XDataDictionary();
 }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <c>BlockRecord</c> class.
 /// </summary>
 /// <param name="name">Block definition name.</param>
 internal BlockRecord(string name)
     : base(DxfObjectCode.BlockRecord)
 {
     if (string.IsNullOrEmpty(name))
     {
         throw new ArgumentNullException(nameof(name));
     }
     this.name           = name;
     this.layout         = null;
     this.units          = DefaultUnits;
     this.allowExploding = true;
     this.scaleUniformly = false;
     this.xData          = new XDataDictionary();
 }
예제 #4
0
 protected EntityObject(EntityType type, string dxfCode)
     : base(dxfCode)
 {
     this.type          = type;
     this.color         = AciColor.ByLayer;
     this.layer         = Layer.Default;
     this.lineType      = LineType.ByLayer;
     this.lineweight    = Lineweight.ByLayer;
     this.transparency  = Transparency.ByLayer;
     this.lineTypeScale = 1.0;
     this.isVisible     = true;
     this.normal        = Vector3.UnitZ;
     this.xData         = new XDataDictionary();
 }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the <c>AttributeDefiniton</c> class.
        /// </summary>
        /// <param name="tag">Attribute identifier, the parameter <c>id</c> string cannot contain spaces.</param>
        /// <param name="textHeight">Height of the attribute definition text.</param>
        /// <param name="style">Attribute <see cref="TextStyle">text style</see>.</param>
        public AttributeDefinition(string tag, double textHeight, TextStyle style)
            : base(DxfObjectCode.AttributeDefinition)
        {
            if (string.IsNullOrEmpty(tag))
            {
                throw new ArgumentNullException(nameof(tag));
            }

            if (tag.Contains(" "))
            {
                throw new ArgumentException("The tag string cannot contain spaces.", nameof(tag));
            }
            this.tag      = tag;
            this.flags    = AttributeFlags.Visible;
            this.prompt   = string.Empty;
            this.attValue = null;
            this.position = Vector3.Zero;
            if (style == null)
            {
                throw new ArgumentNullException(nameof(style));
            }
            this.style = style;
            if (textHeight <= 0.0)
            {
                throw new ArgumentOutOfRangeException(nameof(textHeight), this.attValue, "The attribute definition text height must be greater than zero.");
            }
            this.height        = textHeight;
            this.width         = 1.0;
            this.widthFactor   = style.WidthFactor;
            this.obliqueAngle  = style.ObliqueAngle;
            this.rotation      = 0.0;
            this.alignment     = TextAlignment.BaselineLeft;
            this.isBackward    = false;
            this.isUpsideDown  = false;
            this.color         = AciColor.ByLayer;
            this.layer         = Layer.Default;
            this.linetype      = Linetype.ByLayer;
            this.lineweight    = Lineweight.ByLayer;
            this.transparency  = Transparency.ByLayer;
            this.linetypeScale = 1.0;
            this.isVisible     = true;
            this.normal        = Vector3.UnitZ;

            this.xData               = new XDataDictionary();
            this.xData.AddAppReg    += this.XData_AddAppReg;
            this.xData.RemoveAppReg += this.XData_RemoveAppReg;
        }
예제 #6
0
 protected EntityObject(EntityType type, string dxfCode)
     : base(dxfCode)
 {
     this.type                = type;
     this.color               = AciColor.ByLayer;
     this.layer               = Layer.Default;
     this.linetype            = Linetype.ByLayer;
     this.lineweight          = Lineweight.ByLayer;
     this.transparency        = Transparency.ByLayer;
     this.linetypeScale       = 1.0;
     this.isVisible           = true;
     this.normal              = Vector3.UnitZ;
     this.reactors            = new List <DxfObject>();
     this.xData               = new XDataDictionary();
     this.xData.AddAppReg    += this.XData_AddAppReg;
     this.xData.RemoveAppReg += this.XData_RemoveAppReg;
 }
예제 #7
0
 protected EntityObject(EntityType type, string dxfCode)
     : base(dxfCode)
 {
     this.type = type;
     this.color = AciColor.ByLayer;
     this.layer = Layer.Default;
     this.lineType = LineType.ByLayer;
     this.lineweight = Lineweight.ByLayer;
     this.transparency = Transparency.ByLayer;
     this.lineTypeScale = 1.0;
     this.isVisible = true;
     this.normal = Vector3.UnitZ;
     this.reactors = new List<DxfObject>();
     this.xData = new XDataDictionary();
     this.xData.AddAppReg += this.XData_AddAppReg;
     this.xData.RemoveAppReg += this.XData_RemoveAppReg;
 }
예제 #8
0
파일: TableObject.cs 프로젝트: 894880010/MP
        /// <summary>
        /// Initializes a new instance of the <c>TableObject</c> class.
        /// </summary>
        /// <param name="name">Table name. The following characters \&lt;&gt;/?":;*|,=` are not supported for table object names.</param>
        /// <param name="codeName">Table <see cref="DxfObjectCode">code name</see>.</param>
        /// <param name="checkName">Defines if the table object name needs to be checked for invalid characters.</param>
        protected TableObject(string name, string codeName, bool checkName)
            : base(codeName)
        {
            if (checkName)
            {
                if (!IsValidName(name))
                {
                    throw new ArgumentException("The name should be at least one character long and the following characters \\<>/?\":;*|,=` are not supported.", nameof(name));
                }
            }

            this.name                = name;
            this.reserved            = false;
            this.xData               = new XDataDictionary();
            this.xData.AddAppReg    += this.XData_AddAppReg;
            this.xData.RemoveAppReg += this.XData_RemoveAppReg;
        }
예제 #9
0
 private TmpCadxdata ReadXData(TmpCadxdata cadxdata, XDataDictionary datas2)
 {
     int count = 0;
     List<string> attrs=new List<string>();
     List<XData> datas = datas2.Values.ToList();
     for (int j = 0; j < datas2.Values.Count; j++)
     {
         List<XDataRecord> records = datas[j].XDataRecord;
         for (int k = 0; k < records.Count; k++)
         {
             string pValue = records[k].Value.ToString().Trim();
             if(!string.IsNullOrEmpty(pValue))
                 attrs.Add(pValue);
         }
     }
     cadxdata.Cassdm=attrs.Count>0?attrs[0]:"";
     cadxdata.Fsxx1 = attrs.Count > 1 ? attrs[1] : "";
     cadxdata.Fsxx2 = attrs.Count > 2 ? attrs[2] : "";
     return cadxdata;
 }
예제 #10
0
 private void XData_RemoveAppReg(XDataDictionary sender, ObservableCollectionEventArgs <ApplicationRegistry> e)
 {
     this.OnXDataRemoveAppRegEvent(e.Item);
 }
예제 #11
0
 private void XData_RemoveAppReg(XDataDictionary sender, ObservableCollectionEventArgs<ApplicationRegistry> e)
 {
     this.OnXDataRemoveAppRegEvent(e.Item);
 }
예제 #12
0
        private void WriteXData(XDataDictionary xData)
        {
            foreach (string appReg in xData.AppIds)
            {
                this.chunk.Write(XDataCode.AppReg, this.EncodeNonAsciiCharacters(appReg));

                foreach (XDataRecord x in xData[appReg].XDataRecord)
                {
                    short code = x.Code;
                    object value = x.Value;
                    if (code == 1000 || code == 1003)
                    {
                        this.chunk.Write(code, this.EncodeNonAsciiCharacters((string) value));
                    }
                    else if (code == 1004) // binary extended data is written in chunks of 127 bytes
                    {
                        byte[] bytes = (byte[]) value;
                        byte[] data;
                        int count = bytes.Length;
                        int index = 0;
                        while (count > 127)
                        {
                            data = new byte[127];
                            Array.Copy(bytes, index, data, 0, 127);
                            this.chunk.Write(code, data);
                            count -= 127;
                            index += 127;
                        }
                        data = new byte[bytes.Length - index];
                        Array.Copy(bytes, index, data, 0, bytes.Length - index);
                        this.chunk.Write(code, data);
                    }
                    else
                        this.chunk.Write(code, value);
                }
            }
        }
예제 #13
0
 private void XData_AddAppReg(XDataDictionary sender, ObservableCollectionEventArgs <ApplicationRegistry> e)
 {
     OnXDataAddAppRegEvent(e.Item);
 }
예제 #14
0
파일: DxfReader.cs 프로젝트: Core2D/netdxf
        private Layer ReadLayer()
        {
            Debug.Assert(this.chunk.ReadString() == SubclassMarker.Layer);

            string name = null;
            bool isVisible = true;
            bool plot = true;
            AciColor color = AciColor.Default;
            Linetype linetype = Linetype.ByLayer;
            Lineweight lineweight = Lineweight.Default;
            LayerFlags flags = LayerFlags.None;
            Transparency transparency = new Transparency(0);
            XDataDictionary xData = new XDataDictionary();
            this.chunk.Next();

            while (this.chunk.Code != 0)
            {
                switch (this.chunk.Code)
                {
                    case 2:
                        name = this.DecodeEncodedNonAsciiCharacters(this.chunk.ReadString());
                        this.chunk.Next();
                        break;
                    case 70:
                        flags = (LayerFlags) this.chunk.ReadShort();
                        this.chunk.Next();
                        break;
                    case 62:
                        short index = this.chunk.ReadShort();
                        if (index < 0)
                        {
                            isVisible = false;
                            index = Math.Abs(index);
                        }
                        if (!color.UseTrueColor)
                            color = AciColor.FromCadIndex(index);

                        this.chunk.Next();
                        break;
                    case 420: // the layer uses true color
                        color = AciColor.FromTrueColor(this.chunk.ReadInt());
                        this.chunk.Next();
                        break;
                    case 6:
                        string linetypeName = this.DecodeEncodedNonAsciiCharacters(this.chunk.ReadString());
                        linetype = this.GetLinetype(linetypeName);
                        this.chunk.Next();
                        break;
                    case 290:
                        plot = this.chunk.ReadBool();
                        this.chunk.Next();
                        break;
                    case 370:
                        lineweight = (Lineweight) this.chunk.ReadShort();
                        this.chunk.Next();
                        break;
                    case 1001:
                        string appId = this.DecodeEncodedNonAsciiCharacters(this.chunk.ReadString());
                        XData data = this.ReadXDataRecord(new ApplicationRegistry(appId));
                        xData.Add(data);
                        break;
                    default:
                        if (this.chunk.Code >= 1000 && this.chunk.Code <= 1071)
                            throw new Exception("The extended data of an entity must start with the application registry code.");
                        this.chunk.Next();
                        break;
                }
            }

            if (string.IsNullOrEmpty(name) || !TableObject.IsValidName(name))
                return null;

            // read the layer transparency from the extended data
            XData xDataTransparency;
            if (xData.TryGetValue("AcCmTransparency", out xDataTransparency))
            {
                // there should be only one entry with the transparency value, the first 1071 code will be used
                foreach (XDataRecord record in xDataTransparency.XDataRecord)
                {
                    if (record.Code == XDataCode.Int32)
                    {
                        transparency = Transparency.FromAlphaValue((int) record.Value);
                        break;
                    }
                }
            }

            return new Layer(name, false)
            {
                Color = color,
                Linetype = linetype,
                IsVisible = isVisible,
                IsFrozen = flags.HasFlag(LayerFlags.Frozen),
                IsLocked = flags.HasFlag(LayerFlags.Locked),
                Plot = plot,
                Lineweight = lineweight,
                Transparency = transparency
            };
        }
예제 #15
0
파일: DxfWriter.cs 프로젝트: Core2D/netdxf
        private void AddDimensionStyleOverridesXData(XDataDictionary xdata, DimensionStyleOverrideDictionary overrides, EntityObject entity)
        {
            XData xdataEntry;
            if (xdata.ContainsAppId(ApplicationRegistry.DefaultName))
            {
                xdataEntry = xdata[ApplicationRegistry.DefaultName];
                xdataEntry.XDataRecord.Clear();
            }
            else
            {
                xdataEntry = new XData(new ApplicationRegistry(ApplicationRegistry.DefaultName));
                xdata.Add(xdataEntry);
            }
            xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.String, "DSTYLE"));
            xdataEntry.XDataRecord.Add(XDataRecord.OpenControlString);
            bool writeDIMPOST = false;
            string prefix = string.Empty;
            string suffix = string.Empty;
            bool writeDIMSAH = false;
            bool writeDIMZIN = false;
            bool writeDIMAZIN = false;
            bool suppressLinearLeadingZeros = false;
            bool suppressLinearTrailingZeros = false;
            bool suppressAngularLeadingZeros = false;
            bool suppressAngularTrailingZeros = false;
            bool suppressZeroFeet = true;
            bool suppressZeroInches = true;
            foreach (DimensionStyleOverride styleOverride in overrides.Values)
            {
                switch (styleOverride.Type)
                {
                    case DimensionStyleOverrideType.DimLineColor:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 176));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, ((AciColor) styleOverride.Value).Index));
                        break;
                    case DimensionStyleOverrideType.DimLineLinetype:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 345));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.DatabaseHandle, ((Linetype) styleOverride.Value).Handle));
                        break;
                    case DimensionStyleOverrideType.DimLineLineweight:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 371));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) (Lineweight) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.DimLineExtend:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 46));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Real, (double) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.ExtLineColor:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 177));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, ((AciColor) styleOverride.Value).Index));
                        break;
                    case DimensionStyleOverrideType.ExtLine1Linetype:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 346));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.DatabaseHandle, ((Linetype) styleOverride.Value).Handle));
                        break;
                    case DimensionStyleOverrideType.ExtLine2Linetype:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 347));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.DatabaseHandle, ((Linetype) styleOverride.Value).Handle));
                        break;
                    case DimensionStyleOverrideType.ExtLineLineweight:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 372));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) (Lineweight) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.ExtLine1:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 75));
                        if ((bool) styleOverride.Value)
                            xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 1));
                        else
                            xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 0));
                        break;
                    case DimensionStyleOverrideType.ExtLine2:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 76));
                        if ((bool) styleOverride.Value)
                            xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 1));
                        else
                            xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 0));
                        break;
                    case DimensionStyleOverrideType.ExtLineOffset:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 42));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Real, (double) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.ExtLineExtend:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 44));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Real, (double) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.ArrowSize:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 41));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Real, (double) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.CenterMarkSize:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 141));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Real, (double) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.LeaderArrow:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 341));
                        xdataEntry.XDataRecord.Add(styleOverride.Value != null
                            ? new XDataRecord(XDataCode.DatabaseHandle, ((Block) styleOverride.Value).Record.Handle)
                            : new XDataRecord(XDataCode.DatabaseHandle, "0"));
                        break;
                    case DimensionStyleOverrideType.DimArrow1:
                        writeDIMSAH = true;
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 343));
                        xdataEntry.XDataRecord.Add(styleOverride.Value != null
                            ? new XDataRecord(XDataCode.DatabaseHandle, ((Block) styleOverride.Value).Record.Handle)
                            : new XDataRecord(XDataCode.DatabaseHandle, "0"));
                        break;
                    case DimensionStyleOverrideType.DimArrow2:
                        writeDIMSAH = true;
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 344));
                        xdataEntry.XDataRecord.Add(styleOverride.Value != null
                            ? new XDataRecord(XDataCode.DatabaseHandle, ((Block) styleOverride.Value).Record.Handle)
                            : new XDataRecord(XDataCode.DatabaseHandle, "0"));
                        break;
                    case DimensionStyleOverrideType.TextStyle:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 340));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.DatabaseHandle, ((TextStyle) styleOverride.Value).Handle));
                        break;
                    case DimensionStyleOverrideType.TextColor:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 178));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, ((AciColor) styleOverride.Value).Index));
                        break;
                    case DimensionStyleOverrideType.TextHeight:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 140));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Real, (double) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.TextOffset:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 147));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Real, (double) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.DimScaleOverall:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 40));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Real, (double) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.AngularPrecision:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 179));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.LengthPrecision:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 271));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.DimPrefix:
                        writeDIMPOST = true;
                        prefix = (string) styleOverride.Value;
                        break;
                    case DimensionStyleOverrideType.DimSuffix:
                        writeDIMPOST = true;
                        suffix = (string) styleOverride.Value;
                        break;
                    case DimensionStyleOverrideType.DecimalSeparator:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 278));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) (char) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.DimScaleLinear:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 144));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Real, (double) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.DimLengthUnits:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 277));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) (LinearUnitType) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.DimAngularUnits:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 275));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) (AngleUnitType) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.FractionalType:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 276));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) (FractionFormatType) styleOverride.Value));
                        break;
                    case DimensionStyleOverrideType.SuppressZeroFeet:
                        writeDIMZIN = true;
                        suppressZeroFeet = (bool) styleOverride.Value;
                        break;
                    case DimensionStyleOverrideType.SuppressZeroInches:
                        writeDIMZIN = true;
                        suppressZeroInches = (bool) styleOverride.Value;
                        break;
                    case DimensionStyleOverrideType.SuppressLinearLeadingZeros:
                        writeDIMZIN = true;
                        suppressLinearLeadingZeros = (bool) styleOverride.Value;
                        break;
                    case DimensionStyleOverrideType.SuppressLinearTrailingZeros:
                        writeDIMZIN = true;
                        suppressLinearTrailingZeros = (bool) styleOverride.Value;
                        break;
                    case DimensionStyleOverrideType.SuppressAngularLeadingZeros:
                        writeDIMAZIN = true;
                        suppressAngularLeadingZeros = (bool) styleOverride.Value;
                        break;
                    case DimensionStyleOverrideType.SuppressAngularTrailingZeros:
                        writeDIMAZIN = true;
                        suppressAngularTrailingZeros = (bool) styleOverride.Value;
                        break;
                    case DimensionStyleOverrideType.DimRoundoff:
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 45));
                        xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) styleOverride.Value));
                        break;
                }
            }

            if (writeDIMSAH)
            {
                xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 173));
                xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 1));
            }

            if (writeDIMPOST)
            {
                xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 3));
                xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.String, this.EncodeNonAsciiCharacters(string.Format("{0}<>{1}", prefix, suffix))));
            }

            if (writeDIMZIN)
            {
                short linSupress = 0;
                if (suppressZeroFeet && suppressZeroInches)
                    linSupress = 0;
                else if (!suppressZeroFeet && !suppressZeroInches)
                    linSupress += 1;
                else if (!suppressZeroFeet && suppressZeroInches)
                    linSupress += 2;
                else if (suppressZeroFeet && !suppressZeroInches)
                    linSupress += 3;

                if (!suppressLinearLeadingZeros && !suppressLinearTrailingZeros)
                    linSupress += 0;
                else if (suppressLinearLeadingZeros && !suppressLinearTrailingZeros)
                    linSupress += 4;
                else if (!suppressLinearLeadingZeros && suppressLinearTrailingZeros)
                    linSupress += 8;
                else if (suppressLinearLeadingZeros && suppressLinearTrailingZeros)
                    linSupress += 12;

                xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 78));
                xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, linSupress));
            }

            if (writeDIMAZIN)
            {
                short angSupress = 3;
                if (suppressAngularLeadingZeros && suppressAngularTrailingZeros)
                    angSupress = 3;
                else if (!suppressAngularLeadingZeros && !suppressAngularTrailingZeros)
                    angSupress = 0;
                else if (!suppressAngularLeadingZeros && suppressAngularTrailingZeros)
                    angSupress = 2;
                else if (suppressAngularLeadingZeros && !suppressAngularTrailingZeros)
                    angSupress = 1;

                xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 79));
                xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, angSupress));
            }

            // this information is only required by the Leader entity
            Leader leader = entity as Leader;
            if (leader != null)
            {
                MText mText = leader.Annotation as MText;
                if (mText != null)
                {
                    xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 70));
                    xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) mText.AttachmentPoint));
                    xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 77));
                    xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) leader.TextVerticalPosition));
                }
            }

            xdataEntry.XDataRecord.Add(XDataRecord.CloseControlString);
        }
예제 #16
0
파일: DxfObject.cs 프로젝트: jcambert/WeETL
 public DxfObject(/*string codeName*/)
 {
     // Check.NotNull(codeName, nameof(codeName));
     //CodeName = codeName;
     XData = new XDataDictionary();
 }