Esempio n. 1
0
 internal void method_0(DxfModel model)
 {
     if ((this.elementType_0 & DxfLineType.ElementType.IsShape) != DxfLineType.ElementType.None)
     {
         if (this.TextStyle == null)
         {
             return;
         }
         ShxFile shxFile = this.TextStyle.GetShxFile();
         if (shxFile == null)
         {
             return;
         }
         ShxShape shapeByIndex = shxFile.GetShapeByIndex((ushort)this.short_0);
         if (shapeByIndex == null)
         {
             return;
         }
         WW.Math.Point2D endPoint;
         this.fillableShape2D_0 = new FillableShape2D(shapeByIndex.GetGlyphShape(this.TextStyle.IsVertical, out endPoint), false);
     }
     else
     {
         if ((this.elementType_0 & DxfLineType.ElementType.IsText) == DxfLineType.ElementType.None || this.TextStyle == null)
         {
             return;
         }
         Class425        class425     = Class594.smethod_10(this.string_0, 1.0, this.TextStyle.ObliqueAngle, this.TextStyle.WidthFactor, this.TextStyle, Colors.White);
         List <Class908> class908List = new List <Class908>();
         class425.imethod_3((ICollection <Class908>)class908List, Matrix4D.Identity, (short)0);
         GeneralShape2D generalShape2D = new GeneralShape2D();
         bool           filled         = false;
         foreach (Class908 class908 in class908List)
         {
             generalShape2D.Append(class908.FontPath, false);
             if (class908.Font.Filled)
             {
                 filled = true;
             }
         }
         if (!generalShape2D.HasSegments)
         {
             return;
         }
         generalShape2D.ShrinkWrap();
         this.fillableShape2D_0 = new FillableShape2D((IShape2D) new CachedBoundsShape2D((IShape2D)generalShape2D), filled);
     }
 }
Esempio n. 2
0
        internal static IList <Class908> smethod_6(
            DxfText text,
            Color color,
            short lineWeight,
            Matrix4D insertionTransformation,
            Bounds2D collectBounds,
            out Vector2D alignmentTranslation,
            out Vector2D alignmentScaling)
        {
            Class425 class425 = Class594.smethod_10(text.DisplayString, text.Height, text.ObliqueAngle, text.WidthFactor, text.Style, color);
            Vector2D zero     = Vector2D.Zero;

            class425.imethod_0(ref zero, text.Height, Enum24.flag_3);
            alignmentTranslation = Vector2D.Zero;
            Bounds2D bounds = class425.GetBounds(Enum24.flag_0, (Class985)null);

            if (zero != Vector2D.Zero)
            {
                bounds.Update(0.0, 0.0);
                bounds.Update(zero.X, zero.Y);
            }
            double x = 1.0;
            double y = 1.0;

            if (bounds.Initialized && text.AlignmentPoint2.HasValue)
            {
                if (text.VerticalAlignment != TextVerticalAlignment.Baseline)
                {
                    switch (text.VerticalAlignment)
                    {
                    case TextVerticalAlignment.Bottom:
                        alignmentTranslation.Y = class425.Blocks.Count > 0 ? class425.Blocks.First.Value.Settings.Font.Metrics.Descent : -bounds.Min.Y;
                        break;

                    case TextVerticalAlignment.Middle:
                        alignmentTranslation.Y = -0.5 * text.Height;
                        break;

                    case TextVerticalAlignment.Top:
                        alignmentTranslation.Y = -text.Height;
                        break;
                    }
                }
                switch (text.HorizontalAlignment)
                {
                case TextHorizontalAlignment.Left:
                    alignmentTranslation.X = -bounds.Corner1.X;
                    break;

                case TextHorizontalAlignment.Center:
                    alignmentTranslation.X = -bounds.Center.X;
                    break;

                case TextHorizontalAlignment.Right:
                    alignmentTranslation.X = -bounds.Corner2.X;
                    break;

                case TextHorizontalAlignment.Aligned:
                    x      = (text.AlignmentPoint2.Value - text.AlignmentPoint1).GetLength() / bounds.Delta.X;
                    y      = x;
                    bounds = new Bounds2D(new WW.Math.Point2D(bounds.Corner1.X, y * bounds.Corner1.Y), new WW.Math.Point2D(bounds.Corner1.X + x * bounds.Delta.X, y * bounds.Corner2.Y));
                    alignmentTranslation.X = -bounds.Corner2.X;
                    break;

                case TextHorizontalAlignment.Middle:
                    alignmentTranslation.Y = -bounds.Center.Y;
                    alignmentTranslation.X = -bounds.Center.X;
                    break;

                case TextHorizontalAlignment.Fit:
                    x      = (text.AlignmentPoint2.Value - text.AlignmentPoint1).GetLength() / bounds.Delta.X;
                    bounds = new Bounds2D(bounds.Corner1, new WW.Math.Point2D(bounds.Corner1.X + x * bounds.Delta.X, bounds.Corner2.Y));
                    alignmentTranslation.X = -bounds.Corner2.X;
                    break;
                }
            }
            IList <Class908> class908List = (IList <Class908>) new List <Class908>();

            class425.imethod_3((ICollection <Class908>)class908List, insertionTransformation * Transformation4D.Translation(alignmentTranslation.X, alignmentTranslation.Y, 0.0) * Transformation4D.Scaling(x, y, 1.0), lineWeight);
            if (collectBounds != null)
            {
                bounds.Move(alignmentTranslation.X, alignmentTranslation.Y);
                collectBounds.Update(bounds);
            }
            alignmentScaling = new Vector2D(x, y);
            return(class908List);
        }