From d2cf95e18fafb8b47788183ca47cd2e576eca36d Mon Sep 17 00:00:00 2001 From: "J.D. Purcell" Date: Sat, 26 Oct 2019 16:31:21 -0400 Subject: [PATCH] GdiPlusRenderer: Implement string rotation. --- .../ControlRenderer/GdiPlusRenderer.cs | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/GdiPlusRenderer.cs b/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/GdiPlusRenderer.cs index ef23e7b98a..57a826d51e 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/GdiPlusRenderer.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/GdiPlusRenderer.cs @@ -1,6 +1,6 @@ using System; using System.Drawing; - + namespace BizHawk.Client.EmuHawk.CustomControls { public class GdiPlusRenderer : IControlRenderer @@ -12,6 +12,7 @@ namespace BizHawk.Client.EmuHawk.CustomControls private readonly SolidBrush _currentStringBrush = new SolidBrush(Color.Black); private readonly Font _defaultFont = new Font("Arial", 8, FontStyle.Bold); private Font _currentFont; + private bool _rotateString; public GdiPlusRenderer() { @@ -50,8 +51,18 @@ namespace BizHawk.Client.EmuHawk.CustomControls } 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) @@ -80,13 +91,9 @@ namespace BizHawk.Client.EmuHawk.CustomControls public void PrepDrawString(Font font, Color color, bool rotate = false) { - if (rotate) - { - // TODO - } - _currentFont = font; _currentStringBrush.Color = color; + _rotateString = rotate; } public void SetBrush(Color color)