Skip to content

Instantly share code, notes, and snippets.

@pparadis
Last active December 23, 2015 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pparadis/59eb29ea38e3cebb623d to your computer and use it in GitHub Desktop.
Save pparadis/59eb29ea38e3cebb623d to your computer and use it in GitHub Desktop.
Known Colors
var names = (KnownColor[])Enum.GetValues(typeof(KnownColor));
var namesList = names.ToList();
//Retirer ceux que vous considérez indésirables
namesList.Remove(KnownColor.White);
namesList.Remove(KnownColor.HighlightText);
namesList.Remove(KnownColor.ControlLight);
namesList.Remove(KnownColor.ControlLightLight);
names = namesList
    .OrderByDescending(p => Guid.NewGuid())
    .ToArray();
var randomColorName = names[index];
var randomColor = Color.FromKnownColor(randomColorName);
return "#" + randomColor.R.ToString("X2") + randomColor.G.ToString("X2") + randomColor.B.ToString("X2");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment