using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Security.Cryptography;
namespace EventCalendar
{
public class RandomColor
{
private string[] pallette =
{
"FF6666",
"339933",
"3333CC",
"FF9933",
"990099",
"FFFF00",
"FF00FF",
"66FF33",
"6699FF",
"FFCC66",
"9900FF",
"FFFF66",
"CC0033",
"669966",
"66FFFF",
"CC6600",
"996699",
"CCFF00",
"990000",
"33FF99",
"3399FF",
"CC9900",
"CC33CC",
"00FF66"};
private int _n = 0;
public string GetRepeatableColor()
{
string x = pallette[_n];
_n += 1;
if (_n > 23)
{
_n = 0;
}
return x;
}
public static string GetRandomColorName()
{
KnownColor[] colors = (KnownColor[])Enum.GetValues(typeof(KnownColor));
return Color.FromKnownColor(colors[GetRandomNumber(colors.Length)]).Name;
}
public static Color GetRandomColor()
{
KnownColor[] colors = (KnownColor[])Enum.GetValues(typeof(KnownColor));
return Color.FromKnownColor(colors[GetRandomNumber(colors.Length)]);
}
public static int GetRandomNumber(int maxValue)
{
RandomNumberGenerator rng = RNGCryptoServiceProvider.Create();
byte[] bytes = new byte[4];
rng.GetBytes(bytes);
int ranNum = BitConverter.ToInt32(bytes, 0);
return Math.Abs(ranNum % maxValue);
}
}
}