diff options
| author | Michael <[email protected]> | 2017-07-02 21:48:10 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-07-02 21:48:10 -0400 |
| commit | 6f3a5cba2ea08ea6f442e2336b74f32f4bbc0604 (patch) | |
| tree | 9f138619a1cf4ebe7a7ece6c6a411adbe64843d6 /ShiftOS.Frontend/GUI/TextControl.cs | |
| parent | 5d5f351138b55b27fe92690d824257b6b6e1a469 (diff) | |
| download | shiftos_thereturn-6f3a5cba2ea08ea6f442e2336b74f32f4bbc0604.tar.gz shiftos_thereturn-6f3a5cba2ea08ea6f442e2336b74f32f4bbc0604.tar.bz2 shiftos_thereturn-6f3a5cba2ea08ea6f442e2336b74f32f4bbc0604.zip | |
A day's worth of hell... which is turning into heaven.
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; } |
