9 changed files with 149 additions and 54 deletions
@ -0,0 +1,35 @@ |
|||
// -----------------------------------------------------------------------
|
|||
// <copyright file="RectangleGeometry.cs" company="Steven Kirk">
|
|||
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|||
// </copyright>
|
|||
// -----------------------------------------------------------------------
|
|||
|
|||
namespace Perspex.Media |
|||
{ |
|||
using System; |
|||
using Splat; |
|||
|
|||
public class RectangleGeometry : Geometry |
|||
{ |
|||
public RectangleGeometry(Rect rect) |
|||
{ |
|||
IStreamGeometryImpl impl = Locator.Current.GetService<IStreamGeometryImpl>(); |
|||
|
|||
using (IStreamGeometryContextImpl context = impl.Open()) |
|||
{ |
|||
context.BeginFigure(rect.TopLeft, true); |
|||
context.LineTo(rect.TopRight); |
|||
context.LineTo(rect.BottomRight); |
|||
context.LineTo(rect.BottomLeft); |
|||
context.EndFigure(true); |
|||
} |
|||
|
|||
this.PlatformImpl = impl; |
|||
} |
|||
|
|||
public override Rect Bounds |
|||
{ |
|||
get { return this.PlatformImpl.Bounds; } |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
// -----------------------------------------------------------------------
|
|||
// <copyright file="Rectangle.cs" company="Steven Kirk">
|
|||
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|||
// </copyright>
|
|||
// -----------------------------------------------------------------------
|
|||
|
|||
namespace Perspex.Shapes |
|||
{ |
|||
using System; |
|||
using System.Reactive.Linq; |
|||
using Perspex.Media; |
|||
|
|||
public class Rectangle : Shape |
|||
{ |
|||
private Size size; |
|||
|
|||
public override Geometry DefiningGeometry |
|||
{ |
|||
get { return new RectangleGeometry(new Rect(size)); } |
|||
} |
|||
|
|||
protected override Size MeasureContent(Size availableSize) |
|||
{ |
|||
return new Size(this.Width, this.Height); |
|||
} |
|||
|
|||
protected override Size ArrangeContent(Size finalSize) |
|||
{ |
|||
this.size = finalSize; |
|||
return base.ArrangeContent(finalSize); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue