|
|
|
@ -1,11 +1,7 @@ |
|
|
|
// Copyright (c) The Perspex Project. All rights reserved.
|
|
|
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Perspex.Media; |
|
|
|
|
|
|
|
namespace Perspex.Controls.Shapes |
|
|
|
@ -15,9 +11,25 @@ namespace Perspex.Controls.Shapes |
|
|
|
public static readonly StyledProperty<IList<Point>> PointsProperty = |
|
|
|
PerspexProperty.Register<Polyline, IList<Point>>("Points"); |
|
|
|
|
|
|
|
private Geometry _geometry; |
|
|
|
|
|
|
|
static Polyline() |
|
|
|
{ |
|
|
|
StrokeThicknessProperty.OverrideDefaultValue<Polyline>(1); |
|
|
|
PointsProperty.Changed.AddClassHandler<Polyline>(x => x.PointsChanged); |
|
|
|
} |
|
|
|
|
|
|
|
public override Geometry DefiningGeometry |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
if (_geometry == null) |
|
|
|
{ |
|
|
|
_geometry = new PolylineGeometry(Points, false); |
|
|
|
} |
|
|
|
|
|
|
|
return _geometry; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public IList<Point> Points |
|
|
|
@ -26,6 +38,10 @@ namespace Perspex.Controls.Shapes |
|
|
|
set { SetValue(PointsProperty, value); } |
|
|
|
} |
|
|
|
|
|
|
|
public override Geometry DefiningGeometry => new PolylineGeometry(Points, false); |
|
|
|
private void PointsChanged(PerspexPropertyChangedEventArgs e) |
|
|
|
{ |
|
|
|
_geometry = null; |
|
|
|
InvalidateMeasure(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|