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); }
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); } }
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; } }
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); }
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)); }
public RectangleF MeasureRotatedString(string text, StiFontGeom font, PointF point, StiStringFormatGeom sf, StiRotationMode mode, float angle) { return(contextPainter.MeasureRotatedString(text, font, point, sf, mode, angle)); }
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);
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); }
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); }
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)); }
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)); }
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)); }