From 2adb8859edb95921e8f6d3cbb41fdc349825d6f8 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 4 Jul 2017 17:57:29 -0400 Subject: abandon system.drawing for anything other than text --- ShiftOS.Frontend/GUI/TextControl.cs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'ShiftOS.Frontend/GUI/TextControl.cs') diff --git a/ShiftOS.Frontend/GUI/TextControl.cs b/ShiftOS.Frontend/GUI/TextControl.cs index 9bc70e8..f1bbef1 100644 --- a/ShiftOS.Frontend/GUI/TextControl.cs +++ b/ShiftOS.Frontend/GUI/TextControl.cs @@ -4,6 +4,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; +using ShiftOS.Frontend.GraphicsSubsystem; namespace ShiftOS.Frontend.GUI { @@ -53,19 +54,19 @@ namespace ShiftOS.Frontend.GUI set { _textAlign = value; } } - protected override void OnPaint(Graphics gfx) + protected override void OnPaint(GraphicsContext gfx) { var sMeasure = gfx.MeasureString(_text, _font, Width); PointF loc = new PointF(2, 2); - float centerH = (Width - sMeasure.Width) / 2; - float centerV = (Height - sMeasure.Height) / 2; + float centerH = (Width - sMeasure.X) / 2; + float centerV = (Height - sMeasure.Y) / 2; switch (_textAlign) { case TextAlign.TopCenter: loc.X = centerH; break; case TextAlign.TopRight: - loc.X = Width - sMeasure.Width; + loc.X = Width - sMeasure.X; break; case TextAlign.MiddleLeft: loc.Y = centerV; @@ -76,23 +77,23 @@ namespace ShiftOS.Frontend.GUI break; case TextAlign.MiddleRight: loc.Y = centerV; - loc.X = (Width - sMeasure.Width); + loc.X = (Width - sMeasure.Y); break; case TextAlign.BottomLeft: - loc.Y = (Height - sMeasure.Height); + loc.Y = (Height - sMeasure.Y); break; case TextAlign.BottomCenter: - loc.Y = (Height - sMeasure.Height); + loc.Y = (Height - sMeasure.Y); loc.X = centerH; break; case TextAlign.BottomRight: - loc.Y = (Height - sMeasure.Height); - loc.X = (Width - sMeasure.Width); + loc.Y = (Height - sMeasure.Y); + loc.X = (Width - sMeasure.X); break; } - gfx.DrawString(_text, _font, new SolidBrush(Engine.SkinEngine.LoadedSkin.ControlTextColor), new RectangleF(loc.X, loc.Y, sMeasure.Width, sMeasure.Height)); + gfx.DrawString(_text, 0, 0, Engine.SkinEngine.LoadedSkin.ControlTextColor.ToMonoColor(), _font, this.Width); } } -- cgit v1.2.3