// -----------------------------------------------------------------------
//
// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex.Media
{
using Perspex.Platform;
using Splat;
///
/// Represents the geometry of an arbitrarily complex shape.
///
public class StreamGeometry : Geometry
{
///
/// Initializes a new instance of the class.
///
public StreamGeometry()
{
IPlatformRenderInterface factory = Locator.Current.GetService();
this.PlatformImpl = factory.CreateStreamGeometry();
}
///
/// Initializes a new instance of the class.
///
/// The platform-specific implementation.
private StreamGeometry(IGeometryImpl impl)
{
this.PlatformImpl = impl;
}
///
public override Rect Bounds
{
get { return this.PlatformImpl.Bounds; }
}
///
/// Creates a from a string.
///
/// The string.
/// A .
public static StreamGeometry Parse(string s)
{
StreamGeometry result = new StreamGeometry();
using (StreamGeometryContext ctx = result.Open())
{
PathMarkupParser parser = new PathMarkupParser(result, ctx);
parser.Parse(s);
return result;
}
}
///
public override Geometry Clone()
{
return new StreamGeometry(((IStreamGeometryImpl)this.PlatformImpl).Clone());
}
///
/// Opens the geometry to start defining it.
///
///
/// A which can be used to define the geometry.
///
public StreamGeometryContext Open()
{
return new StreamGeometryContext(((IStreamGeometryImpl)this.PlatformImpl).Open());
}
}
}