diff --git a/src/client/spark/core/data/Proto/NullableColorProto.cs b/src/client/spark/core/data/Proto/NullableColorProto.cs index 3fa15eba3..2fb827d08 100644 --- a/src/client/spark/core/data/Proto/NullableColorProto.cs +++ b/src/client/spark/core/data/Proto/NullableColorProto.cs @@ -16,14 +16,8 @@ namespace bts.proto { public NullableColorProto(uint value) => _value = value; - - public Color? value { - get { - if (_value.HasValue) - return _value.Value.rgb_color(); - return null; - } - } + public Color? value => _value?.rgb_color(); + public Color? argb => _value?.argb_color(); public bool Equals(NullableColorProto other) => EqualityComparer.nullable_equals(_value, other._value); diff --git a/src/client/spark/view/Extensions/WPFExtensions.cs b/src/client/spark/view/Extensions/WPFExtensions.cs index 643e20162..190eab50e 100644 --- a/src/client/spark/view/Extensions/WPFExtensions.cs +++ b/src/client/spark/view/Extensions/WPFExtensions.cs @@ -66,11 +66,18 @@ namespace mbts.ui { } } + // TODO: replace this method with 'argb_color' + // - before that, need to verify that no settings/colors become 'invisible' as a result. public static Color rgb_color(this UInt32 color) { var bytes = BitConverter.GetBytes(color); return Color.FromRgb(bytes[2], bytes[1], bytes[0]); } + public static Color argb_color(this uint color) { + var bytes = BitConverter.GetBytes(color); + return Color.FromArgb(bytes[3], bytes[2], bytes[1], bytes[0]); + } + public static SolidColorBrush to_brush(this BTSColor color) => new SolidColorBrush(color); @@ -103,6 +110,9 @@ namespace mbts.ui { return brush; } + public static Color with(this Color color, byte alpha) => + Color.FromArgb(alpha, color.R, color.G, color.B); + public static SolidColorBrush with(this SolidColorBrush brush, double opacity) { brush.Opacity = opacity; return brush;