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/Button.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/Button.cs')
| -rw-r--r-- | ShiftOS.Frontend/GUI/Button.cs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/ShiftOS.Frontend/GUI/Button.cs b/ShiftOS.Frontend/GUI/Button.cs new file mode 100644 index 0000000..c2e41a3 --- /dev/null +++ b/ShiftOS.Frontend/GUI/Button.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Engine; + +namespace ShiftOS.Frontend.GUI +{ + public class Button : TextControl + { + public Button() + { + TextAlign = TextAlign.MiddleCenter; + Text = "Click me!"; + } + + protected override void OnLayout() + { + if(AutoSize == true) + { + int borderwidth = SkinEngine.LoadedSkin.ButtonBorderWidth * 2; + + using (var gfx = Graphics.FromImage(new Bitmap(1, 1))) + { + var measure = gfx.MeasureString(this.Text, this.Font); + Width = borderwidth + (int)measure.Width + 4; + Height = borderwidth + (int)measure.Height + 8; + } + } + base.OnLayout(); + } + + public override void Paint(Graphics gfx) + { + Color bgCol = SkinEngine.LoadedSkin.ButtonBackgroundColor; + Color fgCol = SkinEngine.LoadedSkin.ControlTextColor; + if (ContainsMouse) + bgCol = SkinEngine.LoadedSkin.ButtonHoverColor; + if (MouseLeftDown) + bgCol = SkinEngine.LoadedSkin.ButtonPressedColor; + + gfx.Clear(bgCol); + gfx.DrawRectangle(new Pen(new SolidBrush(fgCol), SkinEngine.LoadedSkin.ButtonBorderWidth), new Rectangle(0, 0, Width, Height)); + base.Paint(gfx); + + } + } +} |
