1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
/// <summary>
/// Gets the color by percent.
/// </summary>
/// <param name="percent">The value 0 - 100%</param>
/// <returns>System.Drawing.Color dependent on the value</returns>
private Color GetColorByValue(double percent)
{
if (percent > 100.0)
throw new ArgumentException("percent cannot be larger than 100.0");
double red;
double green;
if (percent > 50.0)
{
green = (100.0 - percent) * 5.1;
red = 255.0;
}
else
{
green = 255.0;
red = percent * 5.1;
}
return Color.FromArgb((int)red, (int)green, 0);
}
|