Browse Source

Documentation.

pull/81/head
Steven Kirk 11 years ago
parent
commit
bee6a6981a
  1. 22
      Perspex.Controls/Platform/IWindowImpl.cs
  2. 11
      Perspex.SceneGraph/Media/EllipseGeometry.cs
  3. 27
      Perspex.SceneGraph/Media/Geometry.cs
  4. 12
      Perspex.SceneGraph/Media/RectangleGeometry.cs
  5. 26
      Perspex.SceneGraph/Media/StreamGeometry.cs
  6. 47
      Perspex.SceneGraph/Media/StreamGeometryContext.cs
  7. 34
      Perspex.SceneGraph/Platform/IStreamGeometryContextImpl.cs

22
Perspex.Controls/Platform/IWindowImpl.cs

@ -1,22 +1,40 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="IWindowImpl.cs" company="Steven Kirk"> // <copyright file="IWindowImpl.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information. // Copyright 2015 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
namespace Perspex.Platform namespace Perspex.Platform
{ {
using System; using System;
using System.Threading.Tasks;
/// <summary>
/// Defines a platform-specific window implementation.
/// </summary>
public interface IWindowImpl : ITopLevelImpl public interface IWindowImpl : ITopLevelImpl
{ {
/// <summary>
/// Sets the title of the window.
/// </summary>
/// <param name="title">The title.</param>
void SetTitle(string title); void SetTitle(string title);
/// <summary>
/// Shows the window.
/// </summary>
void Show(); void Show();
/// <summary>
/// Shows the window as a dialog.
/// </summary>
/// <returns>
/// An <see cref="IDisposable"/> that should be used to close the window.
/// </returns>
IDisposable ShowDialog(); IDisposable ShowDialog();
/// <summary>
/// Hides the window.
/// </summary>
void Hide(); void Hide();
} }
} }

11
Perspex.SceneGraph/Media/EllipseGeometry.cs

