// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2014 OxyPlot contributors
//
//
// This is a Avalonia wrapper of OxyPlot.PathAnnotation
//
// --------------------------------------------------------------------------------------------------------------------
using Avalonia;
namespace OxyPlot.Avalonia
{
using global::Avalonia.Media;
using OxyPlot.Annotations;
///
/// This is a Avalonia wrapper of OxyPlot.PathAnnotation
///
public abstract class PathAnnotation : TextualAnnotation
{
///
/// Identifies the dependency property.
///
public static readonly StyledProperty ColorProperty = AvaloniaProperty.Register(nameof(Color), Colors.Blue);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty ClipByXAxisProperty = AvaloniaProperty.Register(nameof(ClipByXAxis), true);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty ClipByYAxisProperty = AvaloniaProperty.Register(nameof(ClipByYAxis), true);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty LineJoinProperty = AvaloniaProperty.Register(nameof(LineJoin), LineJoin.Miter);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty LineStyleProperty = AvaloniaProperty.Register(nameof(LineStyle), LineStyle.Dash);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty StrokeThicknessProperty = AvaloniaProperty.Register(nameof(StrokeThickness), 1.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty TextMarginProperty = AvaloniaProperty.Register(nameof(TextMargin), 12.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty TextOrientationProperty = AvaloniaProperty.Register(nameof(TextOrientation), AnnotationTextOrientation.AlongLine);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty TextLinePositionProperty = AvaloniaProperty.Register(nameof(TextLinePosition), 1.0);
///
/// Gets or sets a value indicating whether to clip the annotation line by the X axis range.
///
/// true if clipping by the X axis is enabled; otherwise, false.
public bool ClipByXAxis
{
get
{
return GetValue(ClipByXAxisProperty);
}
set
{
SetValue(ClipByXAxisProperty, value);
}
}
///
/// Gets or sets a value indicating whether to clip the annotation line by the Y axis range.
///
/// true if clipping by the Y axis is enabled; otherwise, false.
public bool ClipByYAxis
{
get
{
return GetValue(ClipByYAxisProperty);
}
set
{
SetValue(ClipByYAxisProperty, value);
}
}
///
/// Gets or sets the annotation color.
///
/// The color.
public Color Color
{
get
{
return GetValue(ColorProperty);
}
set
{
SetValue(ColorProperty, value);
}
}
///
/// Gets or sets the line join.
///
/// The line join.
public LineJoin LineJoin
{
get
{
return GetValue(LineJoinProperty);
}
set
{
SetValue(LineJoinProperty, value);
}
}
///
/// Gets or sets LineStyle.
///
public LineStyle LineStyle
{
get
{
return GetValue(LineStyleProperty);
}
set
{
SetValue(LineStyleProperty, value);
}
}
///
/// Gets or sets StrokeThickness.
///
public double StrokeThickness
{
get
{
return GetValue(StrokeThicknessProperty);
}
set
{
SetValue(StrokeThicknessProperty, value);
}
}
///
/// Gets or sets the text margin (along the line).
///
/// The text margin.
public double TextMargin
{
get
{
return GetValue(TextMarginProperty);
}
set
{
SetValue(TextMarginProperty, value);
}
}
///
/// Gets or sets the text orientation.
///
/// The text orientation.
public AnnotationTextOrientation TextOrientation
{
get
{
return GetValue(TextOrientationProperty);
}
set
{
SetValue(TextOrientationProperty, value);
}
}
///
/// Gets or sets the text position relative to the line.
///
/// The text position in the interval [0,1].
/// Positions smaller than 0.25 are left aligned at the start of the line
/// Positions larger than 0.75 are right aligned at the end of the line
/// Other positions are center aligned at the specified position
public double TextLinePosition
{
get
{
return GetValue(TextLinePositionProperty);
}
set
{
SetValue(TextLinePositionProperty, 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.PathAnnotation)InternalAnnotation;
a.Color = Color.ToOxyColor();
a.ClipByXAxis = ClipByXAxis;
a.ClipByYAxis = ClipByYAxis;
a.StrokeThickness = StrokeThickness;
a.LineStyle = LineStyle;
a.LineJoin = LineJoin;
a.TextLinePosition = TextLinePosition;
a.TextOrientation = TextOrientation;
a.TextMargin = TextMargin;
}
static PathAnnotation()
{
ColorProperty.Changed.AddClassHandler(AppearanceChanged);
ClipByXAxisProperty.Changed.AddClassHandler(AppearanceChanged);
ClipByYAxisProperty.Changed.AddClassHandler(AppearanceChanged);
LineJoinProperty.Changed.AddClassHandler(AppearanceChanged);
LineStyleProperty.Changed.AddClassHandler(AppearanceChanged);
StrokeThicknessProperty.Changed.AddClassHandler(AppearanceChanged);
TextMarginProperty.Changed.AddClassHandler(AppearanceChanged);
TextOrientationProperty.Changed.AddClassHandler(AppearanceChanged);
TextLinePositionProperty.Changed.AddClassHandler(AppearanceChanged);
}
}
}