aboutsummaryrefslogtreecommitdiff
path: root/Histacom2.Engine/UI/ClassicButton.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Histacom2.Engine/UI/ClassicButton.cs')
-rw-r--r--Histacom2.Engine/UI/ClassicButton.cs23
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);
}
}