示例#1
0
 public static void DrawString(Graphics g, string text, Font font, Brush brush,
                               PointF point, StringFormat stringFormat, StiRotationMode rotationMode, float angle, bool antialiasing,
                               int maximalWidth)
 {
     DrawString(g, text, font, brush, point, stringFormat, rotationMode, angle,
                antialiasing, true, false, maximalWidth);
 }
示例#2
0
        private static PointF GetStartPoint(StiRotationMode rotationMode, RectangleF textRect)
        {
            PointF centerPoint = new PointF(textRect.X + (textRect.Width / 2), textRect.Y + (textRect.Height / 2));

            switch (rotationMode)
            {
            case StiRotationMode.LeftCenter:
                return(new PointF(textRect.X, centerPoint.Y));

            case StiRotationMode.LeftBottom:
                return(new PointF(textRect.X, textRect.Bottom));

            case StiRotationMode.CenterTop:
                return(new PointF(centerPoint.X, textRect.Top));

            case StiRotationMode.CenterCenter:
                return(centerPoint);

            case StiRotationMode.CenterBottom:
                return(new PointF(centerPoint.X, textRect.Bottom));

            case StiRotationMode.RightTop:
                return(new PointF(textRect.Right, textRect.Top));

            case StiRotationMode.RightCenter:
                return(new PointF(textRect.Right, centerPoint.Y));

            case StiRotationMode.RightBottom:
                return(new PointF(textRect.Right, textRect.Bottom));

            default:
                return(textRect.Location);
            }
        }
示例#3
0
        public static void DrawString(Graphics g, string text, Font font, Brush brush,
                                      RectangleF rect, StringFormat stringFormat, StiRotationMode rotationMode, float angle, bool antialiasing,
                                      int maximalWidth)
        {
            PointF point = new PointF(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);

            DrawString(g, text, font, brush, point, stringFormat, rotationMode, angle, antialiasing, maximalWidth);
        }
        public static void CalculateAngle(StiTextDockMode dockMode, ref float angle, ref StiRotationMode rotationMode)
        {
            switch (dockMode)
            {
            case StiTextDockMode.Top:
                if (angle == 0f)
                {
                    rotationMode = StiRotationMode.CenterBottom;
                }
                else if (angle >= 0)
                {
                    rotationMode = StiRotationMode.LeftCenter;
                }
                else if (angle <= -0)
                {
                    rotationMode = StiRotationMode.RightCenter;
                }
                break;

            case StiTextDockMode.Bottom:
                if (angle == 0f)
                {
                    rotationMode = StiRotationMode.CenterTop;
                }
                else if (angle >= 0)
                {
                    rotationMode = StiRotationMode.RightCenter;
                }
                else if (angle <= -0)
                {
                    rotationMode = StiRotationMode.LeftCenter;
                }
                break;

            case StiTextDockMode.Left:
                rotationMode = StiRotationMode.RightCenter;
                break;

            case StiTextDockMode.Right:
                rotationMode = StiRotationMode.LeftCenter;
                break;
            }
        }
示例#5
0
        public StiTextGeom DrawRotatedString(string text, StiFontGeom font, object brush, PointF pos, StiStringFormatGeom sf, StiRotationMode mode,
                                             float angle, bool antialiasing)
        {
            StiTextGeom textGeom = new StiTextGeom(text, font, brush, pos, sf, angle, antialiasing, mode, true);

            geoms.Add(textGeom);
            return(textGeom);
        }
示例#6
0
 public void DrawAnimationLabel(string text, StiFontGeom font, object textBrush, object labelBrush, StiPenGeom penBorder, Rectangle rect, StiStringFormatGeom sf, StiRotationMode mode,
                                float angle, bool drawBorder, TimeSpan duration, TimeSpan?beginTime)
 {
     geoms.Add(new StiLabelAnimationGeom(text, font, textBrush, labelBrush, penBorder, rect, sf, mode, angle, drawBorder, duration, beginTime));
 }
示例#7
0
 public RectangleF MeasureRotatedString(string text, StiFontGeom font, PointF point, StiStringFormatGeom sf, StiRotationMode mode, float angle)
 {
     return(contextPainter.MeasureRotatedString(text, font, point, sf, mode, angle));
 }
