public Dimension(netDxf.Entities.Dimension inputDimension) { this.inputDimension = inputDimension; textBlock.Text = inputDimension.Measurement.ToString("N2"); textBlock.Text = inputDimension.Measurement.ToString("0.##"); //textBlock.Text = "AAA"; // MinXMinY = new Vector3(inputDimension.TextReferencePoint.X, inputDimension.TextReferencePoint.Y, 0); MinXMinY = new Vector3(inputDimension.TextReferencePoint.X, inputDimension.TextReferencePoint.Y, 0); MaxXMaxY = new Vector3(inputDimension.TextReferencePoint.X, inputDimension.TextReferencePoint.Y, 0); textBlock.Foreground = new SolidColorBrush(Colors.Black); textBlock.FontSize = 4; }
private void WriteDimension(Dimension dim) { this.chunk.Write(100, SubclassMarker.Dimension); this.chunk.Write(2, this.EncodeNonAsciiCharacters(dim.Block.Name)); this.chunk.Write(10, dim.DefinitionPoint.X); this.chunk.Write(20, dim.DefinitionPoint.Y); this.chunk.Write(30, dim.DefinitionPoint.Z); this.chunk.Write(11, dim.MidTextPoint.X); this.chunk.Write(21, dim.MidTextPoint.Y); this.chunk.Write(31, dim.MidTextPoint.Z); short flags = (short) (dim.DimensionType + (short) DimensionTypeFlags.BlockReference); if (dim.DimensionType == DimensionType.Ordinate) { // even if the documentation says that code 51 is optional, rotated ordinate dimensions will not work correctly is this value is not provided this.chunk.Write(51, 360 - ((OrdinateDimension) dim).Rotation); if (((OrdinateDimension) dim).Axis == OrdinateDimensionAxis.X) flags += (short) DimensionTypeFlags.OrdinteType; } this.chunk.Write(70, flags); this.chunk.Write(71, (short) dim.AttachmentPoint); this.chunk.Write(72, (short) dim.LineSpacingStyle); this.chunk.Write(41, dim.LineSpacingFactor); if (dim.UserText != null) this.chunk.Write(1, this.EncodeNonAsciiCharacters(dim.UserText)); this.chunk.Write(210, dim.Normal.X); this.chunk.Write(220, dim.Normal.Y); this.chunk.Write(230, dim.Normal.Z); this.chunk.Write(3, this.EncodeNonAsciiCharacters(dim.Style.Name)); switch (dim.DimensionType) { case DimensionType.Aligned: this.WriteAlignedDimension((AlignedDimension) dim); break; case DimensionType.Linear: this.WriteLinearDimension((LinearDimension) dim); break; case DimensionType.Radius: this.WriteRadialDimension((RadialDimension) dim); break; case DimensionType.Diameter: this.WriteDiametricDimension((DiametricDimension) dim); break; case DimensionType.Angular3Point: this.WriteAngular3PointDimension((Angular3PointDimension) dim); break; case DimensionType.Angular: this.WriteAngular2LineDimension((Angular2LineDimension) dim); break; case DimensionType.Ordinate: this.WriteOrdinateDimension((OrdinateDimension) dim); break; } }
private static DimensionStyle BuildDimensionStyleOverride(Dimension dim) { // to avoid the cloning, return the actual dimension style if there are no overrides if (dim.StyleOverrides.Count == 0) return dim.Style; // make a shallow copy of the actual dimension style, there is no need of the full copy that the Clone method does DimensionStyle copy = new DimensionStyle(dim.Style.Name) { // dimension lines DimLineColor = dim.Style.DimLineColor, DimLineLinetype = dim.Style.DimLineLinetype, DimLineLineweight = dim.Style.DimLineLineweight, DimBaselineSpacing = dim.Style.DimBaselineSpacing, DimLineExtend = dim.Style.DimLineExtend, // extension lines ExtLineColor = dim.Style.ExtLineColor, ExtLine1Linetype = dim.Style.ExtLine1Linetype, ExtLine2Linetype = dim.Style.ExtLine2Linetype, ExtLineLineweight = dim.Style.ExtLineLineweight, ExtLine1 = dim.Style.ExtLine1, ExtLine2 = dim.Style.ExtLine2, ExtLineOffset = dim.Style.ExtLineOffset, ExtLineExtend = dim.Style.ExtLineExtend, // symbols and arrows ArrowSize = dim.Style.ArrowSize, CenterMarkSize = dim.Style.CenterMarkSize, // fit DIMTIH = dim.Style.DIMTIH, DIMTOH = dim.Style.DIMTOH, // text appearance TextStyle = dim.Style.TextStyle, TextColor = dim.Style.TextColor, TextHeight = dim.Style.TextHeight, DIMJUST = dim.Style.DIMJUST, DIMTAD = dim.Style.DIMTAD, TextOffset = dim.Style.TextOffset, // primary units AngularPrecision = dim.Style.AngularPrecision, LengthPrecision = dim.Style.LengthPrecision, DecimalSeparator = dim.Style.DecimalSeparator, DimAngularUnits = dim.Style.DimAngularUnits, LeaderArrow = dim.Style.LeaderArrow, DimArrow1 = dim.Style.DimArrow1, DimArrow2 = dim.Style.DimArrow2 }; foreach (DimensionStyleOverride styleOverride in dim.StyleOverrides.Values) { switch (styleOverride.Type) { case DimensionStyleOverrideType.DimLineColor: copy.DimLineColor = (AciColor) styleOverride.Value; break; case DimensionStyleOverrideType.DimLineLinetype: copy.DimLineLinetype = (Linetype) styleOverride.Value; break; case DimensionStyleOverrideType.DimLineLineweight: copy.DimLineLineweight = (Lineweight) styleOverride.Value; break; case DimensionStyleOverrideType.DimLineExtend: copy.DimLineExtend = (double) styleOverride.Value; break; case DimensionStyleOverrideType.ExtLineColor: copy.ExtLineColor = (AciColor) styleOverride.Value; break; case DimensionStyleOverrideType.ExtLine1Linetype: copy.ExtLine1Linetype = (Linetype) styleOverride.Value; break; case DimensionStyleOverrideType.ExtLine2Linetype: copy.ExtLine2Linetype = (Linetype) styleOverride.Value; break; case DimensionStyleOverrideType.ExtLineLineweight: copy.ExtLineLineweight = (Lineweight) styleOverride.Value; break; case DimensionStyleOverrideType.ExtLine1: copy.ExtLine1 = (bool) styleOverride.Value; break; case DimensionStyleOverrideType.ExtLine2: copy.ExtLine2 = (bool) styleOverride.Value; break; case DimensionStyleOverrideType.ExtLineOffset: copy.ExtLineOffset = (double) styleOverride.Value; break; case DimensionStyleOverrideType.ExtLineExtend: copy.ExtLineExtend = (double) styleOverride.Value; break; case DimensionStyleOverrideType.ArrowSize: copy.ArrowSize = (double) styleOverride.Value; break; case DimensionStyleOverrideType.CenterMarkSize: copy.CenterMarkSize = (double) styleOverride.Value; break; case DimensionStyleOverrideType.LeaderArrow: copy.LeaderArrow = (Block) styleOverride.Value; break; case DimensionStyleOverrideType.DimArrow1: copy.DimArrow1 = (Block) styleOverride.Value; break; case DimensionStyleOverrideType.DimArrow2: copy.DimArrow2 = (Block) styleOverride.Value; break; case DimensionStyleOverrideType.TextStyle: copy.TextStyle = (TextStyle) styleOverride.Value; break; case DimensionStyleOverrideType.TextColor: copy.TextColor = (AciColor) styleOverride.Value; break; case DimensionStyleOverrideType.TextHeight: copy.TextHeight = (double) styleOverride.Value; break; case DimensionStyleOverrideType.TextOffset: copy.TextOffset = (double) styleOverride.Value; break; case DimensionStyleOverrideType.DimScaleOverall: copy.DimScaleOverall = (double) styleOverride.Value; break; case DimensionStyleOverrideType.AngularPrecision: copy.AngularPrecision = (short) styleOverride.Value; break; case DimensionStyleOverrideType.LengthPrecision: copy.LengthPrecision = (short) styleOverride.Value; break; case DimensionStyleOverrideType.DimPrefix: copy.DimPrefix = (string) styleOverride.Value; break; case DimensionStyleOverrideType.DimSuffix: copy.DimSuffix = (string) styleOverride.Value; break; case DimensionStyleOverrideType.DecimalSeparator: copy.DecimalSeparator = (char) styleOverride.Value; break; case DimensionStyleOverrideType.DimScaleLinear: copy.DimScaleLinear = (double) styleOverride.Value; break; case DimensionStyleOverrideType.DimLengthUnits: copy.DimLengthUnits = (LinearUnitType) styleOverride.Value; break; case DimensionStyleOverrideType.DimAngularUnits: copy.DimAngularUnits = (AngleUnitType) styleOverride.Value; break; case DimensionStyleOverrideType.FractionalType: copy.FractionalType = (FractionFormatType) styleOverride.Value; break; case DimensionStyleOverrideType.SuppressLinearLeadingZeros: copy.SuppressLinearLeadingZeros = (bool) styleOverride.Value; break; case DimensionStyleOverrideType.SuppressLinearTrailingZeros: copy.SuppressLinearTrailingZeros = (bool) styleOverride.Value; break; case DimensionStyleOverrideType.SuppressAngularLeadingZeros: copy.SuppressAngularLeadingZeros = (bool) styleOverride.Value; break; case DimensionStyleOverrideType.SuppressAngularTrailingZeros: copy.SuppressAngularTrailingZeros = (bool) styleOverride.Value; break; case DimensionStyleOverrideType.SuppressZeroFeet: copy.SuppressZeroFeet = (bool) styleOverride.Value; break; case DimensionStyleOverrideType.SuppressZeroInches: copy.SuppressZeroInches = (bool) styleOverride.Value; break; case DimensionStyleOverrideType.DimRoundoff: copy.DimRoundoff = (double) styleOverride.Value; break; } } return copy; }
private void Dimension_DimStyleOverrideRemoved(Dimension sender, DimensionStyleOverrideChangeEventArgs e) { switch (e.Item.Type) { case DimensionStyleOverrideType.DimLineLinetype: case DimensionStyleOverrideType.ExtLine1Linetype: case DimensionStyleOverrideType.ExtLine2Linetype: Linetype linetype = (Linetype) e.Item.Value; this.linetypes.References[linetype.Name].Remove(sender); break; case DimensionStyleOverrideType.LeaderArrow: case DimensionStyleOverrideType.DimArrow1: case DimensionStyleOverrideType.DimArrow2: Block block = (Block) e.Item.Value; if (block == null) return; // the block might be defined as null to indicate that the default arrowhead will be used this.blocks.References[block.Name].Remove(sender); break; case DimensionStyleOverrideType.TextStyle: TextStyle style = (TextStyle) e.Item.Value; this.textStyles.References[style.Name].Remove(sender); break; } }
private void Dimension_DimStyleChanged(Dimension sender, TableObjectChangedEventArgs<DimensionStyle> e) { this.dimStyles.References[e.OldValue.Name].Remove(sender); e.NewValue = this.dimStyles.Add(e.NewValue); this.dimStyles.References[e.NewValue.Name].Add(sender); }
private void Dimension_DimBlockChanged(Dimension sender, TableObjectChangedEventArgs<Block> e) { this.blocks.References[e.OldValue.Name].Remove(sender); this.blocks.Remove(e.OldValue); e.NewValue = this.blocks.Add(e.NewValue); this.blocks.References[e.NewValue.Name].Add(sender); }
private void AddDimensionStyleOverrides(Dimension dim, bool assignHandle) { // add the style override referenced DxfObjects DimensionStyleOverride styleOverride; // add referenced text style if (dim.StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextStyle, out styleOverride)) { TextStyle dimtxtsty = (TextStyle) styleOverride.Value; dim.StyleOverrides[styleOverride.Type] = new DimensionStyleOverride(styleOverride.Type, this.textStyles.Add(dimtxtsty, assignHandle)); this.textStyles.References[dimtxtsty.Name].Add(dim); } // add referenced blocks if (dim.StyleOverrides.TryGetValue(DimensionStyleOverrideType.LeaderArrow, out styleOverride)) { Block block = (Block) styleOverride.Value; if (block != null) { dim.StyleOverrides[styleOverride.Type] = new DimensionStyleOverride(styleOverride.Type, this.blocks.Add(block, assignHandle)); this.blocks.References[block.Name].Add(dim); } } if (dim.StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimArrow1, out styleOverride)) { Block block = (Block) styleOverride.Value; if (block != null) { dim.StyleOverrides[styleOverride.Type] = new DimensionStyleOverride(styleOverride.Type, this.blocks.Add(block, assignHandle)); this.blocks.References[block.Name].Add(dim); } } if (dim.StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimArrow2, out styleOverride)) { Block block = (Block) styleOverride.Value; if (block != null) { dim.StyleOverrides[styleOverride.Type] = new DimensionStyleOverride(styleOverride.Type, this.blocks.Add(block, assignHandle)); this.blocks.References[block.Name].Add(dim); } } // add referenced line types if (dim.StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimLineLinetype, out styleOverride)) { Linetype linetype = (Linetype) styleOverride.Value; dim.StyleOverrides[styleOverride.Type] = new DimensionStyleOverride(styleOverride.Type, this.linetypes.Add(linetype, assignHandle)); this.linetypes.References[linetype.Name].Add(dim); } if (dim.StyleOverrides.TryGetValue(DimensionStyleOverrideType.ExtLine1Linetype, out styleOverride)) { Linetype linetype = (Linetype) styleOverride.Value; dim.StyleOverrides[styleOverride.Type] = new DimensionStyleOverride(styleOverride.Type, this.linetypes.Add(linetype, assignHandle)); this.linetypes.References[linetype.Name].Add(dim); } if (dim.StyleOverrides.TryGetValue(DimensionStyleOverrideType.ExtLine2Linetype, out styleOverride)) { Linetype linetype = (Linetype) styleOverride.Value; dim.StyleOverrides[styleOverride.Type] = new DimensionStyleOverride(styleOverride.Type, this.linetypes.Add(linetype, assignHandle)); this.linetypes.References[linetype.Name].Add(dim); } }