From 6f3a5cba2ea08ea6f442e2336b74f32f4bbc0604 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 2 Jul 2017 21:48:10 -0400 Subject: A day's worth of hell... which is turning into heaven. --- ShiftOS.Frontend/GUI/TextControl.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'ShiftOS.Frontend/GUI/TextControl.cs') diff --git a/ShiftOS.Frontend/GUI/TextControl.cs b/ShiftOS.Frontend/GUI/TextControl.cs index c8eb56b..79da213 100644 --- a/ShiftOS.Frontend/GUI/TextControl.cs +++ b/ShiftOS.Frontend/GUI/TextControl.cs @@ -13,6 +13,22 @@ namespace ShiftOS.Frontend.GUI private TextAlign _textAlign = TextAlign.TopLeft; private Font _font = new Font("Tahoma", 9f); + protected override void OnLayout() + { + if (AutoSize) + { + using (var bmp = new Bitmap(1, 1)) + { + using(var gfx = Graphics.FromImage(bmp)) + { + var measure = gfx.MeasureString(_text, _font); + Width = (int)measure.Width; + Height = (int)measure.Height; + } + } + } + } + public string Text { get { return _text; } -- cgit v1.2.3