public Color GetColorAtValue(double percent) { if (Value.Text == "Random values") { return(Color.FromArgb(MapUtils.GetRandomValue(256), MapUtils.GetRandomValue(256), MapUtils.GetRandomValue(256))); } // searching for the corresponding value int i; for (i = 0; i < Value.Count; i++) { if (Value.Keys[i] > percent) { ++i; break; } } // calculate color if (i > 0) { if (i < 2 || Value.Style == ColorRampStyle.Discrete) { return(Value.Values[i - 1]); } else { return(GetInterpolatedColor(Value.Values[i - 2], Value.Values[i - 1], percent / 100)); } } else { return(Color.Empty); } }