csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.1 KiB
75 lines
2.1 KiB
// -----------------------------------------------------------------------
|
|
// <copyright file="GeometryImpl.cs" company="Steven Kirk">
|
|
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|
// </copyright>
|
|
// -----------------------------------------------------------------------
|
|
|
|
namespace Perspex.Direct2D1.Media
|
|
{
|
|
using Perspex.Platform;
|
|
using SharpDX.Direct2D1;
|
|
using Splat;
|
|
|
|
public abstract class GeometryImpl : IGeometryImpl
|
|
{
|
|
private TransformedGeometry transformed;
|
|
|
|
public abstract Rect Bounds
|
|
{
|
|
get;
|
|
}
|
|
|
|
public abstract Geometry DefiningGeometry
|
|
{
|
|
get;
|
|
}
|
|
|
|
public Geometry Geometry
|
|
{
|
|
get { return this.transformed ?? this.DefiningGeometry; }
|
|
}
|
|
|
|
public Matrix Transform
|
|
{
|
|
get
|
|
{
|
|
return this.transformed != null ?
|
|
this.transformed.Transform.ToPerspex() :
|
|
Matrix.Identity;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (value != this.Transform)
|
|
{
|
|
if (this.transformed != null)
|
|
{
|
|
this.transformed.Dispose();
|
|
this.transformed = null;
|
|
}
|
|
|
|
if (!value.IsIdentity)
|
|
{
|
|
Factory factory = Locator.Current.GetService<Factory>();
|
|
this.transformed = new TransformedGeometry(
|
|
factory,
|
|
this.DefiningGeometry,
|
|
value.ToDirect2D());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public Rect GetRenderBounds(double strokeThickness)
|
|
{
|
|
if (this.transformed != null)
|
|
{
|
|
return this.transformed.GetWidenedBounds((float)strokeThickness).ToPerspex();
|
|
}
|
|
else
|
|
{
|
|
return this.DefiningGeometry.GetWidenedBounds((float)strokeThickness).ToPerspex();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|