|
@@ -318,7 +318,7 @@ public class GdiGraphics : IGraphics
|
|
Graphics.FillEllipse(new SolidBrush(color), point.X - thickness / 2, point.Y - thickness / 2, point.X + thickness / 2, point.Y + thickness / 2);
|
|
Graphics.FillEllipse(new SolidBrush(color), point.X - thickness / 2, point.Y - thickness / 2, point.X + thickness / 2, point.Y + thickness / 2);
|
|
}
|
|
}
|
|
|
|
|
|
- private void TransformText(string text, Font font, PointF position, float rotation, TextFormat format)
|
|
|
|
|
|
+ private void TransformTextVertical(string text, Font font, PointF position, float rotation, TextFormat format)
|
|
{
|
|
{
|
|
DrawData.Translate(position);
|
|
DrawData.Translate(position);
|
|
DrawData.Rotate(rotation);
|
|
DrawData.Rotate(rotation);
|
|
@@ -350,18 +350,6 @@ public class GdiGraphics : IGraphics
|
|
DrawData.Translate(new PointF(0, -baseline + font.FontFamily.GetCellAscent(font.Style) * ratio));
|
|
DrawData.Translate(new PointF(0, -baseline + font.FontFamily.GetCellAscent(font.Style) * ratio));
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
-
|
|
|
|
- switch (format.Alignment)
|
|
|
|
- {
|
|
|
|
- case TextAlignment.Left:
|
|
|
|
- break;
|
|
|
|
- case TextAlignment.Center:
|
|
|
|
- DrawData.Translate(new PointF(-(float)size.Width / 2, 0));
|
|
|
|
- break;
|
|
|
|
- case TextAlignment.Right:
|
|
|
|
- DrawData.Translate(new PointF(-(float)size.Width, 0));
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public void DrawText(string text, Color color, PointF position, float rotation, TextFormat format)
|
|
public void DrawText(string text, Color color, PointF position, float rotation, TextFormat format)
|
|
@@ -371,9 +359,32 @@ public class GdiGraphics : IGraphics
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
DrawData.PushTransform();
|
|
DrawData.PushTransform();
|
|
- TransformText(text, Font, position, rotation, format);
|
|
|
|
|
|
+ TransformTextVertical(text, Font, position, rotation, format);
|
|
|
|
|
|
- Graphics.DrawString(text, Font, new SolidBrush(color), new PointF(0, 0), StringFormat.GenericTypographic);
|
|
|
|
|
|
+ var pos = 0;
|
|
|
|
+ foreach(var line in text.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries))
|
|
|
|
+ {
|
|
|
|
+ DrawData.PushTransform();
|
|
|
|
+ DrawData.Translate(0, pos * Font.Height);
|
|
|
|
+ var size = Graphics.MeasureString(line, Font);
|
|
|
|
+
|
|
|
|
+ switch (format.Alignment)
|
|
|
|
+ {
|
|
|
|
+ case TextAlignment.Left:
|
|
|
|
+ break;
|
|
|
|
+ case TextAlignment.Center:
|
|
|
|
+ DrawData.Translate(new PointF(-(float)size.Width / 2, 0));
|
|
|
|
+ break;
|
|
|
|
+ case TextAlignment.Right:
|
|
|
|
+ DrawData.Translate(new PointF(-(float)size.Width, 0));
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Graphics.DrawString(line, Font, new SolidBrush(color), new PointF(0, 0), StringFormat.GenericTypographic);
|
|
|
|
+ DrawData.PopTransform();
|
|
|
|
+
|
|
|
|
+ ++pos;
|
|
|
|
+ }
|
|
|
|
|
|
DrawData.PopTransform();
|
|
DrawData.PopTransform();
|
|
}
|
|
}
|