Perfil de MambyDevNationBlogListas Herramientas Ayuda

DevNation

Welcome to the Developer Nation !
Todavía no se han agregado elementos de lista.

Mamby Camara

Ocupación
Ubicación
Intereses
05 julio

WPF HighContrast (High contrast support with Windows Presentation Foundation)

 

I hate the literature, but I know that’s necessary for a blog.

Lets go to the practice !!!

Many applications have enhanced UI (User Interface) but doesn’t support all high contrast color schemes.

Two examples:

Example 1. Microsoft Office 2007 applications in High Contrast #2 color scheme:

office2k7 in High Contrast  click image to enlarge

Example 2. Windows live applications in all high contrast color schemes:

Windows Live Apps in High Contrast

 

Demo:

You can create similar UIs with WPF (Windows Presentation Foundation) while fully supporting high contrast color schemes. The approach that I used isn't, maybe, the best practical one but can be used as starting point to solve this problem.

The sample application support all system’s default high contrast color schemes (black, white, #1 and #2) and can be easily extended.

WPF Sample App in High Contrast WPF Sample App in Normal Contrast

Code: (Main function)

public static bool IsHighContrast()
{
    bool isHighContrast = false;

    if (SystemColors.ControlColor.ToString() == "#FF000000")
    {
        if (SystemColors.ControlTextColor.ToString() == "#FFFFFFFF"
            || SystemColors.ControlTextColor.ToString() == "#FF00FF00")  // High Contrast #1, #2 and Black.
        {
            isHighContrast = true;
        }
        else
        {
            isHighContrast = false;
        }
    }
    else if (SystemColors.ControlColor.ToString() == "#FFFFFFFF")
    {
        if (SystemColors.ControlTextColor.ToString() == "#FF000000") // High Contrast White.
        {
            isHighContrast = true;
        }
        else
        {
            isHighContrast = false;
        }
    }

    return isHighContrast;
}

Download source code (zip): WPF HighContrast.zip