示例#8
0
        public StiTextGeom DrawRotatedString(string text, StiFontGeom font, object brush, RectangleF rect, StiStringFormatGeom sf, StiRotationMode mode,
                                             float angle, bool antialiasing, int maximalWidth)
        {
            StiTextGeom textGeom = new StiTextGeom(text, font, brush, rect, sf, angle, antialiasing, maximalWidth, mode, true);

            geoms.Add(textGeom);
            return(textGeom);
        }
 public StiLabelAnimationGeom(string text, StiFontGeom font, object textBrush, object LabelBrush, StiPenGeom penBorder, Rectangle rect, StiStringFormatGeom sf, StiRotationMode rotationMode,
                              float angle, bool drawBorder, TimeSpan duration, TimeSpan?beginTime) : base(duration, beginTime)
 {
     this.Text         = text;
     this.Font         = font;
     this.TextBrush    = textBrush;
     this.LabelBrush   = LabelBrush;
     this.PenBorder    = penBorder;
     this.Rectangle    = rect;
     this.StringFormat = sf;
     this.RotationMode = rotationMode;
     this.Angle        = angle;
     this.DrawBorder   = drawBorder;
 }
 public abstract RectangleF MeasureRotatedString(string text, StiFontGeom font, PointF point, StiStringFormatGeom sf, StiRotationMode mode, float angle);
示例#11
0
        private static RectangleF DrawString(Graphics g, string text, Font font, Brush brush,
                                             PointF point, StringFormat stringFormat, StiRotationMode rotationMode, float angle,
                                             bool antialiasing, bool draw, bool measure, int maximalWidth)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(new RectangleF(point.X, point.Y, 0, 0));
            }
            SizeF textSize = g.MeasureString(text, font, maximalWidth, stringFormat);

            if (textSize.Width == 0 && textSize.Height == 0)
            {
                return(new RectangleF(point.X, point.Y, 0, 0));
            }
            GraphicsState state = g.Save();

            TextRenderingHint textHint = g.TextRenderingHint;

            if (antialiasing)
            {
                g.TextRenderingHint = TextRenderingHint.AntiAlias;
            }

            float px = point.X;
            float py = point.Y;


            RectangleF textRect = new RectangleF(0, 0, textSize.Width, textSize.Height);

            g.TranslateTransform(px, py);
            g.RotateTransform(angle);

            PointF startPoint = GetStartPoint(rotationMode, textRect);

            textRect.X -= startPoint.X;
            textRect.Y -= startPoint.Y;

            RectangleF rect = RectangleF.Empty;

            if (textRect.Width != 0 && textRect.Height != 0)
            {
                if (draw)
                {
                    g.DrawString(text, font, brush, textRect, stringFormat);
                }

                //Red line
                //if (draw)
                //g.DrawLine(Pens.Red, textRect.X, textRect.Y + textRect.Height / 2, textRect.Right, textRect.Y + textRect.Height / 2);

                if (measure)
                {
                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddRectangle(textRect);
                        path.Transform(g.Transform);
                        rect = path.GetBounds();
                    }
                }

                if (antialiasing)
                {
                    g.TextRenderingHint = textHint;
                }
            }

            g.RotateTransform(-angle);
            g.TranslateTransform(-px, -py);

            if (measure)
            {
                rect = new RectangleF(rect.X - g.Transform.OffsetX, rect.Y - g.Transform.OffsetY, rect.Width, rect.Height);
            }

            rect.Width++;
            rect.Height++;

            g.Restore(state);

            return(rect);
        }
示例#12
0
 public static void DrawString(Graphics g, string text, Font font, Brush brush,
                               RectangleF rect, StringFormat stringFormat, StiRotationMode rotationMode, float angle, bool antialiasing)
 {
     DrawString(g, text, font, brush,
                rect, stringFormat, rotationMode, angle, antialiasing, 0);
 }
示例#13
0
 public static RectangleF MeasureString(Graphics g, string text, Font font,
                                        RectangleF rect, StringFormat stringFormat, StiRotationMode rotationMode, float angle)
 {
     return(MeasureString(g, text, font,
                          rect, stringFormat, rotationMode, angle, 0));
 }
示例#14
0
        public static RectangleF MeasureString(Graphics g, string text, Font font,
                                               RectangleF rect, StringFormat stringFormat, StiRotationMode rotationMode, float angle, int maximalWidth)
        {
            PointF point = new PointF(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);

            return(DrawString(g, text, font, null, point, stringFormat, rotationMode, angle,
                              false, false, true, maximalWidth));
        }
示例#15
0
 public static RectangleF MeasureString(Graphics g, string text, Font font,
                                        PointF point, StringFormat stringFormat, StiRotationMode rotationMode, float angle, int maximalWidth)
 {
     return(DrawString(g, text, font, null, point, stringFormat, rotationMode, angle,
                       false, false, true, maximalWidth));
 }