File tree Expand file tree Collapse file tree 1 file changed +61
-0
lines changed
src/Avalonia.Visuals/Media Expand file tree Collapse file tree 1 file changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ using System . Collections . Generic ;
2+ using Avalonia . Collections ;
3+
4+ namespace Avalonia . Media
5+ {
6+ /// <summary>
7+ /// Represents a set of line segments defined by a points collection with each Point specifying the end point of a line segment.
8+ /// </summary>
9+ public sealed class PolyLineSegment : PathSegment
10+ {
11+ /// <summary>
12+ /// Defines the <see cref="Points"/> property.
13+ /// </summary>
14+ public static readonly StyledProperty < Points > PointsProperty
15+ = AvaloniaProperty . Register < PolyLineSegment , Points > ( nameof ( Points ) ) ;
16+
17+ /// <summary>
18+ /// Gets or sets the points.
19+ /// </summary>
20+ /// <value>
21+ /// The points.
22+ /// </value>
23+ public AvaloniaList < Point > Points
24+ {
25+ get => GetValue ( PointsProperty ) ;
26+ set => SetValue ( PointsProperty , value ) ;
27+ }
28+
29+ /// <summary>
30+ /// Initializes a new instance of the <see cref="PolyLineSegment"/> class.
31+ /// </summary>
32+ public PolyLineSegment ( )
33+ {
34+ Points = new Points ( ) ;
35+ }
36+
37+ /// <summary>
38+ /// Initializes a new instance of the <see cref="PolyLineSegment"/> class.
39+ /// </summary>
40+ /// <param name="points">The points.</param>
41+ public PolyLineSegment ( IEnumerable < Point > points ) : this ( )
42+ {
43+ Points . AddRange ( points ) ;
44+ }
45+
46+ protected internal override void ApplyTo ( StreamGeometryContext ctx )
47+ {
48+ var points = Points ;
49+ if ( points . Count > 0 )
50+ {
51+ for ( int i = 0 ; i < points . Count ; i ++ )
52+ {
53+ ctx . LineTo ( points [ i ] ) ;
54+ }
55+ }
56+ }
57+
58+ public override string ToString ( )
59+ => Points . Count >= 1 ? "L " + string . Join ( " " , Points ) : "" ;
60+ }
61+ }
You can’t perform that action at this time.
0 commit comments