// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2014 OxyPlot contributors
//
//
// The Avalonia wrapper for OxyPlot.TwoColorAreaSeries.
//
// --------------------------------------------------------------------------------------------------------------------
using Avalonia;
using System.Linq;
namespace OxyPlot.Avalonia
{
using global::Avalonia.Media;
///
/// The Avalonia wrapper for OxyPlot.TwoColorAreaSeries.
///
public class TwoColorAreaSeries : AreaSeries
{
///
/// Identifies the dependency property.
///
public static readonly StyledProperty Dashes2Property = AvaloniaProperty.Register(nameof(Dashes2));
///
/// Identifies the dependency property.
///
public static readonly StyledProperty FillProperty = AvaloniaProperty.Register(nameof(Fill), MoreColors.Automatic);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty Fill2Property = AvaloniaProperty.Register(nameof(Fill2), MoreColors.Automatic);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty LineStyle2Property = AvaloniaProperty.Register(nameof(LineStyle2));
///
/// Identifies the dependency property.
///
public static readonly AvaloniaProperty LimitProperty = AvaloniaProperty.Register(nameof(Limit));
///
/// Identifies the dependency property.
///
public static readonly StyledProperty MarkerFill2Property = AvaloniaProperty.Register(nameof(MarkerFill2), MoreColors.Automatic);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty MarkerStroke2Property = AvaloniaProperty.Register(nameof(MarkerStroke2), MoreColors.Automatic);
///
/// Initializes a new instance of the class.
///
public TwoColorAreaSeries()
{
InternalSeries = new OxyPlot.Series.TwoColorAreaSeries();
}
///
/// Gets or sets the dash array for the rendered line that is below the limit (overrides ).
///
public double[] Dashes2
{
get
{
return GetValue(Dashes2Property);
}
set
{
SetValue(Dashes2Property, value);
}
}
///
/// Gets or sets Fill above the limit line.
///
public Color Fill
{
get
{
return GetValue(FillProperty);
}
set
{
SetValue(FillProperty, value);
}
}
///
/// Gets or sets Fill below the limit line.
///
public Color Fill2
{
get
{
return GetValue(Fill2Property);
}
set
{
SetValue(Fill2Property, value);
}
}
///
/// Gets or sets Marker Fill which is below the limit line.
///
public Color MarkerFill2
{
get
{
return GetValue(MarkerFill2Property);
}
set
{
SetValue(MarkerFill2Property, value);
}
}
///
/// Gets or sets Marker Stroke which is below the limit line.
///
public Color MarkerStroke2
{
get
{
return GetValue(MarkerStroke2Property);
}
set
{
SetValue(MarkerStroke2Property, value);
}
}
///
/// Gets or sets the line style for the part of the line that is below the limit.
///
public LineStyle LineStyle2
{
get
{
return (LineStyle)this.GetValue(LineStyle2Property);
}
set
{
this.SetValue(LineStyle2Property, value);
}
}
///
/// Gets or sets a baseline for the series.
///
public double Limit
{
get
{
return (double)this.GetValue(LimitProperty);
}
set
{
this.SetValue(LimitProperty, value);
}
}
///
/// Synchronizes the properties.
///
/// The series.
protected override void SynchronizeProperties(OxyPlot.Series.Series series)
{
base.SynchronizeProperties(series);
var s = (OxyPlot.Series.TwoColorAreaSeries)series;
s.Fill = Fill.ToOxyColor();
s.Fill2 = Fill2.ToOxyColor();
s.MarkerFill2 = MarkerFill2.ToOxyColor();
s.MarkerStroke2 = MarkerStroke2.ToOxyColor();
s.Limit = Limit;
s.Dashes2 = Dashes2?.ToArray();
s.LineStyle2 = LineStyle2;
}
static TwoColorAreaSeries()
{
FillProperty.Changed.AddClassHandler(AppearanceChanged);
Fill2Property.Changed.AddClassHandler(AppearanceChanged);
MarkerFill2Property.Changed.AddClassHandler(AppearanceChanged);
MarkerStroke2Property.Changed.AddClassHandler(AppearanceChanged);
LimitProperty.Changed.AddClassHandler(AppearanceChanged);
Dashes2Property.Changed.AddClassHandler(AppearanceChanged);
LineStyle2Property.Changed.AddClassHandler(AppearanceChanged);
}
}
}