// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2014 OxyPlot contributors
//
//
// This is a Avalonia wrapper of OxyPlot.RectangleAnnotation
//
// --------------------------------------------------------------------------------------------------------------------
using Avalonia;
namespace OxyPlot.Avalonia
{
///
/// This is a Avalonia wrapper of OxyPlot.RectangleAnnotation
///
public class RectangleAnnotation : ShapeAnnotation
{
///
/// Identifies the dependency property.
///
public static readonly StyledProperty MaximumXProperty = AvaloniaProperty.Register(nameof(MaximumX), double.MaxValue);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty MaximumYProperty = AvaloniaProperty.Register(nameof(MaximumY), double.MaxValue);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty MinimumXProperty = AvaloniaProperty.Register(nameof(MinimumX), double.MinValue);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty MinimumYProperty = AvaloniaProperty.Register(nameof(MinimumY), double.MinValue);
///
/// Initializes static members of the class.
///
static RectangleAnnotation()
{
TextColorProperty.OverrideDefaultValue(MoreColors.Automatic);
TextColorProperty.Changed.AddClassHandler(AppearanceChanged);
MaximumXProperty.Changed.AddClassHandler(DataChanged);
MaximumYProperty.Changed.AddClassHandler(DataChanged);
MinimumXProperty.Changed.AddClassHandler(DataChanged);
MinimumYProperty.Changed.AddClassHandler(DataChanged);
}
///
/// Initializes a new instance of the class.
///
public RectangleAnnotation()
{
InternalAnnotation = new Annotations.RectangleAnnotation();
}
///
/// Gets or sets the Maximum X.
///
public double MaximumX
{
get
{
return GetValue(MaximumXProperty);
}
set
{
SetValue(MaximumXProperty, value);
}
}
///
/// Gets or sets the Maximum Y.
///
public double MaximumY
{
get
{
return GetValue(MaximumYProperty);
}
set
{
SetValue(MaximumYProperty, value);
}
}
///
/// Gets or sets the Minimum X.
///
public double MinimumX
{
get
{
return GetValue(MinimumXProperty);
}
set
{
SetValue(MinimumXProperty, value);
}
}
///
/// Gets or sets the Minimum Y.
///
public double MinimumY
{
get
{
return GetValue(MinimumYProperty);
}
set
{
SetValue(MinimumYProperty, value);
}
}
///
/// Creates the internal annotation object.
///
/// The annotation.
public override Annotations.Annotation CreateModel()
{
SynchronizeProperties();
return InternalAnnotation;
}
///
/// Synchronizes the properties.
///
public override void SynchronizeProperties()
{
base.SynchronizeProperties();
var a = (Annotations.RectangleAnnotation)InternalAnnotation;
a.MinimumX = MinimumX;
a.MaximumX = MaximumX;
a.MinimumY = MinimumY;
a.MaximumY = MaximumY;
}
}
}