// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) 2014 OxyPlot contributors // // // This is a Avalonia wrapper of OxyPlot.PathAnnotation // // -------------------------------------------------------------------------------------------------------------------- using Avalonia; namespace OxyPlot.Avalonia { using global::Avalonia.Layout; using OxyPlot.Annotations; using System; /// /// This is a Avalonia wrapper of OxyPlot.PathAnnotation /// public class FunctionAnnotation : PathAnnotation { /// /// Identifies the dependency property. /// public static readonly StyledProperty TypeProperty = AvaloniaProperty.Register(nameof(Type), FunctionAnnotationType.EquationX); /// /// Identifies the dependency property. /// public static readonly StyledProperty> EquationProperty = AvaloniaProperty.Register>(nameof(Equation)); /// /// Identifies the dependency property. /// public static readonly StyledProperty ResolutionProperty = AvaloniaProperty.Register(nameof(Resolution), 400); /// /// Initializes static members of the class. /// static FunctionAnnotation() { 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); } /// /// Initializes a new instance of the class. /// public FunctionAnnotation() { InternalAnnotation = new Annotations.FunctionAnnotation(); } /// /// Gets or sets the equation. /// /// The equation. public Func Equation { get { return GetValue(EquationProperty); } set { SetValue(EquationProperty, value); } } /// /// Gets or sets the resolution. /// /// The resolution. public int Resolution { get { return GetValue(ResolutionProperty); } set { SetValue(ResolutionProperty, value); } } /// /// Gets or sets Type. /// public FunctionAnnotationType Type { get { return GetValue(TypeProperty); } set { SetValue(TypeProperty, 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.FunctionAnnotation)InternalAnnotation; a.Type = Type; a.Equation = Equation; a.Resolution = Resolution; } } }