diff options
Diffstat (limited to 'ShiftOS.Frontend/GUI/TextControl.cs')
| -rw-r--r-- | ShiftOS.Frontend/GUI/TextControl.cs | 16 |
1 files changed, 16 insertions, 0 deletions
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; } |
