The user of the ASP.NET web app I\'m building can select colors for use on some of the elements (e.g. buttons/titles) to facilitate some degree of personalisation.
var hexcolor = "#FA3CD0";
var color = System.Drawing.ColorTranslator.FromHtml(hexcolor);
var brightness = color.GetBrightness();
if (brightness > .5)
{
// color is light
}
else
{
// color is dark
}