Пример #1
0
        public override Extents GetExtents()
        {
            float thHeight = Height * Lines.Length * 1.425f;
            float thWidth  = 0;

            foreach (string line in Lines)
            {
                thWidth = Math.Max(thWidth, line.Length * Height / 2);
            }

            float    angle = Rotation / 180 * (float)Math.PI;
            Point2D  p1    = new Point2D(0, 0);
            Point2D  p2    = new Point2D(thWidth, 0);
            Point2D  p3    = new Point2D(0, -thHeight);
            Point2D  p4    = new Point2D(thWidth, -thHeight);
            Matrix2D trans = Matrix2D.Transformation(1, 1, angle, P.X, P.Y);

            p1.TransformBy(trans);
            p2.TransformBy(trans);
            p3.TransformBy(trans);
            p4.TransformBy(trans);

            Extents extents = new Extents();

            extents.Add(p1);
            extents.Add(p2);
            extents.Add(p3);
            extents.Add(p4);
            return(extents);
        }
Пример #2
0
        public override Extents GetExtents()
        {
            float offset = Math.Sign(Offset) * (0.5f * TextHeight + Math.Abs(Offset));

            Vector2D dir   = P2 - P1;
            float    angle = dir.Angle;
            float    len   = dir.Length;
            Point2D  p1    = new Point2D(0, 0);
            Point2D  p2    = new Point2D(len, 0);
            Point2D  p3    = p1 + new Vector2D(0, offset);
            Point2D  p4    = p2 + new Vector2D(0, offset);
            Matrix2D trans = Matrix2D.Transformation(1, 1, angle, P1.X, P1.Y);

            p1.TransformBy(trans);
            p2.TransformBy(trans);
            p3.TransformBy(trans);
            p4.TransformBy(trans);

            Extents extents = new Extents();

            extents.Add(p1);
            extents.Add(p2);
            extents.Add(p3);
            extents.Add(p4);
            return(extents);
        }
Пример #3
0
        public override Extents GetExtents()
        {
            float   angle    = Rotation / 180 * (float)Math.PI;
            float   thHeight = Height;
            float   thWidth  = String.Length * thHeight / 2;
            Point2D p1       = new Point2D(0, 0);
            Point2D p2       = new Point2D(thWidth, 0);
            Point2D p3       = new Point2D(0, thHeight);
            Point2D p4       = new Point2D(thWidth, thHeight);
            float   dx       = 0;
            float   dy       = 0;

            if (HorizontalAlignment == StringAlignment.Far)
            {
                dx = -thWidth;
            }
            else if (HorizontalAlignment == StringAlignment.Center)
            {
                dx = -thWidth / 2;
            }
            if (VerticalAlignment == StringAlignment.Far)
            {
                dy = -thHeight;
            }
            else if (VerticalAlignment == StringAlignment.Center)
            {
                dy = -thHeight / 2;
            }
            Vector2D offset = new Vector2D(dx, dy);

            p1 = p1 + offset;
            p2 = p2 + offset;
            p3 = p3 + offset;
            p4 = p4 + offset;
            Matrix2D trans = Matrix2D.Transformation(1, 1, angle, P.X, P.Y);

            p1.TransformBy(trans);
            p2.TransformBy(trans);
            p3.TransformBy(trans);
            p4.TransformBy(trans);

            Extents extents = new Extents();

            extents.Add(p1);
            extents.Add(p2);
            extents.Add(p3);
            extents.Add(p4);
            return(extents);
        }
Пример #4
0
        public override void Draw(DrawParams param)
        {
            float tickSize = 0.5f * TextHeight;

            Vector2D dir   = P2 - P1;
            float    angle = dir.Angle;
            float    len   = dir.Length;

            Matrix2D trans = Matrix2D.Transformation(1, 1, angle, P1.X, P1.Y);

            // Dimension line
            Line dim = new Line(0, Offset, len, Offset);

            dim.OutlineStyle = OutlineStyle;
            dim.TransformBy(trans);
            dim.Draw(param);

            // Left tick
            Line tick1 = new Line(0, -tickSize + Offset, 0, tickSize + Offset);

            tick1.OutlineStyle = OutlineStyle;
            tick1.TransformBy(trans);
            tick1.Draw(param);

            // Right tick
            Line tick2 = new Line(len, -tickSize + Offset, len, tickSize + Offset);

            tick2.OutlineStyle = OutlineStyle;
            tick2.TransformBy(trans);
            tick2.Draw(param);

            // Text
            Text textObj = new Text(len / 2, Offset, String, TextHeight);

            textObj.FontFamily          = FontFamily;
            textObj.FontStyle           = FontStyle;
            textObj.HorizontalAlignment = StringAlignment.Center;
            textObj.VerticalAlignment   = StringAlignment.Center;
            textObj.FillStyle           = FillStyle;
            textObj.OutlineStyle        = OutlineStyle;
            textObj.TransformBy(trans);
            textObj.Draw(param);
        }