refactor: Add 'Freeze' prop to BTSBrushExtension

This commit is contained in:
John Colvin committed 2022-08-22 16:08:40 -04:00
1 parent 9bb7025752
commit bfb73ffc5a
2 files changed
+10 -3

No files matched your search

@@ -10,8 +10,13 @@ namespace mbts.ui {
}
public static System.Windows.Media.SolidColorBrush to_brush(
this BTSColor color, double opacity) =>
new(color) { Opacity = opacity };
this BTSColor color, double opacity, bool freeze = false) {
var b = new System.Windows.Media.SolidColorBrush(color) { Opacity = opacity };
if (freeze) {
b.Freeze();
}
return b;
}
public static System.Windows.Media.SolidColorBrush to_brush(
this BTSColor color, bool freeze) {
@@ -16,8 +16,10 @@ namespace mbts.ui {
public double Opacity { get; set; } = 1;
public bool Freeze { get; set; }
public override object? ProvideValue(IServiceProvider service_provider) =>
Name is null ? throw new InvalidOperationException("Name is null") :
BTSColorExtension.get_color(Name).to_brush(Opacity);
BTSColorExtension.get_color(Name).to_brush(Opacity, Freeze);
}
}