// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) 2014 OxyPlot contributors // // // This is a Avalonia wrapper of OxyPlot.PolygonAnnotation // // -------------------------------------------------------------------------------------------------------------------- using Avalonia; namespace OxyPlot.Avalonia { using System.Collections.Generic; /// /// This is a Avalonia wrapper of OxyPlot.PolygonAnnotation /// public class PolygonAnnotation : ShapeAnnotation { /// /// 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.Solid); /// /// Identifies the dependency property. /// public static readonly StyledProperty> PointsProperty = AvaloniaProperty.Register>(nameof(Points), new List()); /// /// Initializes static members of the class. /// static PolygonAnnotation() { TextColorProperty.OverrideDefaultValue(MoreColors.Automatic); TextColorProperty.Changed.AddClassHandler(AppearanceChanged); LineJoinProperty.Changed.AddClassHandler(AppearanceChanged); LineStyleProperty.Changed.AddClassHandler(AppearanceChanged); PointsProperty.Changed.AddClassHandler(DataChanged); } /// /// Initializes a new instance of the class. /// public PolygonAnnotation() { InternalAnnotation = new Annotations.PolygonAnnotation(); } /// /// Gets or sets the line join. /// /// The line join. public LineJoin LineJoin { get { return GetValue(LineJoinProperty); } set { SetValue(LineJoinProperty, value); } } /// /// Gets or sets the line style. /// public LineStyle LineStyle { get { return GetValue(LineStyleProperty); } set { SetValue(LineStyleProperty, value); } } /// /// Gets or sets the points. /// public IList Points { get { return GetValue(PointsProperty); } set { SetValue(PointsProperty, 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.PolygonAnnotation)InternalAnnotation; a.Points.Clear(); a.Points.AddRange(Points); a.LineStyle = LineStyle; a.LineJoin = LineJoin; } } }