Skip to content

Instantly share code, notes, and snippets.

@pparadis

pparadis/known-color.cs

Last active Dec 23, 2015
Embed
What would you like to do?
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