Last active
August 29, 2015 14:27
-
-
Save kiichi/1759d3382bbcf89fcc48 to your computer and use it in GitHub Desktop.
I could not find BrushConverter class in the latest Universal Windows App namespaces. Here is simple example to convert Hex string to Color class.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //using Windows.UI | |
| class ColorUtil { | |
| // ColorUtil.FromHex("#FFAABBCC") | |
| public static Color FromHex(string hexStr) { | |
| hexStr = hexStr.Replace("#", ""); | |
| return Color.FromArgb( | |
| (byte)Convert.ToInt32(hexStr.Substring(0, 2), 16), | |
| (byte)Convert.ToInt32(hexStr.Substring(2, 2), 16), | |
| (byte)Convert.ToInt32(hexStr.Substring(4, 2), 16), | |
| (byte)Convert.ToInt32(hexStr.Substring(6, 2), 16)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment