diff options
| author | lempamo <[email protected]> | 2017-09-05 20:05:28 -0400 |
|---|---|---|
| committer | lempamo <[email protected]> | 2017-09-05 20:05:28 -0400 |
| commit | 859e2483cbfd124d3dde85f1654df9aaa17ca605 (patch) | |
| tree | a5a3864b5e43d9b1f70e83bd90218b5cb71745b2 /Histacom2.Engine/UI/ClassicButton.cs | |
| parent | 1a970e69dada088c5f5ea82dd5683da9ae306ebe (diff) | |
| download | histacom2-859e2483cbfd124d3dde85f1654df9aaa17ca605.tar.gz histacom2-859e2483cbfd124d3dde85f1654df9aaa17ca605.tar.bz2 histacom2-859e2483cbfd124d3dde85f1654df9aaa17ca605.zip | |
buttons and window colors
Diffstat (limited to 'Histacom2.Engine/UI/ClassicButton.cs')
| -rw-r--r-- | Histacom2.Engine/UI/ClassicButton.cs | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/Histacom2.Engine/UI/ClassicButton.cs b/Histacom2.Engine/UI/ClassicButton.cs index e82a742..717a6ce 100644 --- a/Histacom2.Engine/UI/ClassicButton.cs +++ b/Histacom2.Engine/UI/ClassicButton.cs @@ -10,8 +10,9 @@ namespace Histacom2.Engine.UI { public class ClassicButton : Control { - private Color _lightBack = Color.White; - private Color _darkBack = Color.Gray; + private Color _lightBack; + private Color _darkBack; + private Font _font; private bool _pressing = false; @@ -25,17 +26,31 @@ namespace Histacom2.Engine.UI if (SaveSystem.currentTheme != null) ForeColor = SaveSystem.currentTheme.threeDObjectsTextColor; else ForeColor = Color.Black; + if (SaveSystem.currentTheme != null) _font = SaveSystem.currentTheme.buttonFont; + else _font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular); + MouseDown += (s, e) => { _pressing = true; Invalidate(); }; MouseUp += (s, e) => { _pressing = false; Invalidate(); }; + Invalidate(); } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); + + if (SaveSystem.currentTheme != null) BackColor = SaveSystem.currentTheme.threeDObjectsColor; + else BackColor = Color.Silver; + + _lightBack = Paintbrush.GetLightFromColor(BackColor); + _darkBack = Paintbrush.GetDarkFromColor(BackColor); + var g = e.Graphics; g.Clear(BackColor); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; + StringFormat sf = new StringFormat(); + sf.Alignment = StringAlignment.Center; + sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show; if (_pressing) { @@ -44,7 +59,7 @@ namespace Histacom2.Engine.UI g.FillRectangle(new SolidBrush(_darkBack), new Rectangle(1, 1, Width - 2, Height - 2)); g.FillRectangle(new SolidBrush(BackColor), new Rectangle(2, 2, Width - 3, Height - 3)); - g.DrawString(Text, Font, new SolidBrush(ForeColor), (Width / 2) - (g.MeasureString(Text, Font).Width / 2) + 1, (Height / 2) - (g.MeasureString(Text, Font).Height / 2) + 1); + g.DrawString(Text, _font, new SolidBrush(ForeColor), ((Width / 2) + 1) + Padding.Left, (Height / 2) - (g.MeasureString(Text, Font).Height / 2) + 3, sf); } else { @@ -53,7 +68,7 @@ namespace Histacom2.Engine.UI g.FillRectangle(new SolidBrush(_darkBack), new Rectangle(1, 1, Width - 2, Height - 2)); g.FillRectangle(new SolidBrush(BackColor), new Rectangle(1, 1, Width - 3, Height - 3)); - g.DrawString(Text, Font, new SolidBrush(ForeColor), (Width / 2) - (g.MeasureString(Text, Font).Width / 2), (Height / 2) - (g.MeasureString(Text, Font).Height / 2)); + g.DrawString(Text, _font, new SolidBrush(ForeColor), (Width / 2) + Padding.Left, (Height / 2) - (g.MeasureString(Text, Font).Height / 2) + 2, sf); } } |
