summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/Color.cs
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2017-03-01 19:45:26 +0100
committerJason Smith <jason.smith@xamarin.com>2017-03-01 10:45:26 -0800
commit837929478ed9ebb0e006ba8413cc147748619ef9 (patch)
tree29adeaa48876584e063dc4fd3cc409e23779df11 /Xamarin.Forms.Core/Color.cs
parentbadc2e03782e3e266ad03313fed1c7ab14f0cacb (diff)
downloadxamarin-forms-837929478ed9ebb0e006ba8413cc147748619ef9.tar.gz
xamarin-forms-837929478ed9ebb0e006ba8413cc147748619ef9.tar.bz2
xamarin-forms-837929478ed9ebb0e006ba8413cc147748619ef9.zip
[C] support more color format in ColorTypeConverter (#784)
* [C] support more color format in ColorTypeConverter * [C] Parse numbers in InvariantCulture * more tests
Diffstat (limited to 'Xamarin.Forms.Core/Color.cs')
-rw-r--r--Xamarin.Forms.Core/Color.cs25
1 files changed, 14 insertions, 11 deletions
diff --git a/Xamarin.Forms.Core/Color.cs b/Xamarin.Forms.Core/Color.cs
index 526489d4..2b19e58d 100644
--- a/Xamarin.Forms.Core/Color.cs
+++ b/Xamarin.Forms.Core/Color.cs
@@ -299,17 +299,20 @@ namespace Xamarin.Forms
public static Color FromHex(string hex)
{
hex = hex.Replace("#", "");
- switch (hex.Length)
- {
- case 3: //#rgb => ffrrggbb
- hex = string.Format("ff{0}{1}{2}{3}{4}{5}", hex[0], hex[0], hex[1], hex[1], hex[2], hex[2]);
- break;
- case 4: //#argb => aarrggbb
- hex = string.Format("{0}{1}{2}{3}{4}{5}{6}{7}", hex[0], hex[0], hex[1], hex[1], hex[2], hex[2], hex[3], hex[3]);
- break;
- case 6: //#rrggbb => ffrrggbb
- hex = string.Format("ff{0}", hex);
- break;
+ switch (hex.Length) {
+ case 3: //#rgb => ffrrggbb
+ hex = string.Format("ff{0}{1}{2}{3}{4}{5}", hex[0], hex[0], hex[1], hex[1], hex[2], hex[2]);
+ break;
+ case 4: //#argb => aarrggbb
+ hex = string.Format("{0}{1}{2}{3}{4}{5}{6}{7}", hex[0], hex[0], hex[1], hex[1], hex[2], hex[2], hex[3], hex[3]);
+ break;
+ case 6: //#rrggbb => ffrrggbb
+ hex = string.Format("ff{0}", hex);
+ break;
+ case 8: //#aarrggbb
+ break;
+ default: //everything else will result in unexpected results
+ return Default;
}
return FromUint(Convert.ToUInt32(hex, 16));
}