Skip to content
Merged
21 changes: 20 additions & 1 deletion src/Avalonia.Visuals/Media/PathGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Avalonia.Collections;
using Avalonia.Metadata;
using Avalonia.Platform;
using Avalonia.Visuals.Platform;

namespace Avalonia.Media
{
Expand All @@ -28,7 +29,7 @@ public class PathGeometry : StreamGeometry

static PathGeometry()
{
FiguresProperty.Changed.AddClassHandler<PathGeometry>((s, e) =>
FiguresProperty.Changed.AddClassHandler<PathGeometry>((s, e) =>
s.OnFiguresChanged(e.NewValue as PathFigures));
}

Expand All @@ -40,6 +41,24 @@ public PathGeometry()
Figures = new PathFigures();
}

/// <summary>
/// Parses the specified path data to a <see cref="PathGeometry"/>.
/// </summary>
/// <param name="pathData">The s.</param>
/// <returns></returns>
public static new PathGeometry Parse(string pathData)
{
var pathGeometry = new PathGeometry();

using (var context = new PathGeometryContext(pathGeometry))
using (var parser = new PathMarkupParser(context))
{
parser.Parse(pathData);
}

return pathGeometry;
}

/// <summary>
/// Gets or sets the figures.
/// </summary>
Expand Down
Loading