Teoretycznie możesz zedytować taką kontrolkę / okno dodając własne elementy, ale praktycznie prościej będzie napisać takie coś od nowa.
Nie znam się na grafice, wszystko, co zastosowałem to zwykła interpolacja liniowa.
public static Bitmap CreateColorMap(int width, int height, Color[] gradients, Color bottom)
{
Bitmap map = new Bitmap(width, height);
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
Color fullColor = InterpolateGradient(gradients, x, width / (gradients.Length - 1));
map.SetPixel(x, y, InterpolateColor(fullColor, bottom, y, height));
}
}
return map;
}
public static int Interpolate(int from, int to, int position, int max)
{
return (to - from) * position / max + from;
}
public static Color InterpolateColor(Color from, Color to, int position, int max)
{
return Color.FromArgb(Interpolate(from.R, to.R, position, max),
Interpolate(from.G, to.G, position, max),
Interpolate(from.B, to.B, position, max));
}
public static Color InterpolateGradient(Color[] gradients, int position, int gradientWidth)
{
int from = position / gradientWidth;
int to = ((from + 1) == gradients.Length) ? from : from + 1;
return InterpolateColor(gradients[from], gradients[to], position - (from * gradientWidth), gradientWidth);
}
I korzystasz z tego tak:
Color[] gradients = new Color[]
{
Color.FromArgb(255, 0, 0),
Color.FromArgb(255, 255, 0),
Color.FromArgb(0, 255, 0),
Color.FromArgb(0, 255, 255),
Color.FromArgb(0, 0, 255),
Color.FromArgb(255, 0, 255),
Color.FromArgb(255, 0, 0)
};
Bitmap b = CreateColorMap(500, 200, gradients, Color.FromArgb(127, 127, 127));
Aha - uprzedzając wypowiedzi, jest to kod niezoptymalizowany, poglądowy. Do jednego wygenerowania może być okej, ale i tak użyj wskazówek ludzi mądrzejszych od nas ;): https://codeguru.pl/forum-posts-17845-2.aspx