#region label按下颜色变深
Color m_cacheColor = Color.Empty;
private void label4_MouseLeave(object sender, EventArgs e)
{
if (m_cacheColor != Color.Empty)
{
label4.BackColor = m_cacheColor;
m_cacheColor = Color.Empty;
}
}
private void label4_MouseEnter(object sender, EventArgs e)
{
if (label4.BackColor != Color.Empty && label4.BackColor != null)
{
m_cacheColor = label4.BackColor;
label4.BackColor = ChangeColor(label4.BackColor, -0.2f);
}
}
Color ChangeColor(Color color, float value)
{
float red = color.R;
float green = color.G;
float blue = color.B;
if (value < 0)
{
value = 1 + value;
red *= value;
green *= value;
blue *= value;
}
else
{
red = (255 - red) * value + red;
green = (255 - green) * value + green;
blue = (255 - blue) * value + blue;
}
if (red < 0) red = 0;
if (red > 255) red = 255;
if (green < 0) green = 0;
if (green > 255) green = 255;
if (blue < 0) blue = 0;
if (blue > 255) blue = 255;
return Color.FromArgb(color.A, (int)red, (int)green, (int)blue);
}
#endregion