@ -1,6 +1,6 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="EllipseGeometry.cs" company="Steven Kirk"> // <copyright file="EllipseGeometry.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information. // Copyright 2015 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -10,8 +10,15 @@ namespace Perspex.Media
using Perspex.Platform; using Perspex.Platform;
using Splat; using Splat;
/// <summary>
/// Represents the geometry of an ellipse or circle.
/// </summary>
public class EllipseGeometry : Geometry public class EllipseGeometry : Geometry
{ {
/// <summary>
/// Initializes a new instance of the <see cref="EllipseGeometry"/> class.
/// </summary>
/// <param name="rect">The rectangle that the ellipse should fill.</param>
public EllipseGeometry(Rect rect) public EllipseGeometry(Rect rect)
{ {
IPlatformRenderInterface factory = Locator.Current.GetService<IPlatformRenderInterface>(); IPlatformRenderInterface factory = Locator.Current.GetService<IPlatformRenderInterface>();
@ -46,11 +53,13 @@ namespace Perspex.Media
this.PlatformImpl = impl; this.PlatformImpl = impl;
} }
/// <inheritdoc/>
public override Rect Bounds public override Rect Bounds
{ {
get { return this.PlatformImpl.Bounds; } get { return this.PlatformImpl.Bounds; }
} }
/// <inheritdoc/>
public override Geometry Clone() public override Geometry Clone()
{ {
return new EllipseGeometry(this.Bounds); return new EllipseGeometry(this.Bounds);

27
Perspex.SceneGraph/Media/Geometry.cs

@ -9,11 +9,20 @@ namespace Perspex.Media
using System; using System;
using Perspex.Platform; using Perspex.Platform;
/// <summary>
/// Defines a geometric shape.
/// </summary>
public abstract class Geometry : PerspexObject public abstract class Geometry : PerspexObject
{ {
/// <summary>
/// Defines the <see cref="Transform"/> property.
/// </summary>
public static readonly PerspexProperty<Transform> TransformProperty = public static readonly PerspexProperty<Transform> TransformProperty =
PerspexProperty.Register<Geometry, Transform>("Transform"); PerspexProperty.Register<Geometry, Transform>("Transform");
/// <summary>
/// Initializes static members of the <see cref="Geometry"/> class.
/// </summary>
static Geometry() static Geometry()
{ {
TransformProperty.Changed.Subscribe(x => TransformProperty.Changed.Subscribe(x =>
@ -22,25 +31,43 @@ namespace Perspex.Media
}); });
} }
/// <summary>
/// Gets the geometry's bounding rectangle.
/// </summary>
public abstract Rect Bounds public abstract Rect Bounds
{ {
get; get;
} }
/// <summary>
/// Gets the platform-specific implementation of the geometry.
/// </summary>
public IGeometryImpl PlatformImpl public IGeometryImpl PlatformImpl
{ {
get; get;
protected set; protected set;
} }
/// <summary>
/// Gets or sets a transform to apply to the geometry.
/// </summary>
public Transform Transform public Transform Transform
{ {
get { return this.GetValue(TransformProperty); } get { return this.GetValue(TransformProperty); }
set { this.SetValue(TransformProperty, value); } set { this.SetValue(TransformProperty, value); }
} }
/// <summary>
/// Clones the geometry.
/// </summary>
/// <returns>A cloned geometry.</returns>
public abstract Geometry Clone(); public abstract Geometry Clone();
/// <summary>
/// Gets the geometry's bounding rectangle with the specified stroke thickness.
/// </summary>
/// <param name="strokeThickness">The stroke thickness.</param>
/// <returns>The bounding rectangle.</returns>
public Rect GetRenderBounds(double strokeThickness) public Rect GetRenderBounds(double strokeThickness)
{ {
return this.PlatformImpl.GetRenderBounds(strokeThickness); return this.PlatformImpl.GetRenderBounds(strokeThickness);

12
Perspex.SceneGraph/Media/RectangleGeometry.cs

@ -1,17 +1,23 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="RectangleGeometry.cs" company="Steven Kirk"> // <copyright file="RectangleGeometry.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information. // Copyright 2015 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
namespace Perspex.Media namespace Perspex.Media
{ {
using System;
using Perspex.Platform; using Perspex.Platform;
using Splat; using Splat;
/// <summary>
/// Represents the geometry of a rectangle.
/// </summary>
public class RectangleGeometry : Geometry public class RectangleGeometry : Geometry
{ {
/// <summary>
/// Initializes a new instance of the <see cref="RectangleGeometry"/> class.
/// </summary>
/// <param name="rect">The rectangle bounds.</param>
public RectangleGeometry(Rect rect) public RectangleGeometry(Rect rect)
{ {
IPlatformRenderInterface factory = Locator.Current.GetService<IPlatformRenderInterface>(); IPlatformRenderInterface factory = Locator.Current.GetService<IPlatformRenderInterface>();
@ -29,11 +35,13 @@ namespace Perspex.Media
this.PlatformImpl = impl; this.PlatformImpl = impl;
} }
/// <inheritdoc/>
public override Rect Bounds public override Rect Bounds
{ {
get { return this.PlatformImpl.Bounds; } get { return this.PlatformImpl.Bounds; }
} }
/// <inheritdoc/>
public override Geometry Clone() public override Geometry Clone()
{ {
return new RectangleGeometry(this.Bounds); return new RectangleGeometry(this.Bounds);

26
Perspex.SceneGraph/Media/StreamGeometry.cs

@ -1,33 +1,48 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="StreamGeometry.cs" company="Steven Kirk"> // <copyright file="StreamGeometry.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information. // Copyright 2015 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
namespace Perspex.Media namespace Perspex.Media
{ {
using System;
using Perspex.Platform; using Perspex.Platform;
using Splat; using Splat;
/// <summary>
/// Represents the geometry of an arbitrarily complex shape.
/// </summary>
public class StreamGeometry : Geometry public class StreamGeometry : Geometry
{ {
/// <summary>
/// Initializes a new instance of the <see cref="StreamGeometry"/> class.
/// </summary>
public StreamGeometry() public StreamGeometry()
{ {
IPlatformRenderInterface factory = Locator.Current.GetService<IPlatformRenderInterface>(); IPlatformRenderInterface factory = Locator.Current.GetService<IPlatformRenderInterface>();
this.PlatformImpl = factory.CreateStreamGeometry(); this.PlatformImpl = factory.CreateStreamGeometry();
} }
/// <summary>
/// Initializes a new instance of the <see cref="StreamGeometry"/> class.
/// </summary>
/// <param name="impl">The platform-specific implementation.</param>
private StreamGeometry(IGeometryImpl impl) private StreamGeometry(IGeometryImpl impl)
{ {
this.PlatformImpl = impl; this.PlatformImpl = impl;
} }
/// <inheritdoc/>
public override Rect Bounds public override Rect Bounds
{ {
get { return this.PlatformImpl.Bounds; } get { return this.PlatformImpl.Bounds; }
} }
/// <summary>
/// Creates a <see cref="StreamGeometry"/> from a string.
/// </summary>
/// <param name="s">The string.</param>
/// <returns>A <see cref="StreamGeometry"/>.</returns>
public static StreamGeometry Parse(string s) public static StreamGeometry Parse(string s)
{ {
StreamGeometry result = new StreamGeometry(); StreamGeometry result = new StreamGeometry();
@ -40,11 +55,18 @@ namespace Perspex.Media
} }
} }
/// <inheritdoc/>
public override Geometry Clone() public override Geometry Clone()
{ {
return new StreamGeometry(((IStreamGeometryImpl)this.PlatformImpl).Clone()); return new StreamGeometry(((IStreamGeometryImpl)this.PlatformImpl).Clone());
} }
/// <summary>
/// Opens the geometry to start defining it.
/// </summary>
/// <returns>
/// A <see cref="StreamGeometryContext"/> which can be used to define the geometry.
/// </returns>
public StreamGeometryContext Open() public StreamGeometryContext Open()
{ {
return new StreamGeometryContext(((IStreamGeometryImpl)this.PlatformImpl).Open()); return new StreamGeometryContext(((IStreamGeometryImpl)this.PlatformImpl).Open());

47
Perspex.SceneGraph/Media/StreamGeometryContext.cs

@ -1,6 +1,6 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="StreamGeometryContext.cs" company="Steven Kirk"> // <copyright file="StreamGeometryContext.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information. // Copyright 2015 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -9,40 +9,85 @@ namespace Perspex.Media
using System; using System;
using Perspex.Platform; using Perspex.Platform;
/// <summary>
/// Describes a geometry using drawing commands.
/// </summary>
/// <remarks>
/// This class is used to define the geometry of a <see cref="StreamGeometry"/>. An instance
/// of <see cref="StreamGeometryContext"/> is obtained by calling
/// <see cref="StreamGeometry.Open"/>.
/// </remarks>
/// TODO: This class is just a wrapper around IStreamGeometryContextImpl: is it needed?
public class StreamGeometryContext : IDisposable public class StreamGeometryContext : IDisposable
{ {
private IStreamGeometryContextImpl impl; private IStreamGeometryContextImpl impl;
/// <summary>
/// Initializes a new instance of the <see cref="StreamGeometryContext"/> class.
/// </summary>
/// <param name="impl">The platform-specific implementation.</param>
public StreamGeometryContext(IStreamGeometryContextImpl impl) public StreamGeometryContext(IStreamGeometryContextImpl impl)
{ {
this.impl = impl; this.impl = impl;
} }
/// <summary>
/// Draws an arc to the specified point.
/// </summary>
/// <param name="point">The destination point.</param>
/// <param name="size">The radii of an oval whose perimeter is used to draw the angle.</param>
/// <param name="rotationAngle">The rotation angle of the oval that specifies the curve.</param>
/// <param name="isLargeArc">true to draw the arc greater than 180 degrees; otherwise, false.</param>
/// <param name="sweepDirection">
/// A value that indicates whether the arc is drawn in the Clockwise or Counterclockwise direction.
/// </param>
public void ArcTo(Point point, Size size, double rotationAngle, bool isLargeArc, SweepDirection sweepDirection) public void ArcTo(Point point, Size size, double rotationAngle, bool isLargeArc, SweepDirection sweepDirection)
{ {
this.impl.ArcTo(point, size, rotationAngle, isLargeArc, sweepDirection); this.impl.ArcTo(point, size, rotationAngle, isLargeArc, sweepDirection);
} }
/// <summary>
/// Begins a new figure.
/// </summary>
/// <param name="startPoint">The starting point for the figure.</param>
/// <param name="isFilled">Whether the figure is filled.</param>
public void BeginFigure(Point startPoint, bool isFilled) public void BeginFigure(Point startPoint, bool isFilled)
{ {
this.impl.BeginFigure(startPoint, isFilled); this.impl.BeginFigure(startPoint, isFilled);
} }
/// <summary>
/// Draws a Bezier curve to the specified point.
/// </summary>
/// <param name="point1">The first control point used to specify the shape of the curve.</param>
/// <param name="point2">The second control point used to specify the shape of the curve.</param>
/// <param name="point3">The destination point for the end of the curve.</param>
public void BezierTo(Point point1, Point point2, Point point3) public void BezierTo(Point point1, Point point2, Point point3)
{ {
this.impl.BezierTo(point1, point2, point3); this.impl.BezierTo(point1, point2, point3);
} }
/// <summary>
/// Draws a line to the specified point.
/// </summary>
/// <param name="point">The destination point.</param>
public void LineTo(Point point) public void LineTo(Point point)
{ {
this.impl.LineTo(point); this.impl.LineTo(point);
} }
/// <summary>
/// Ends the figure started by <see cref="BeginFigure(Point, bool)"/>.
/// </summary>
/// <param name="isClosed">Whether the figure is closed.</param>
public void EndFigure(bool isClosed) public void EndFigure(bool isClosed)
{ {
this.impl.EndFigure(isClosed); this.impl.EndFigure(isClosed);
} }
/// <summary>
/// Finishes the drawing session.
/// </summary>
public void Dispose() public void Dispose()
{ {
this.impl.Dispose(); this.impl.Dispose();

34
Perspex.SceneGraph/Platform/IStreamGeometryContextImpl.cs

@ -1,6 +1,6 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="IStreamGeometryContextImpl.cs" company="Steven Kirk"> // <copyright file="IStreamGeometryContextImpl.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information. // Copyright 2015 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -9,16 +9,48 @@ namespace Perspex.Platform
using System; using System;
using Perspex.Media; using Perspex.Media;
/// <summary>
/// Describes a geometry using drawing commands.
/// </summary>
public interface IStreamGeometryContextImpl : IDisposable public interface IStreamGeometryContextImpl : IDisposable
{ {
/// <summary>
/// Draws an arc to the specified point.
/// </summary>
/// <param name="point">The destination point.</param>
/// <param name="size">The radii of an oval whose perimeter is used to draw the angle.</param>
/// <param name="rotationAngle">The rotation angle of the oval that specifies the curve.</param>
/// <param name="isLargeArc">true to draw the arc greater than 180 degrees; otherwise, false.</param>
/// <param name="sweepDirection">
/// A value that indicates whether the arc is drawn in the Clockwise or Counterclockwise direction.
/// </param>
void ArcTo(Point point, Size size, double rotationAngle, bool isLargeArc, SweepDirection sweepDirection); void ArcTo(Point point, Size size, double rotationAngle, bool isLargeArc, SweepDirection sweepDirection);
/// <summary>
/// Begins a new figure.
/// </summary>
/// <param name="startPoint">The starting point for the figure.</param>
/// <param name="isFilled">Whether the figure is filled.</param>
void BeginFigure(Point startPoint, bool isFilled); void BeginFigure(Point startPoint, bool isFilled);
/// <summary>
/// Draws a Bezier curve to the specified point.
/// </summary>
/// <param name="point1">The first control point used to specify the shape of the curve.</param>
/// <param name="point2">The second control point used to specify the shape of the curve.</param>
/// <param name="point3">The destination point for the end of the curve.</param>
void BezierTo(Point point1, Point point2, Point point3); void BezierTo(Point point1, Point point2, Point point3);
/// <summary>
/// Draws a line to the specified point.
/// </summary>
/// <param name="point">The destination point.</param>
void LineTo(Point point); void LineTo(Point point);
/// <summary>
/// Ends the figure started by <see cref="BeginFigure(Point, bool)"/>.
/// </summary>
/// <param name="isClosed">Whether the figure is closed.</param>
void EndFigure(bool isClosed); void EndFigure(bool isClosed);
} }
} }

Loading…
Cancel
Save