// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) 2014 OxyPlot contributors // // // This is a Avalonia wrapper of OxyPlot.LineAnnotation // // -------------------------------------------------------------------------------------------------------------------- using Avalonia; namespace OxyPlot.Avalonia { using global::Avalonia.Layout; using OxyPlot.Annotations; /// /// This is a Avalonia wrapper of OxyPlot.LineAnnotation /// public class LineAnnotation : PathAnnotation { /// /// Identifies the dependency property. /// public static readonly StyledProperty TypeProperty = AvaloniaProperty.Register(nameof(Type), LineAnnotationType.LinearEquation); /// /// Identifies the dependency property. /// public static readonly StyledProperty InterceptProperty = AvaloniaProperty.Register(nameof(Intercept), 0.0); /// /// 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); /// /// Identifies the dependency property. /// public static readonly StyledProperty SlopeProperty = AvaloniaProperty.Register(nameof(Slope), 0.0); /// /// 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); /// /// Initializes static members of the class. /// static LineAnnotation() { TextColorProperty.OverrideDefaultValue(MoreColors.Automatic); TextColorProperty.Changed.AddClassHandler(AppearanceChanged); TextHorizontalAlignmentProperty.OverrideDefaultValue(HorizontalAlignment.Right); TextHorizontalAlignmentProperty.Changed.AddClassHandler(AppearanceChanged); TextVerticalAlignmentProperty.OverrideDefaultValue(VerticalAlignment.Top); TextVerticalAlignmentProperty.Changed.AddClassHandler(AppearanceChanged); TypeProperty.Changed.AddClassHandler(DataChanged); InterceptProperty.Changed.AddClassHandler(DataChanged); MaximumXProperty.Changed.AddClassHandler(DataChanged); MaximumYProperty.Changed.AddClassHandler(DataChanged); MinimumXProperty.Changed.AddClassHandler(DataChanged); MinimumYProperty.Changed.AddClassHandler(DataChanged); SlopeProperty.Changed.AddClassHandler(DataChanged); XProperty.Changed.AddClassHandler(DataChanged); YProperty.Changed.AddClassHandler(DataChanged); } /// /// Initializes a new instance of the class. /// public LineAnnotation() { InternalAnnotation = new Annotations.LineAnnotation(); } /// /// Gets or sets Intercept. /// public double Intercept { get { return GetValue(InterceptProperty); } set { SetValue(InterceptProperty, value); } } /// /// Gets or sets MaximumX. /// public double MaximumX { get { return GetValue(MaximumXProperty); } set { SetValue(MaximumXProperty, value); } } /// /// Gets or sets MaximumY. /// public double MaximumY { get { return GetValue(MaximumYProperty); } set { SetValue(MaximumYProperty, value); } } /// /// Gets or sets MinimumX. /// public double MinimumX { get { return GetValue(MinimumXProperty); } set { SetValue(MinimumXProperty, value); } } /// /// Gets or sets MinimumY. /// public double MinimumY { get { return GetValue(MinimumYProperty); } set { SetValue(MinimumYProperty, value); } } /// /// Gets or sets Slope. /// public double Slope { get { return GetValue(SlopeProperty); } set { SetValue(SlopeProperty, value); } } /// /// Gets or sets Type. /// public LineAnnotationType Type { get { return GetValue(TypeProperty); } set { SetValue(TypeProperty, value); } } /// /// Gets or sets X. /// public double X { get { return GetValue(XProperty); } set { SetValue(XProperty, value); } } /// /// Gets or sets Y. /// 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.LineAnnotation)InternalAnnotation; a.Type = Type; a.Slope = Slope; a.Intercept = Intercept; a.X = X; a.Y = Y; a.MinimumX = MinimumX; a.MaximumX = MaximumX; a.MinimumY = MinimumY; a.MaximumY = MaximumY; } } }