GdiPlusRenderer: Implement string rotation.

This commit is contained in:
J.D. Purcell 2019-10-26 16:31:21 -04:00
parent e21e861e99
commit d2cf95e18f
1 changed files with 15 additions and 8 deletions

View File

@ -1,6 +1,6 @@
using System; using System;
using System.Drawing; using System.Drawing;
namespace BizHawk.Client.EmuHawk.CustomControls namespace BizHawk.Client.EmuHawk.CustomControls
{ {
public class GdiPlusRenderer : IControlRenderer public class GdiPlusRenderer : IControlRenderer
@ -12,6 +12,7 @@ namespace BizHawk.Client.EmuHawk.CustomControls
private readonly SolidBrush _currentStringBrush = new SolidBrush(Color.Black); private readonly SolidBrush _currentStringBrush = new SolidBrush(Color.Black);
private readonly Font _defaultFont = new Font("Arial", 8, FontStyle.Bold); private readonly Font _defaultFont = new Font("Arial", 8, FontStyle.Bold);
private Font _currentFont; private Font _currentFont;
private bool _rotateString;
public GdiPlusRenderer() public GdiPlusRenderer()
{ {
@ -50,8 +51,18 @@ namespace BizHawk.Client.EmuHawk.CustomControls
} }
public void DrawString(string str, Point point) public void DrawString(string str, Point point)
{ {
_graphics.DrawString(str, _currentFont, _currentStringBrush, point); if (_rotateString)
{
_graphics.TranslateTransform(point.X, point.Y);
_graphics.RotateTransform(90);
_graphics.DrawString(str, _currentFont, _currentStringBrush, Point.Empty);
_graphics.ResetTransform();
}
else
{
_graphics.DrawString(str, _currentFont, _currentStringBrush, point);
}
} }
public void FillRectangle(int x, int y, int w, int h) public void FillRectangle(int x, int y, int w, int h)
@ -80,13 +91,9 @@ namespace BizHawk.Client.EmuHawk.CustomControls
public void PrepDrawString(Font font, Color color, bool rotate = false) public void PrepDrawString(Font font, Color color, bool rotate = false)
{ {
if (rotate)
{
// TODO
}
_currentFont = font; _currentFont = font;
_currentStringBrush.Color = color; _currentStringBrush.Color = color;
_rotateString = rotate;
} }
public void SetBrush(Color color) public void SetBrush(Color color)