Tags: | Categories: Code Snippets Posted by Vitaly Zayko on 10/10/2008 8:00 PM | Comments (0)

Sometimes, when you change, for example, background color of an object dynamically, you should dynamically change foreground color as well to keep a text readable. Here is very simple way to do it:

public Color InvertColor(Color color){
    return Color.FromArgb(color.ToArgb() ^ 0xFFFFFF);
}
Comments are closed