diff options
author | Larry Ewing <lewing@xamarin.com> | 2018-05-16 20:59:09 +0300 |
---|---|---|
committer | Larry Ewing <lewing@microsoft.com> | 2018-07-16 22:05:49 +0300 |
commit | 5341f42f329b343486569cd7cc93f0f7d72be1fd (patch) | |
tree | 352849d38bd4484103a7a0dcd917f8fd4ee7d8f7 /Xamarin.PropertyEditing | |
parent | d4ac90198ebdb672af6e6d881e88e4f2a791ff24 (diff) |
Switch to #ARGB hex
Diffstat (limited to 'Xamarin.PropertyEditing')
-rw-r--r-- | Xamarin.PropertyEditing/Drawing/CommonColor.cs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Xamarin.PropertyEditing/Drawing/CommonColor.cs b/Xamarin.PropertyEditing/Drawing/CommonColor.cs index aa7aa6f..aa74e6f 100644 --- a/Xamarin.PropertyEditing/Drawing/CommonColor.cs +++ b/Xamarin.PropertyEditing/Drawing/CommonColor.cs @@ -367,7 +367,7 @@ namespace Xamarin.PropertyEditing.Drawing return $"#{R:X2}{G:X2}{B:X2}{A:X2}"; } - public static bool TryParseRgbaHex (string value, out CommonColor color) + public static bool TryParseArgbHex (string value, out CommonColor color) { if (Regex.IsMatch (value, @"^#(([A-Fa-f0-9]{2}){3}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{4}|([A-Fa-f0-9]{2}){4})$")) { var hex = value.Substring (1); @@ -384,10 +384,10 @@ namespace Xamarin.PropertyEditing.Drawing case 8: var v = Convert.ToInt32 (hex, 16); color = new CommonColor ( - r: (byte)(v >> 24), - g: (byte)(v >> 16), - b: (byte)(v >> 8), - a: (byte)v); + a: (byte)(v >> 24), + r: (byte)(v >> 16), + g: (byte)(v >> 8), + b: (byte)v); return true; } @@ -574,7 +574,7 @@ namespace Xamarin.PropertyEditing.Drawing public override string ToString () { - return $"#{R:X2}{G:X2}{B:X2}{A:X2}"; + return (A == 255) ? $"#{R:X2}{G:X2}{B:X2}" : $"#{A:X2}{R:X2}{G:X2}{B:X2}"; } } } |