From f12e8deeab70f4dc1394227a54b0c20adeaa0eff Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 31 Oct 2019 17:41:29 -0500 Subject: [PATCH] add 'Freeze' prop to BrushExtension --- .../MarkupExtensions/BrushExtension.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/client/spark/view/Extensions/MarkupExtensions/BrushExtension.cs b/src/client/spark/view/Extensions/MarkupExtensions/BrushExtension.cs index 2ba3d743d..448526a6c 100644 --- a/src/client/spark/view/Extensions/MarkupExtensions/BrushExtension.cs +++ b/src/client/spark/view/Extensions/MarkupExtensions/BrushExtension.cs @@ -2,28 +2,28 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; using System.Windows.Markup; using System.Windows.Media; namespace mbts.ui { [MarkupExtensionReturnType(typeof(Brush))] - public class BrushExtension : MarkupExtension { + class BrushExtension : MarkupExtension { public BrushExtension() : this(Colors.Black) { } public BrushExtension(Color Color) : this(Color, 1.0) { } public BrushExtension(Color Color, double Opacity) { this.Color = Color; this.Opacity = Opacity; } [TypeConverter(typeof(ColorTypeConverter))] [ConstructorArgument("Color")] - public Color Color { get; set; } + public Color Color { get; set; } + [ConstructorArgument("Opacity")] - public double Opacity { get; set; } - public override object ProvideValue(IServiceProvider serviceProvider) { - return new SolidColorBrush(Color) { Opacity = Opacity }; - } - } + public double Opacity { get; set; } + + public bool Freeze { get; set; } + + public override object ProvideValue(IServiceProvider serviceProvider) => + Freeze ? FrozenBrushCache.get_brush(Color, Opacity) : new SolidColorBrush(Color) { Opacity = Opacity }; + } public class ColorTypeConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); }