added 'argb_color' uint extension (like rgb_color, but includes alpha byte)

This commit is contained in:
John Colvin committed 2019-08-14 00:24:35 -05:00
1 parent 915e0d38c3
commit e68b626ec4
1 file changed
+10
@@ -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;