From a8b8454a6c680ca9bedcf93caba6de15540da0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=97=D0=B0?= =?UTF-8?q?=D0=B2=D0=BE=D0=B4=D1=81=D0=BA=D0=BE=D0=B9?= Date: Sat, 9 Feb 2019 03:54:28 +0300 Subject: [PATCH] add StrokeDashOffset support for shapes --- src/Avalonia.Controls/Shapes/Shape.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/Shapes/Shape.cs b/src/Avalonia.Controls/Shapes/Shape.cs index f77c43acd0..0387328a46 100644 --- a/src/Avalonia.Controls/Shapes/Shape.cs +++ b/src/Avalonia.Controls/Shapes/Shape.cs @@ -20,7 +20,10 @@ namespace Avalonia.Controls.Shapes AvaloniaProperty.Register(nameof(Stroke)); public static readonly StyledProperty> StrokeDashArrayProperty = - AvaloniaProperty.Register>("StrokeDashArray"); + AvaloniaProperty.Register>(nameof(StrokeDashArray)); + + public static readonly StyledProperty StrokeDashOffsetProperty = + AvaloniaProperty.Register(nameof(StrokeDashOffset)); public static readonly StyledProperty StrokeThicknessProperty = AvaloniaProperty.Register(nameof(StrokeThickness)); @@ -103,6 +106,12 @@ namespace Avalonia.Controls.Shapes get { return GetValue(StrokeDashArrayProperty); } set { SetValue(StrokeDashArrayProperty, value); } } + + public double StrokeDashOffset + { + get { return GetValue(StrokeDashOffsetProperty); } + set { SetValue(StrokeDashOffsetProperty, value); } + } public double StrokeThickness { @@ -124,7 +133,7 @@ namespace Avalonia.Controls.Shapes if (geometry != null) { - var pen = new Pen(Stroke, StrokeThickness, new DashStyle(StrokeDashArray), + var pen = new Pen(Stroke, StrokeThickness, new DashStyle(StrokeDashArray, StrokeDashOffset), StrokeDashCap, StrokeStartLineCap, StrokeEndLineCap, StrokeJoin); context.DrawGeometry(Fill, pen, geometry); }