add 'Freeze' prop to BrushExtension
This commit is contained in:
1 parent
06935d525a
commit
4bb159311f
1 file changed
+8
-10
@@ -2,17 +2,12 @@
|
||||
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
|
||||
{
|
||||
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; }
|
||||
@@ -20,11 +15,14 @@ namespace mbts.ui
|
||||
[TypeConverter(typeof(ColorTypeConverter))]
|
||||
[ConstructorArgument("Color")]
|
||||
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 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
|
||||
|
||||
Reference in new issue
Block a user