Use darker button color for depth color instead of black

This commit is contained in:
Jaex 2017-12-17 08:56:58 +03:00
parent 8464358215
commit 4f1b2f16c0
3 changed files with 20 additions and 6 deletions

View file

@ -374,5 +374,15 @@ public static bool ColorsAreClose(Color color1, Color color2, int threshold)
{
return ColorDifference(color1, color2) <= threshold;
}
public static Color LighterColor(Color color, float amount)
{
return Lerp(color, Color.White, amount);
}
public static Color DarkerColor(Color color, float amount)
{
return Lerp(color, Color.Black, amount);
}
}
}

View file

@ -37,8 +37,8 @@ internal class ButtonObject : DrawableObject
{
public string Text { get; set; }
public Color ButtonColor { get; set; }
private int depth = 2;
public int ButtonDepth { get; set; } = 3;
public Color ButtonDepthColor => ColorHelpers.DarkerColor(ButtonColor, 0.5f);
public override void OnDraw(Graphics g)
{
@ -46,7 +46,7 @@ public override void OnDraw(Graphics g)
if (IsCursorHover)
{
rect = rect.LocationOffset(0, depth);
rect = rect.LocationOffset(0, ButtonDepth);
}
g.SmoothingMode = SmoothingMode.HighQuality;
@ -57,7 +57,10 @@ public override void OnDraw(Graphics g)
if (!IsCursorHover)
{
g.DrawRoundedRectangle(Brushes.Black, rect.LocationOffset(0, depth), 5);
using (SolidBrush buttonDepthBrush = new SolidBrush(ButtonDepthColor))
{
g.DrawRoundedRectangle(buttonDepthBrush, rect.LocationOffset(0, ButtonDepth), 5);
}
}
g.DrawRoundedRectangle(buttonBrush, rect, 5);
@ -69,8 +72,9 @@ public override void OnDraw(Graphics g)
using (Font font = new Font("Arial", 18))
using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
using (SolidBrush textDepthBrush = new SolidBrush(ButtonDepthColor))
{
g.DrawString(Text, font, Brushes.Black, rect.LocationOffset(0, 4), sf);
g.DrawString(Text, font, textDepthBrush, rect.LocationOffset(0, 4), sf);
g.DrawString(Text, font, Brushes.White, rect.LocationOffset(0, 2), sf);
}
}

View file

@ -105,7 +105,7 @@ public override void Dispose()
{
base.Dispose();
if (confirmButton.IsCursorHover || cancelButton.IsCursorHover)
if ((confirmButton != null && confirmButton.IsCursorHover) || (cancelButton != null && cancelButton.IsCursorHover))
{
Manager.Form.SetDefaultCursor();
}