// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2014 OxyPlot contributors
//
//
// This is a Avalonia wrapper of .
//
// --------------------------------------------------------------------------------------------------------------------
using Avalonia;
namespace OxyPlot.Avalonia
{
using global::Avalonia.Layout;
///
/// This is a Avalonia wrapper of .
///
public class PointAnnotation : ShapeAnnotation
{
///
/// Identifies the dependency property.
///
public static readonly StyledProperty XProperty = AvaloniaProperty.Register(nameof(X), 0.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty YProperty = AvaloniaProperty.Register(nameof(Y), 0.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty SizeProperty = AvaloniaProperty.Register(nameof(Size), 4d);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty TextMarginProperty = AvaloniaProperty.Register(nameof(TextMargin), 2d);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty ShapeProperty = AvaloniaProperty.Register(nameof(Shape), MarkerType.Circle);
///
/// Initializes static members of the class.
///
static PointAnnotation()
{
TextColorProperty.OverrideDefaultValue(MoreColors.Automatic);
TextColorProperty.Changed.AddClassHandler(AppearanceChanged);
TextVerticalAlignmentProperty.OverrideDefaultValue(VerticalAlignment.Top);
TextVerticalAlignmentProperty.Changed.AddClassHandler(AppearanceChanged);
XProperty.Changed.AddClassHandler(DataChanged);
YProperty.Changed.AddClassHandler(DataChanged);
SizeProperty.Changed.AddClassHandler(AppearanceChanged);
TextMarginProperty.Changed.AddClassHandler(AppearanceChanged);
ShapeProperty.Changed.AddClassHandler(AppearanceChanged);
}
///
/// Initializes a new instance of the class.
///
public PointAnnotation()
{
InternalAnnotation = new Annotations.PointAnnotation();
}
///
/// Gets or sets the size.
///
public double Size
{
get
{
return GetValue(SizeProperty);
}
set
{
SetValue(SizeProperty, value);
}
}
///
/// Gets or sets the text margin.
///
public double TextMargin
{
get
{
return GetValue(TextMarginProperty);
}
set
{
SetValue(TextMarginProperty, value);
}
}
///
/// Gets or sets the shape.
///
public MarkerType Shape
{
get
{
return GetValue(ShapeProperty);
}
set
{
SetValue(ShapeProperty, value);
}
}
///
/// Gets or sets the X coordinate.
///
public double X
{
get
{
return GetValue(XProperty);
}
set
{
SetValue(XProperty, value);
}
}
///
/// Gets or sets the Y coordinate.
///
public double Y
{
get
{
return GetValue(YProperty);
}
set
{
SetValue(YProperty, 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.PointAnnotation)InternalAnnotation;
a.X = X;
a.Y = Y;
a.Size = Size;
a.TextMargin = TextMargin;
a.Shape = Shape;
}
}
}