Added SpreadMethod for gradients
This commit is contained in:
Родитель
8ce93bcb90
Коммит
140953b4e8
|
@ -1,17 +1,26 @@
|
|||
using System.Collections.Generic;
|
||||
using XGraphics.Brushes;
|
||||
using System.Windows;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace XGraphics.WPF.Brushes
|
||||
{
|
||||
public class GradientBrush : Brush, IGradientBrush
|
||||
{
|
||||
public static readonly DependencyProperty SpreadMethodProperty = PropertyUtils.Create(nameof(SpreadMethod), typeof(GradientSpreadMethod), typeof(GradientBrush), GradientSpreadMethod.Pad);
|
||||
|
||||
public GradientBrush()
|
||||
{
|
||||
GradientStops = new GraphicsObjectCollection<GradientStop>();
|
||||
GradientStops.Changed += OnSubobjectChanged;
|
||||
}
|
||||
|
||||
public GradientSpreadMethod SpreadMethod
|
||||
{
|
||||
get => (GradientSpreadMethod)GetValue(SpreadMethodProperty);
|
||||
set => SetValue(SpreadMethodProperty, value);
|
||||
}
|
||||
|
||||
IEnumerable<IGradientStop> IGradientBrush.GradientStops => GradientStops;
|
||||
public GraphicsObjectCollection<GradientStop> GradientStops
|
||||
{
|
||||
|
|
|
@ -6,12 +6,20 @@ namespace XGraphics.XamarinForms.Brushes
|
|||
{
|
||||
public class GradientBrush : Brush, IGradientBrush
|
||||
{
|
||||
public static readonly BindableProperty SpreadMethodProperty = PropertyUtils.Create(nameof(SpreadMethod), typeof(GradientSpreadMethod), typeof(GradientBrush), GradientSpreadMethod.Pad);
|
||||
|
||||
public GradientBrush()
|
||||
{
|
||||
GradientStops = new GraphicsObjectCollection<GradientStop>();
|
||||
GradientStops.Changed += OnSubobjectChanged;
|
||||
}
|
||||
|
||||
public GradientSpreadMethod SpreadMethod
|
||||
{
|
||||
get => (GradientSpreadMethod)GetValue(SpreadMethodProperty);
|
||||
set => SetValue(SpreadMethodProperty, value);
|
||||
}
|
||||
|
||||
IEnumerable<IGradientStop> IGradientBrush.GradientStops => GradientStops;
|
||||
public GraphicsObjectCollection<GradientStop> GradientStops
|
||||
{
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
namespace XGraphics.Brushes
|
||||
{
|
||||
public enum GradientSpreadMethod
|
||||
{
|
||||
Pad = 0,
|
||||
Reflect = 1,
|
||||
Repeat = 2
|
||||
}
|
||||
}
|
|
@ -5,6 +5,9 @@ namespace XGraphics.Brushes
|
|||
[GraphicsModelObject]
|
||||
public interface IGradientBrush : IBrush
|
||||
{
|
||||
[ModelDefaultValue(GradientSpreadMethod.Pad)]
|
||||
GradientSpreadMethod SpreadMethod { get; }
|
||||
|
||||
IEnumerable<IGradientStop> GradientStops { get; }
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче