using System.Collections.Generic;
namespace Avalonia.Media
{
///
/// Represents a set of line segments defined by a points collection with each Point specifying the end point of a line segment.
///
public sealed class PolyLineSegment : PathSegment
{
///
/// Defines the property.
///
public static readonly StyledProperty> PointsProperty
= AvaloniaProperty.Register>(nameof(Points));
///
/// Gets or sets the points.
///
///
/// The points.
///
public IList Points
{
get => GetValue(PointsProperty);
set => SetValue(PointsProperty, value);
}
///
/// Initializes a new instance of the class.
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012",
Justification = "Collection properties shouldn't be set with SetCurrentValue.")]
public PolyLineSegment()
{
Points = new Points();
}
///
/// Initializes a new instance of the class.
///
/// The points.
public PolyLineSegment(IEnumerable points)
{
Points = new Points(points);
}
internal override void ApplyTo(StreamGeometryContext ctx)
{
var points = Points;
if (points.Count > 0)
{
for (int i = 0; i < points.Count; i++)
{
ctx.LineTo(points[i]);
}
}
}
public override string ToString()
=> Points.Count >= 1 ? "L " + string.Join(" ", Points) : "";
}
}