diff --git a/Perspex.Controls/Shapes/Shape.cs b/Perspex.Controls/Shapes/Shape.cs
index 1dd8792733..86311efb20 100644
--- a/Perspex.Controls/Shapes/Shape.cs
+++ b/Perspex.Controls/Shapes/Shape.cs
@@ -121,7 +121,7 @@ namespace Perspex.Controls.Shapes
if (this.Stretch != Stretch.None)
{
shapeSize = shapeBounds.Size;
- translate = Matrix.Translation(-(Vector)shapeBounds.Position);
+ translate = Matrix.CreateTranslation(-(Vector)shapeBounds.Position);
}
if (double.IsInfinity(availableSize.Width))
@@ -179,7 +179,7 @@ namespace Perspex.Controls.Shapes
break;
}
- var t = translate * Matrix.Scaling(sx, sy);
+ var t = translate * Matrix.CreateScale(sx, sy);
if (this.transform != t)
{
diff --git a/Perspex.Input/AccessKeyHandler.cs b/Perspex.Input/AccessKeyHandler.cs
index cf2251ef45..6df206bc67 100644
--- a/Perspex.Input/AccessKeyHandler.cs
+++ b/Perspex.Input/AccessKeyHandler.cs
@@ -158,7 +158,7 @@ namespace Perspex.Input
// If the menu is open, only match controls in the menu's visual tree.
if (menuIsOpen)
{
- matches = matches.Where(x => this.MainMenu.IsVisualParentOf(x));
+ matches = matches.Where(x => this.MainMenu.IsVisualAncestorOf(x));
}
var match = matches.FirstOrDefault();
diff --git a/Perspex.SceneGraph/Matrix.cs b/Perspex.SceneGraph/Matrix.cs
index 27cca586ad..b12db41cdd 100644
--- a/Perspex.SceneGraph/Matrix.cs
+++ b/Perspex.SceneGraph/Matrix.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------
+// -----------------------------------------------------------------------
//
// Copyright 2013 MIT Licence. See licence.md for more information.
//
@@ -7,16 +7,29 @@
namespace Perspex
{
using System;
+ using System.Globalization;
+ ///
+ /// A 2x3 matrix.
+ ///
public struct Matrix
{
private double m11;
private double m12;
private double m21;
private double m22;
- private double offsetX;
- private double offsetY;
-
+ private double m31;
+ private double m32;
+
+ ///
+ /// Initializes a new instance of the struct.
+ ///
+ /// The first element of the first row.
+ /// The second element of the first row.
+ /// The first element of the second row.
+ /// The second element of the second row.
+ /// The first element of the third row.
+ /// The second element of the third row.
public Matrix(
double m11,
double m12,
@@ -29,176 +42,279 @@ namespace Perspex
this.m12 = m12;
this.m21 = m21;
this.m22 = m22;
- this.offsetX = offsetX;
- this.offsetY = offsetY;
+ this.m31 = offsetX;
+ this.m32 = offsetY;
}
+ ///
+ /// Returns the multiplicative identity matrix.
+ ///
public static Matrix Identity
{
get { return new Matrix(1.0, 0.0, 0.0, 1.0, 0.0, 0.0); }
}
- public double Determinant
- {
- get { return (this.m11 * this.m22) - (this.m12 * this.m21); }
- }
-
- public bool HasInverse
- {
- get { return this.Determinant != 0; }
- }
-
+ ///
+ /// Returns whether the matrix is the identity matrix.
+ ///
public bool IsIdentity
{
get { return this.Equals(Matrix.Identity); }
}
+ ///
+ /// The first element of the first row
+ ///
public double M11
{
get { return this.m11; }
}
+ ///
+ /// The second element of the first row
+ ///
public double M12
{
get { return this.m12; }
}
+ ///
+ /// The first element of the second row
+ ///
public double M21
{
get { return this.m21; }
}
+ ///
+ /// The second element of the second row
+ ///
public double M22
{
get { return this.m22; }
}
- public double OffsetX
+ ///
+ /// The first element of the third row
+ ///
+ public double M31
{
- get { return this.offsetX; }
+ get { return this.m31; }
}
- public double OffsetY
+ ///
+ /// The second element of the third row
+ ///
+ public double M32
{
- get { return this.offsetY; }
+ get { return this.m32; }
}
- public static Matrix operator *(Matrix left, Matrix right)
+ ///
+ /// Multiplies two matrices together and returns the resulting matrix.
+ ///
+ /// The first source matrix.
+ /// The second source matrix.
+ /// The product matrix.
+ public static Matrix operator *(Matrix value1, Matrix value2)
{
return new Matrix(
- (left.M11 * right.M11) + (left.M12 * right.M21),
- (left.M11 * right.M12) + (left.M12 * right.M22),
- (left.M21 * right.M11) + (left.M22 * right.M21),
- (left.M21 * right.M12) + (left.M22 * right.M22),
- (left.offsetX * right.M11) + (left.offsetY * right.M21) + right.offsetX,
- (left.offsetX * right.M12) + (left.offsetY * right.M22) + right.offsetY);
- }
-
- public static Matrix operator -(Matrix matrix)
- {
- return matrix.Invert();
+ (value1.M11 * value2.M11) + (value1.M12 * value2.M21),
+ (value1.M11 * value2.M12) + (value1.M12 * value2.M22),
+ (value1.M21 * value2.M11) + (value1.M22 * value2.M21),
+ (value1.M21 * value2.M12) + (value1.M22 * value2.M22),
+ (value1.m31 * value2.M11) + (value1.m32 * value2.M21) + value2.m31,
+ (value1.m31 * value2.M12) + (value1.m32 * value2.M22) + value2.m32);
}
- public static bool operator ==(Matrix matrix1, Matrix matrix2)
+ ///
+ /// Negates the given matrix by multiplying all values by -1.
+ ///
+ /// The source matrix.
+ /// The negated matrix.
+ public static Matrix operator -(Matrix value)
{
- return matrix1.Equals(matrix2);
+ return value.Invert();
}
- public static bool operator !=(Matrix matrix1, Matrix matrix2)
+ ///
+ /// Returns a boolean indicating whether the given matrices are equal.
+ ///
+ /// The first source matrix.
+ /// The second source matrix.
+ /// True if the matrices are equal; False otherwise.
+ public static bool operator ==(Matrix value1, Matrix value2)
{
- return !matrix1.Equals(matrix2);
+ return value1.Equals(value2);
}
- public static bool Equals(Matrix matrix1, Matrix matrix2)
+ ///
+ /// Returns a boolean indicating whether the given matrices are not equal.
+ ///
+ /// The first source matrix.
+ /// The second source matrix.
+ /// True if the matrices are not equal; False if they are equal.
+ public static bool operator !=(Matrix value1, Matrix value2)
{
- return matrix1.Equals(matrix2);
+ return !value1.Equals(value2);
}
- public static Matrix Rotation(double angle)
+ ///
+ /// Creates a rotation matrix using the given rotation in radians.
+ ///
+ /// The amount of rotation, in radians.
+ /// A rotation matrix.
+ public static Matrix CreateRotation(double radians)
{
- double cos = Math.Cos(angle);
- double sin = Math.Sin(angle);
+ double cos = Math.Cos(radians);
+ double sin = Math.Sin(radians);
return new Matrix(cos, sin, -sin, cos, 0, 0);
}
- public static Matrix Scaling(double x, double y)
+ ///
+ /// Creates a scale matrix from the given X and Y components.
+ ///
+ /// Value to scale by on the X-axis.
+ /// Value to scale by on the Y-axis.
+ /// A scaling matrix.
+ public static Matrix CreateScale(double xScale, double yScale)
{
- return Scaling(new Vector(x, y));
+ return CreateScale(new Vector(xScale, yScale));
}
- public static Matrix Scaling(Vector scale)
+ ///
+ /// Creates a scale matrix from the given vector scale.
+ ///
+ /// The scale to use.
+ /// A scaling matrix.
+ public static Matrix CreateScale(Vector scales)
{
- return new Matrix(scale.X, 0, 0, scale.Y, 0, 0);
+ return new Matrix(scales.X, 0, 0, scales.Y, 0, 0);
}
- public static Matrix Translation(Vector v)
+ ///
+ /// Creates a translation matrix from the given vector.
+ ///
+ /// The translation position.
+ /// A translation matrix.
+ public static Matrix CreateTranslation(Vector position)
{
- return Translation(v.X, v.Y);
+ return CreateTranslation(position.X, position.Y);
}
- public static Matrix Translation(double x, double y)
+ ///
+ /// Creates a translation matrix from the given X and Y components.
+ ///
+ /// The X position.
+ /// The Y position.
+ /// A translation matrix.
+ public static Matrix CreateTranslation(double xPosition, double yPosition)
{
- return new Matrix(1.0, 0.0, 0.0, 1.0, x, y);
+ return new Matrix(1.0, 0.0, 0.0, 1.0, xPosition, yPosition);
}
+ ///
+ /// Converts an ange in degrees to radians.
+ ///
+ /// The angle in degrees.
+ /// The angle in radians.
public static double ToRadians(double angle)
{
return angle * 0.0174532925;
}
- public bool Equals(Matrix value)
+ ///
+ /// Calculates the determinant for this matrix.
+ ///
+ /// The determinant.
+ ///
+ /// The determinant is calculated by expanding the matrix with a third column whose
+ /// values are (0,0,1).
+ ///
+ public double GetDeterminant()
+ {
+ return (this.m11 * this.m22) - (this.m12 * this.m21);
+ }
+
+ ///
+ /// Returns a boolean indicating whether the matrix is equal to the other given matrix.
+ ///
+ /// The other matrix to test equality against.
+ /// True if this matrix is equal to other; False otherwise.
+ public bool Equals(Matrix other)
{
- return this.m11 == value.M11 &&
- this.m12 == value.M12 &&
- this.m21 == value.M21 &&
- this.m22 == value.M22 &&
- this.offsetX == value.OffsetX &&
- this.offsetY == value.OffsetY;
+ return this.m11 == other.M11 &&
+ this.m12 == other.M12 &&
+ this.m21 == other.M21 &&
+ this.m22 == other.M22 &&
+ this.m31 == other.M31 &&
+ this.m32 == other.M32;
}
- public override bool Equals(object o)
+ ///
+ /// Returns a boolean indicating whether the given Object is equal to this matrix instance.
+ ///
+ /// The Object to compare against.
+ /// True if the Object is equal to this matrix; False otherwise.
+ public override bool Equals(object obj)
{
- if (!(o is Matrix))
+ if (!(obj is Matrix))
{
return false;
}
- return this.Equals((Matrix)o);
+ return this.Equals((Matrix)obj);
}
+ ///
+ /// Returns the hash code for this instance.
+ ///
+ /// The hash code.
public override int GetHashCode()
{
- throw new NotImplementedException();
+ return this.M11.GetHashCode() + this.M12.GetHashCode() +
+ this.M21.GetHashCode() + this.M22.GetHashCode() +
+ this.M31.GetHashCode() + this.M32.GetHashCode();
}
+ ///
+ /// Returns a String representing this matrix instance.
+ ///
+ /// The string representation.
public override string ToString()
{
+ CultureInfo ci = CultureInfo.CurrentCulture;
return string.Format(
- "{0},{1} {2},{3} {4},{5}",
- this.m11,
- this.m12,
- this.m21,
- this.m22,
- this.offsetX,
- this.offsetY);
+ ci,
+ "{{ {{M11:{0} M12:{1}}} {{M21:{2} M22:{3}}} {{M31:{4} M32:{5}}} }}",
+ this.M11.ToString(ci),
+ this.M12.ToString(ci),
+ this.M21.ToString(ci),
+ this.M22.ToString(ci),
+ this.M31.ToString(ci),
+ this.M32.ToString(ci));
}
+ ///
+ /// Inverts the Matrix.
+ ///
+ /// The inverted matrix.
public Matrix Invert()
{
- if (!this.HasInverse)
+ if (this.GetDeterminant() == 0)
{
throw new InvalidOperationException("Transform is not invertible.");
}
- double d = this.Determinant;
+ double d = this.GetDeterminant();
return new Matrix(
this.m22 / d,
-this.m12 / d,
-this.m21 / d,
this.m11 / d,
- ((this.m21 * this.offsetY) - (this.m22 * this.offsetX)) / d,
- ((this.m12 * this.offsetX) - (this.m11 * this.offsetY)) / d);
+ ((this.m21 * this.m32) - (this.m22 * this.m31)) / d,
+ ((this.m12 * this.m31) - (this.m11 * this.m32)) / d);
}
}
}
\ No newline at end of file
diff --git a/Perspex.SceneGraph/Media/FontStyle.cs b/Perspex.SceneGraph/Media/FontStyle.cs
index 2729233ecd..67178e3ead 100644
--- a/Perspex.SceneGraph/Media/FontStyle.cs
+++ b/Perspex.SceneGraph/Media/FontStyle.cs
@@ -6,10 +6,24 @@
namespace Perspex.Media
{
+ ///
+ /// Defines the available font styles.
+ ///
public enum FontStyle
{
+ ///
+ /// A normal font.
+ ///
Normal,
+
+ ///
+ /// An oblique font.
+ ///
Oblique,
+
+ ///
+ /// An italic font.
+ ///
Italic,
}
}
diff --git a/Perspex.SceneGraph/Media/FontWeight.cs b/Perspex.SceneGraph/Media/FontWeight.cs
index e28802d2a0..d59d3e75c0 100644
--- a/Perspex.SceneGraph/Media/FontWeight.cs
+++ b/Perspex.SceneGraph/Media/FontWeight.cs
@@ -6,23 +6,93 @@
namespace Perspex.Media
{
+ ///
+ /// Defines a set of predefined font weights.
+ ///
+ ///
+ /// As well as the values defined by this enumeration you can also pass any integer value by
+ /// casting it to , e.g. (FontWeight)550.
+ ///
public enum FontWeight
{
+ ///
+ /// Specifies a "thin" font weight.
+ ///
Thin = 100,
+
+ ///
+ /// Specifies an "extra light" font weight.
+ ///
ExtraLight = 200,
+
+ ///
+ /// Specifies an "ultra light" font weight.
+ ///
UltraLight = 200,
+
+ ///
+ /// Specifies a "light" font weight.
+ ///
Light = 300,
+
+ ///
+ /// Specifies a "normal" font weight.
+ ///
Normal = 400,
+
+ ///
+ /// Specifies a "regular" font weight.
+ ///
Regular = 400,
+
+ ///
+ /// Specifies a "medium" font weight.
+ ///
Medium = 500,
+
+ ///
+ /// Specifies a "demi-bold" font weight.
+ ///
DemiBold = 600,
+
+ ///
+ /// Specifies a "semi-bold" font weight.
+ ///
SemiBold = 600,
+
+ ///
+ /// Specifies a "bold" font weight.
+ ///
Bold = 700,
+
+ ///
+ /// Specifies an "extra bold" font weight.
+ ///
ExtraBold = 800,
+
+ ///
+ /// Specifies an "ultra bold" font weight.
+ ///
UltraBold = 800,
+
+ ///
+ /// Specifies a "black" font weight.
+ ///
Black = 900,
+
+ ///
+ /// Specifies a "heavy" font weight.
+ ///
Heavy = 900,
+
+ ///
+ /// Specifies an "extra black" font weight.
+ ///
ExtraBlack = 950,
+
+ ///
+ /// Specifies an "ultra black" font weight.
+ ///
UltraBlack = 950
}
}
diff --git a/Perspex.SceneGraph/Media/FormattedText.cs b/Perspex.SceneGraph/Media/FormattedText.cs
index 0fbc3eb092..ab9c9d8510 100644
--- a/Perspex.SceneGraph/Media/FormattedText.cs
+++ b/Perspex.SceneGraph/Media/FormattedText.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// Copyright 2013 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
@@ -11,8 +11,20 @@ namespace Perspex.Media
using Perspex.Platform;
using Splat;
+ ///
+ /// Represents a piece of text with formatting.
+ ///
public class FormattedText : IDisposable
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The text.
+ /// The font family.
+ /// The font size.
+ /// The font style.
+ /// The text alignment.
+ /// The font weight.
public FormattedText(
string text,
string fontFamilyName,
@@ -39,87 +51,148 @@ namespace Perspex.Media
fontWeight);
}
+ ///
+ /// Gets or sets the constraint of the text.
+ ///
public Size Constraint
{
get { return this.PlatformImpl.Constraint; }
set { this.PlatformImpl.Constraint = value; }
}
+ ///
+ /// Gets the font family.
+ ///
public string FontFamilyName
{
get;
private set;
}
+ ///
+ /// Gets the font size.
+ ///
public double FontSize
{
get;
private set;
}
+ ///
+ /// Gets the font style.
+ ///
public FontStyle FontStyle
{
get;
private set;
}
+ ///
+ /// Gets the font weight.
+ ///
public FontWeight FontWeight
{
get;
private set;
}
+ ///
+ /// Gets the text.
+ ///
public string Text
{
get;
private set;
}
+ ///
+ /// Gets platform-specific platform implementation.
+ ///
public IFormattedTextImpl PlatformImpl
{
get;
private set;
}
+ ///
+ /// Gets the text alignment.
+ ///
public TextAlignment TextAlignment
{
get;
private set;
}
+ ///
+ /// Disposes of unmanaged resources associated with the formatted text.
+ ///
public void Dispose()
{
this.PlatformImpl.Dispose();
}
+ ///
+ /// Gets the lines in the text.
+ ///
+ ///
+ /// A collection of objects.
+ ///
public IEnumerable GetLines()
{
return this.PlatformImpl.GetLines();
}
+ ///
+ /// Hit tests a point in the text.
+ ///
+ /// The point.
+ ///
+ /// A describing the result of the hit test.
+ ///
public TextHitTestResult HitTestPoint(Point point)
{
return this.PlatformImpl.HitTestPoint(point);
}
+ ///
+ /// Gets the bounds rectangle that the specified character occupies.
+ ///
+ /// The index of the character.
+ /// The character bounds.
public Rect HitTestTextPosition(int index)
{
return this.PlatformImpl.HitTestTextPosition(index);
}
- public IEnumerable HitTestTextRange(int index, int length, Point origin = default(Point))
+ ///
+ /// Gets the bounds rectangles that the specified text range occupies.
+ ///
+ /// The index of the first character.
+ /// The number of characters in the text range.
+ /// The character bounds.
+ public IEnumerable HitTestTextRange(int index, int length)
{
- return this.PlatformImpl.HitTestTextRange(index, length, origin);
+ return this.PlatformImpl.HitTestTextRange(index, length);
}
+ ///
+ /// Gets the size of the text, taking into account.
+ ///
+ /// The bounds box of the text.
public Size Measure()
{
return this.PlatformImpl.Measure();
}
- public void SetForegroundBrush(Brush brush, int startIndex, int count)
+ ///
+ /// Sets the foreground brush for the specified text range.
+ ///
+ /// The brush.
+ /// The start of the text range.
+ /// The length of the text range.
+ public void SetForegroundBrush(Brush brush, int startIndex, int length)
{
- this.PlatformImpl.SetForegroundBrush(brush, startIndex, count);
+ this.PlatformImpl.SetForegroundBrush(brush, startIndex, length);
}
}
}
diff --git a/Perspex.SceneGraph/Media/FormattedTextLine.cs b/Perspex.SceneGraph/Media/FormattedTextLine.cs
index 2b3f44030a..b35fd8edfb 100644
--- a/Perspex.SceneGraph/Media/FormattedTextLine.cs
+++ b/Perspex.SceneGraph/Media/FormattedTextLine.cs
@@ -1,21 +1,35 @@
// -----------------------------------------------------------------------
//
-// Copyright 2013 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex.Media
{
+ ///
+ /// Stores information about a line of .
+ ///
public class FormattedTextLine
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The length of the line, in characters.
+ /// The height of the line, in pixels.
public FormattedTextLine(int length, double height)
{
this.Length = length;
this.Height = height;
}
- public int Length { get; private set; }
+ ///
+ /// Gets the length of the line, in characters.
+ ///
+ public int Length { get; }
- public double Height { get; private set; }
+ ///
+ /// Gets the height of the line, in pixels.
+ ///
+ public double Height { get; }
}
}
diff --git a/Perspex.SceneGraph/Media/Imaging/Bitmap.cs b/Perspex.SceneGraph/Media/Imaging/Bitmap.cs
index 9e98886f0e..08ea2fe4b1 100644
--- a/Perspex.SceneGraph/Media/Imaging/Bitmap.cs
+++ b/Perspex.SceneGraph/Media/Imaging/Bitmap.cs
@@ -9,41 +9,70 @@ namespace Perspex.Media.Imaging
using Perspex.Platform;
using Splat;
+ ///
+ /// Holds a bitmap image.
+ ///
public class Bitmap : IBitmap
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The filename of the bitmap.
public Bitmap(string fileName)
{
IPlatformRenderInterface factory = Locator.Current.GetService();
this.PlatformImpl = factory.LoadBitmap(fileName);
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The width of the bitmap, in pixels.
+ /// The height of the bitmap, in pixels.
public Bitmap(int width, int height)
{
IPlatformRenderInterface factory = Locator.Current.GetService();
this.PlatformImpl = factory.CreateBitmap(width, height);
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// A platform-specific bitmap implementation.
protected Bitmap(IBitmapImpl impl)
{
this.PlatformImpl = impl;
}
+ ///
+ /// Gets the width of the bitmap, in pixels.
+ ///
public int PixelWidth
{
get { return this.PlatformImpl.PixelWidth; }
}
+ ///
+ /// Gets the height of the bitmap, in pixels.
+ ///
public int PixelHeight
{
get { return this.PlatformImpl.PixelHeight; }
}
+ ///
+ /// Gets the platform-specific bitmap implementation.
+ ///
public IBitmapImpl PlatformImpl
{
get;
private set;
}
+ ///
+ /// Saves the bitmap to a file.
+ ///
+ /// The filename.
public void Save(string fileName)
{
this.PlatformImpl.Save(fileName);
diff --git a/Perspex.SceneGraph/Media/Imaging/IBitmap.cs b/Perspex.SceneGraph/Media/Imaging/IBitmap.cs
index 3337c714fe..12d8a3da86 100644
--- a/Perspex.SceneGraph/Media/Imaging/IBitmap.cs
+++ b/Perspex.SceneGraph/Media/Imaging/IBitmap.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// Copyright 2014 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
@@ -8,14 +8,30 @@ namespace Perspex.Media.Imaging
{
using Perspex.Platform;
+ ///
+ /// Represents a bitmap image.
+ ///
public interface IBitmap
{
+ ///
+ /// Gets the width of the bitmap, in pixels.
+ ///
int PixelWidth { get; }
+ ///
+ /// Gets the height of the bitmap, in pixels.
+ ///
int PixelHeight { get; }
+ ///
+ /// Gets the platform-specific bitmap implementation.
+ ///
IBitmapImpl PlatformImpl { get; }
+ ///
+ /// Saves the bitmap to a file.
+ ///
+ /// The filename.
void Save(string fileName);
}
}
diff --git a/Perspex.SceneGraph/Media/Imaging/RenderTargetBitmap.cs b/Perspex.SceneGraph/Media/Imaging/RenderTargetBitmap.cs
index ac96dde0f3..f74cdf3c48 100644
--- a/Perspex.SceneGraph/Media/Imaging/RenderTargetBitmap.cs
+++ b/Perspex.SceneGraph/Media/Imaging/RenderTargetBitmap.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// Copyright 2013 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
@@ -10,28 +10,55 @@ namespace Perspex.Media.Imaging
using Perspex.Platform;
using Splat;
+ ///
+ /// A bitmap that holds the rendering of a .
+ ///
public class RenderTargetBitmap : Bitmap, IDisposable
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The width of the bitmap.
+ /// The height of the bitmap.
public RenderTargetBitmap(int width, int height)
: base(CreateImpl(width, height))
{
}
+ ///
+ /// Gets the platform-specific bitmap implementation.
+ ///
public new IRenderTargetBitmapImpl PlatformImpl
{
get { return (IRenderTargetBitmapImpl)base.PlatformImpl; }
}
+ ///
+ /// Renders an into the bitmap.
+ ///
+ /// The visual to render.
+ ///
+ /// Before calling this method, ensure that has been measured.
+ ///
public void Render(IVisual visual)
{
this.PlatformImpl.Render(visual);
}
+ ///
+ /// Disposes of the bitmap.
+ ///
public void Dispose()
{
this.PlatformImpl.Dispose();
}
+ ///
+ /// Creates a platform-specific imlementation for a .
+ ///
+ /// The width of the bitmap.
+ /// The height of the bitmap.
+ /// The platform-specific implementation.
private static IBitmapImpl CreateImpl(int width, int height)
{
IPlatformRenderInterface factory = Locator.Current.GetService();
diff --git a/Perspex.SceneGraph/Media/MatrixTransform.cs b/Perspex.SceneGraph/Media/MatrixTransform.cs
index 16e8f5f59d..bcf01e5b7b 100644
--- a/Perspex.SceneGraph/Media/MatrixTransform.cs
+++ b/Perspex.SceneGraph/Media/MatrixTransform.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// Copyright 2013 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
@@ -8,28 +8,47 @@ namespace Perspex.Media
{
using System;
+ ///
+ /// Transforms an according to a .
+ ///
public class MatrixTransform : Transform
{
+ ///
+ /// Defines the property.
+ ///
public static readonly PerspexProperty MatrixProperty =
PerspexProperty.Register("Matrix", Matrix.Identity);
+ ///
+ /// Initializes a new instance of the class.
+ ///
public MatrixTransform()
{
this.GetObservable(MatrixProperty).Subscribe(_ => this.RaiseChanged());
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The matrix.
public MatrixTransform(Matrix matrix)
: this()
{
this.Matrix = matrix;
}
+ ///
+ /// Gets or sets the matrix.
+ ///
public Matrix Matrix
{
get { return this.GetValue(MatrixProperty); }
set { this.SetValue(MatrixProperty, value); }
}
+ ///
+ /// Gets the matrix.
+ ///
public override Matrix Value
{
get { return this.Matrix; }
diff --git a/Perspex.SceneGraph/Media/PathMarkupParser.cs b/Perspex.SceneGraph/Media/PathMarkupParser.cs
index 6aaeaf86d8..5cd66456fd 100644
--- a/Perspex.SceneGraph/Media/PathMarkupParser.cs
+++ b/Perspex.SceneGraph/Media/PathMarkupParser.cs
@@ -12,6 +12,9 @@ namespace Perspex.Media
using System.IO;
using System.Text;
+ ///
+ /// Parses a path markup string.
+ ///
public class PathMarkupParser
{
private static readonly Dictionary Commands = new Dictionary
@@ -36,12 +39,20 @@ namespace Perspex.Media
private StreamGeometryContext context;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The geometry in which the path should be stored.
+ /// The context for .
public PathMarkupParser(StreamGeometry geometry, StreamGeometryContext context)
{
this.geometry = geometry;
this.context = context;
}
+ ///
+ /// Defines the command currently being processed.
+ ///
private enum Command
{
None,
@@ -60,6 +71,10 @@ namespace Perspex.Media
Eof,
}
+ ///
+ /// Parses the specified markup string.
+ ///
+ /// The markup string.
public void Parse(string s)
{
bool openFigure = false;
diff --git a/Perspex.SceneGraph/Media/RotateTransform.cs b/Perspex.SceneGraph/Media/RotateTransform.cs
index 8759df0bdb..2567a48e7d 100644
--- a/Perspex.SceneGraph/Media/RotateTransform.cs
+++ b/Perspex.SceneGraph/Media/RotateTransform.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// Copyright 2013 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
@@ -8,31 +8,50 @@ namespace Perspex.Media
{
using System;
+ ///
+ /// Rotates an .
+ ///
public class RotateTransform : Transform
{
+ ///
+ /// Defines the property.
+ ///
public static readonly PerspexProperty AngleProperty =
PerspexProperty.Register("Angle");
+ ///
+ /// Initializes a new instance of the class.
+ ///
public RotateTransform()
{
this.GetObservable(AngleProperty).Subscribe(_ => this.RaiseChanged());
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The angle, in degrees.
public RotateTransform(double angle)
: this()
{
this.Angle = angle;
}
+ ///
+ /// Gets or sets the angle of rotation, in degrees.
+ ///
public double Angle
{
get { return this.GetValue(AngleProperty); }
set { this.SetValue(AngleProperty, value); }
}
+ ///
+ /// Gets the tranform's .
+ ///
public override Matrix Value
{
- get { return Matrix.Rotation(Matrix.ToRadians(this.Angle)); }
+ get { return Matrix.CreateRotation(Matrix.ToRadians(this.Angle)); }
}
}
}
diff --git a/Perspex.SceneGraph/Media/SolidColorBrush.cs b/Perspex.SceneGraph/Media/SolidColorBrush.cs
index 5cfbfb94bd..9819939655 100644
--- a/Perspex.SceneGraph/Media/SolidColorBrush.cs
+++ b/Perspex.SceneGraph/Media/SolidColorBrush.cs
@@ -38,6 +38,10 @@ namespace Perspex.Media
private set;
}
+ ///
+ /// Returns a string representation of the brush.
+ ///
+ /// A string representation of the brush.
public override string ToString()
{
return this.Color.ToString();
diff --git a/Perspex.SceneGraph/Media/Stretch.cs b/Perspex.SceneGraph/Media/Stretch.cs
index 354e740f66..76fff743a8 100644
--- a/Perspex.SceneGraph/Media/Stretch.cs
+++ b/Perspex.SceneGraph/Media/Stretch.cs
@@ -6,11 +6,33 @@
namespace Perspex.Media
{
+ ///
+ /// Describes how content is resized to fill its allocated space.
+ ///
public enum Stretch
{
+ ///
+ /// The content preserves its original size.
+ ///
None,
+
+ ///
+ /// The content is resized to fill the destination dimensions. The aspect ratio is not
+ /// preserved.
+ ///
Fill,
+
+ ///
+ /// The content is resized to fit in the destination dimensions while preserving its
+ /// native aspect ratio.
+ ///
Uniform,
+
+ ///
+ /// The content is resized to completely fill the destination rectangle while preserving
+ /// its native aspect ratio. A portion of the content may not be visible if the aspect
+ /// ratio of the content does not match the aspect ratio of the allocated space.
+ ///
UniformToFill,
}
}
diff --git a/Perspex.SceneGraph/Media/SweepDirection.cs b/Perspex.SceneGraph/Media/SweepDirection.cs
index 22d51788a7..aef1facb2a 100644
--- a/Perspex.SceneGraph/Media/SweepDirection.cs
+++ b/Perspex.SceneGraph/Media/SweepDirection.cs
@@ -1,14 +1,24 @@
// -----------------------------------------------------------------------
//
-// Copyright 2013 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex.Media
{
+ ///
+ /// Defines the direction an which elliptical arc is drawn.
+ ///
public enum SweepDirection
{
+ ///
+ /// Specifies that arcs are drawn in a counter clockwise (negative-angle) direction.
+ ///
CounterClockwise,
+
+ ///
+ /// Specifies that arcs are drawn in a clockwise (positive-angle) direction.
+ ///
Clockwise,
}
}
diff --git a/Perspex.SceneGraph/Media/TextAlignment.cs b/Perspex.SceneGraph/Media/TextAlignment.cs
index 5578b0de9d..2c2c558a38 100644
--- a/Perspex.SceneGraph/Media/TextAlignment.cs
+++ b/Perspex.SceneGraph/Media/TextAlignment.cs
@@ -1,15 +1,29 @@
// -----------------------------------------------------------------------
//
-// Copyright 2014 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex.Media
{
+ ///
+ /// Defines how text is aligned.
+ ///
public enum TextAlignment
{
+ ///
+ /// The text is left-aligned.
+ ///
Left,
+
+ ///
+ /// The text is centered.
+ ///
Center,
+
+ ///
+ /// The text is right-aligned.
+ ///
Right,
}
}
diff --git a/Perspex.SceneGraph/Media/TextHitTestResult.cs b/Perspex.SceneGraph/Media/TextHitTestResult.cs
index fee1d1abc4..169ffbd97a 100644
--- a/Perspex.SceneGraph/Media/TextHitTestResult.cs
+++ b/Perspex.SceneGraph/Media/TextHitTestResult.cs
@@ -1,17 +1,29 @@
// -----------------------------------------------------------------------
//
-// Copyright 2014 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex.Media
{
+ ///
+ /// Holds a hit test result from a .
+ ///
public class TextHitTestResult
{
+ ///
+ /// Gets or sets a value indicating whether the point is inside the bounds of the text.
+ ///
public bool IsInside { get; set; }
+ ///
+ /// Gets the index of the hit character in the text.
+ ///
public int TextPosition { get; set; }
+ ///
+ /// Gets a value indicating whether the hit is on the trailing edge of the character.
+ ///
public bool IsTrailing { get; set; }
}
}
diff --git a/Perspex.SceneGraph/Media/Transform.cs b/Perspex.SceneGraph/Media/Transform.cs
index af6cb16832..9523e23687 100644
--- a/Perspex.SceneGraph/Media/Transform.cs
+++ b/Perspex.SceneGraph/Media/Transform.cs
@@ -9,12 +9,24 @@ namespace Perspex.Media
using System;
using Perspex.Animation;
+ ///
+ /// Represents a transform on an .
+ ///
public abstract class Transform : Animatable
{
+ ///
+ /// Raised when the transform changes.
+ ///
public event EventHandler Changed;
+ ///
+ /// Gets the tranform's .
+ ///
public abstract Matrix Value { get; }
+ ///
+ /// Raises the event.
+ ///
protected void RaiseChanged()
{
if (this.Changed != null)
diff --git a/Perspex.SceneGraph/Media/TranslateTransform.cs b/Perspex.SceneGraph/Media/TranslateTransform.cs
index 787968e814..8867516230 100644
--- a/Perspex.SceneGraph/Media/TranslateTransform.cs
+++ b/Perspex.SceneGraph/Media/TranslateTransform.cs
@@ -8,20 +8,37 @@ namespace Perspex.Media
{
using System;
+ ///
+ /// Translates (moves) an .
+ ///
public class TranslateTransform : Transform
{
+ ///
+ /// Defines the property.
+ ///
public static readonly PerspexProperty XProperty =
PerspexProperty.Register("X");
+ ///
+ /// Defines the property.
+ ///
public static readonly PerspexProperty YProperty =
PerspexProperty.Register("Y");
+ ///
+ /// Initializes a new instance of the class.
+ ///
public TranslateTransform()
{
this.GetObservable(XProperty).Subscribe(_ => this.RaiseChanged());
this.GetObservable(YProperty).Subscribe(_ => this.RaiseChanged());
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Gets the horizontal offset of the translate.
+ /// Gets the vertical offset of the translate.
public TranslateTransform(double x, double y)
: this()
{
@@ -29,21 +46,30 @@ namespace Perspex.Media
this.Y = y;
}
+ ///
+ /// Gets the horizontal offset of the translate.
+ ///
public double X
{
get { return this.GetValue(XProperty); }
set { this.SetValue(XProperty, value); }
}
+ ///
+ /// Gets the vertical offset of the translate.
+ ///
public double Y
{
get { return this.GetValue(YProperty); }
set { this.SetValue(YProperty, value); }
}
+ ///
+ /// Gets the tranform's .
+ ///
public override Matrix Value
{
- get { return Matrix.Translation(this.X, this.Y); }
+ get { return Matrix.CreateTranslation(this.X, this.Y); }
}
}
}
diff --git a/Perspex.SceneGraph/Origin.cs b/Perspex.SceneGraph/Origin.cs
index 948ee9df19..0da413cd00 100644
--- a/Perspex.SceneGraph/Origin.cs
+++ b/Perspex.SceneGraph/Origin.cs
@@ -6,44 +6,79 @@
namespace Perspex
{
- using System;
- using System.Globalization;
-
+ ///
+ /// Defines the reference point units of an .
+ ///
public enum OriginUnit
{
+ ///
+ /// The origin's point is a percentage.
+ ///
Percent,
+
+ ///
+ /// The origin's point is in pixels.
+ ///
Pixels,
}
+ ///
+ /// Defines an origin for a .
+ ///
public struct Origin
{
+ ///
+ /// The default origin, which is the center of the control.
+ ///
public static readonly Origin Default = new Origin(0.5, 0.5, OriginUnit.Percent);
private Point point;
private OriginUnit unit;
+ ///
+ /// Initializes a new instance of the struct.
+ ///
+ /// The X point.
+ /// The Y point
+ /// The origin unit.
public Origin(double x, double y, OriginUnit unit)
: this(new Point(x, y), unit)
{
}
+ ///
+ /// Initializes a new instance of the struct.
+ ///
+ /// The origin point.
+ /// The origin unit.
public Origin(Point point, OriginUnit unit)
{
this.point = point;
this.unit = unit;
}
+ ///
+ /// Gets the origin point.
+ ///
public Point Point
{
get { return this.point; }
}
+ ///
+ /// Gets the origin unit.
+ ///
public OriginUnit Unit
{
get { return this.unit; }
}
+ ///
+ /// Converts an into pixels.
+ ///
+ /// The size of the visual.
+ /// The origin point in pixels.
public Point ToPixels(Size size)
{
return this.unit == OriginUnit.Pixels ?
diff --git a/Perspex.SceneGraph/Perspex.SceneGraph.csproj b/Perspex.SceneGraph/Perspex.SceneGraph.csproj
index d259b5bdc9..d6872ef6cc 100644
--- a/Perspex.SceneGraph/Perspex.SceneGraph.csproj
+++ b/Perspex.SceneGraph/Perspex.SceneGraph.csproj
@@ -52,6 +52,7 @@
+
@@ -64,7 +65,6 @@
-
diff --git a/Perspex.SceneGraph/Platform/IBitmapImpl.cs b/Perspex.SceneGraph/Platform/IBitmapImpl.cs
index b6ae7a7ff3..e31e78be0e 100644
--- a/Perspex.SceneGraph/Platform/IBitmapImpl.cs
+++ b/Perspex.SceneGraph/Platform/IBitmapImpl.cs
@@ -6,12 +6,25 @@
namespace Perspex.Platform
{
+ ///
+ /// Defines the platform-specific interface for a .
+ ///
public interface IBitmapImpl
{
+ ///
+ /// Gets the width of the bitmap, in pixels.
+ ///
int PixelWidth { get; }
+ ///
+ /// Gets the height of the bitmap, in pixels.
+ ///
int PixelHeight { get; }
+ ///
+ /// Saves the bitmap to a file.
+ ///
+ /// The filename.
void Save(string fileName);
}
}
diff --git a/Perspex.SceneGraph/Platform/IFormattedTextImpl.cs b/Perspex.SceneGraph/Platform/IFormattedTextImpl.cs
index eb1db49959..dd64f6dcb4 100644
--- a/Perspex.SceneGraph/Platform/IFormattedTextImpl.cs
+++ b/Perspex.SceneGraph/Platform/IFormattedTextImpl.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// Copyright 2014 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
@@ -10,20 +10,60 @@ namespace Perspex.Platform
using System.Collections.Generic;
using Perspex.Media;
+ ///
+ /// Defines the platform-specific interface for .
+ ///
public interface IFormattedTextImpl : IDisposable
{
+ ///
+ /// Gets or sets the constraint of the text.
+ ///
Size Constraint { get; set; }
+ ///
+ /// Gets the lines in the text.
+ ///
+ ///
+ /// A collection of objects.
+ ///
IEnumerable GetLines();
+ ///
+ /// Hit tests a point in the text.
+ ///
+ /// The point.
+ ///
+ /// A describing the result of the hit test.
+ ///
TextHitTestResult HitTestPoint(Point point);
+ ///
+ /// Gets the bounds rectangle that the specified character occupies.
+ ///
+ /// The index of the character.
+ /// The character bounds.
Rect HitTestTextPosition(int index);
- IEnumerable HitTestTextRange(int index, int length, Point origin);
+ ///
+ /// Gets the bounds rectangles that the specified text range occupies.
+ ///
+ /// The index of the first character.
+ /// The number of characters in the text range.
+ /// The character bounds.
+ IEnumerable HitTestTextRange(int index, int length);
+ ///
+ /// Gets the size of the text, taking into account.
+ ///
+ /// The bounds box of the text.
Size Measure();
- void SetForegroundBrush(Brush brush, int startIndex, int count);
+ ///
+ /// Sets the foreground brush for the specified text range.
+ ///
+ /// The brush.
+ /// The start of the text range.
+ /// The length of the text range.
+ void SetForegroundBrush(Brush brush, int startIndex, int length);
}
}
diff --git a/Perspex.SceneGraph/Platform/IGeometryImpl.cs b/Perspex.SceneGraph/Platform/IGeometryImpl.cs
index 02f4bf8fbd..2400f89dc5 100644
--- a/Perspex.SceneGraph/Platform/IGeometryImpl.cs
+++ b/Perspex.SceneGraph/Platform/IGeometryImpl.cs
@@ -1,17 +1,31 @@
// -----------------------------------------------------------------------
//
-// Copyright 2014 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex.Platform
{
+ ///
+ /// Defines the platform-specific interface for .
+ ///
public interface IGeometryImpl
{
+ ///
+ /// Gets the geometry's bounding rectangle.
+ ///
Rect Bounds { get; }
+ ///
+ /// Gets or sets a transform to apply to the geometry.
+ ///
Matrix Transform { get; set; }
+ ///
+ /// Gets the geometry's bounding rectangle with the specified stroke thickness.
+ ///
+ /// The stroke thickness.
+ /// The bounding rectangle.
Rect GetRenderBounds(double strokeThickness);
}
}
diff --git a/Perspex.SceneGraph/Platform/IPlatformRenderInterface.cs b/Perspex.SceneGraph/Platform/IPlatformRenderInterface.cs
index 7f7c1bb562..762f78c355 100644
--- a/Perspex.SceneGraph/Platform/IPlatformRenderInterface.cs
+++ b/Perspex.SceneGraph/Platform/IPlatformRenderInterface.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// Copyright 2014 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
@@ -8,24 +8,65 @@ namespace Perspex.Platform
{
using Perspex.Media;
+ ///
+ /// Defines the main platform-specific interface for the rendering subsystem.
+ ///
public interface IPlatformRenderInterface
{
+ ///
+ /// Creates a bitmap implementation.
+ ///
+ /// The width of the bitmap.
+ /// The height of the bitmap.
+ /// An .
IBitmapImpl CreateBitmap(int width, int height);
+ ///
+ /// Creates a formatted text implementation.
+ ///
+ /// The text.
+ /// The font family.
+ /// The font size.
+ /// The font style.
+ /// The text alignment.
+ /// The font weight.
+ /// An .
IFormattedTextImpl CreateFormattedText(
string text,
- string fontFamily,
+ string fontFamilyName,
double fontSize,
FontStyle fontStyle,
TextAlignment textAlignment,
FontWeight fontWeight);
+ ///
+ /// Creates a stream geometry implementation.
+ ///
+ /// An .
IStreamGeometryImpl CreateStreamGeometry();
+ ///
+ /// Creates a renderer.
+ ///
+ /// The platform handle for the renderer.
+ /// The initial width of the render.
+ /// The initial height of the render.
+ /// An .
IRenderer CreateRenderer(IPlatformHandle handle, double width, double height);
+ ///
+ /// Creates a render target bitmap implementation.
+ ///
+ /// The width of the bitmap.
+ /// The height of the bitmap.
+ /// An .
IRenderTargetBitmapImpl CreateRenderTargetBitmap(int width, int height);
+ ///
+ /// Loads a bitmap implementation from a file..
+ ///
+ /// The filename of the bitmap.
+ /// An .
IBitmapImpl LoadBitmap(string fileName);
}
}
diff --git a/Perspex.SceneGraph/Platform/IRenderTargetBitmapImpl.cs b/Perspex.SceneGraph/Platform/IRenderTargetBitmapImpl.cs
index 7478de1e60..3d006c9579 100644
--- a/Perspex.SceneGraph/Platform/IRenderTargetBitmapImpl.cs
+++ b/Perspex.SceneGraph/Platform/IRenderTargetBitmapImpl.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// Copyright 2014 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
@@ -8,8 +8,19 @@ namespace Perspex.Platform
{
using System;
+ ///
+ /// Defines the platform-specific interface for a
+ /// .
+ ///
public interface IRenderTargetBitmapImpl : IBitmapImpl, IDisposable
{
+ ///
+ /// Renders an into the bitmap.
+ ///
+ /// The visual to render.
+ ///
+ /// Before calling this method, ensure that has been measured.
+ ///
void Render(IVisual visual);
}
}
diff --git a/Perspex.SceneGraph/Platform/IRenderer.cs b/Perspex.SceneGraph/Platform/IRenderer.cs
index 1724e5f51d..7a9d40ec78 100644
--- a/Perspex.SceneGraph/Platform/IRenderer.cs
+++ b/Perspex.SceneGraph/Platform/IRenderer.cs
@@ -1,13 +1,20 @@
// -----------------------------------------------------------------------
//
-// Copyright 2014 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex.Platform
{
- using System;
-
+ ///
+ /// Defines a renderer.
+ ///
+ ///
+ /// The interface used to render s. You will usually want to inherit from
+ /// rather than implementing the whole interface
+ /// as RenderBase has a default implementation for the non-platform specific parts of a
+ /// renderer.
+ ///
public interface IRenderer
{
///
diff --git a/Perspex.SceneGraph/Platform/IStreamGeometryImpl.cs b/Perspex.SceneGraph/Platform/IStreamGeometryImpl.cs
index 8424306615..fa5322c00a 100644
--- a/Perspex.SceneGraph/Platform/IStreamGeometryImpl.cs
+++ b/Perspex.SceneGraph/Platform/IStreamGeometryImpl.cs
@@ -1,15 +1,28 @@
// -----------------------------------------------------------------------
//
-// Copyright 2014 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex.Platform
{
+ ///
+ /// Defines the platform-specific interface for a .
+ ///
public interface IStreamGeometryImpl : IGeometryImpl
{
+ ///
+ /// Clones the geometry.
+ ///
+ /// A cloned geometry.
IStreamGeometryImpl Clone();
+ ///
+ /// Opens the geometry to start defining it.
+ ///
+ ///
+ /// An which can be used to define the geometry.
+ ///
IStreamGeometryContextImpl Open();
}
}
diff --git a/Perspex.SceneGraph/Point.cs b/Perspex.SceneGraph/Point.cs
index 78186dba86..917ebc749a 100644
--- a/Perspex.SceneGraph/Point.cs
+++ b/Perspex.SceneGraph/Point.cs
@@ -134,8 +134,8 @@ namespace Perspex
public static Point operator *(Point point, Matrix matrix)
{
return new Point(
- (point.X * matrix.M11) + (point.Y * matrix.M21) + matrix.OffsetX,
- (point.X * matrix.M12) + (point.Y * matrix.M22) + matrix.OffsetY);
+ (point.X * matrix.M11) + (point.Y * matrix.M21) + matrix.M31,
+ (point.X * matrix.M12) + (point.Y * matrix.M22) + matrix.M32);
}
///
diff --git a/Perspex.SceneGraph/Rect.cs b/Perspex.SceneGraph/Rect.cs
index 86c4b51ce5..3f797a903e 100644
--- a/Perspex.SceneGraph/Rect.cs
+++ b/Perspex.SceneGraph/Rect.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// Copyright 2014 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
@@ -221,6 +221,12 @@ namespace Perspex
return !(left == right);
}
+ ///
+ /// Multiplies a rectangle by a vector.
+ ///
+ /// The rectangle.
+ /// The vector scale.
+ /// The scaled rectangle.
public static Rect operator *(Rect rect, Vector scale)
{
double centerX = rect.x + (rect.width / 2);
@@ -234,11 +240,23 @@ namespace Perspex
height);
}
+ ///
+ /// Transforms a rectangle by a matrix and returns the axis-aligned bounding box.
+ ///
+ /// The rectangle.
+ /// The matrix.
+ /// The axis-aligned bounding box.
public static Rect operator *(Rect rect, Matrix matrix)
{
return new Rect(rect.TopLeft * matrix, rect.BottomRight * matrix);
}
+ ///
+ /// Divides a rectangle by a vector.
+ ///
+ /// The rectangle.
+ /// The vector scale.
+ /// The scaled rectangle.
public static Rect operator /(Rect rect, Vector scale)
{
double centerX = rect.x + (rect.width / 2);
@@ -263,6 +281,11 @@ namespace Perspex
p.Y >= this.y && p.Y < this.y + this.height;
}
+ ///
+ /// Centers another rectangle in this rectangle.
+ ///
+ /// The rectangle to center.
+ /// The centered rectangle.
public Rect CenterIn(Rect rect)
{
return new Rect(
@@ -318,6 +341,11 @@ namespace Perspex
this.Size.Deflate(thickness));
}
+ ///
+ /// Returns a boolean indicating whether the given object is equal to this rectangle.
+ ///
+ /// The object to compare against.
+ /// True if the object is equal to this rectangle; false otherwise.
public override bool Equals(object obj)
{
if (obj is Rect)
@@ -328,6 +356,10 @@ namespace Perspex
return false;
}
+ ///
+ /// Returns the hash code for this instance.
+ ///
+ /// The hash code.
public override int GetHashCode()
{
unchecked
@@ -341,6 +373,11 @@ namespace Perspex
}
}
+ ///
+ /// Gets the intersection of two rectangles.
+ ///
+ /// The other rectangle.
+ /// The intersection.
public Rect Intersect(Rect rect)
{
double x = Math.Max(this.x, rect.x);
diff --git a/Perspex.SceneGraph/Rendering/IRenderManager.cs b/Perspex.SceneGraph/Rendering/IRenderManager.cs
index 72827e4080..7dfdec6ac1 100644
--- a/Perspex.SceneGraph/Rendering/IRenderManager.cs
+++ b/Perspex.SceneGraph/Rendering/IRenderManager.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// Copyright 2013 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
@@ -9,12 +9,25 @@ namespace Perspex.Rendering
using System;
using System.Reactive;
+ ///
+ /// Defines the interface for a .
+ ///
public interface IRenderManager
{
+ ///
+ /// Gets an observable that is fired whenever a render is required.
+ ///
IObservable RenderNeeded { get; }
+ ///
+ /// Invalidates the render for the specified visual and raises .
+ ///
+ /// The visual.
void InvalidateRender(IVisual visual);
+ ///
+ /// Called when rendering is finished.
+ ///
void RenderFinished();
}
}
diff --git a/Perspex.SceneGraph/Rendering/IRenderRoot.cs b/Perspex.SceneGraph/Rendering/IRenderRoot.cs
index aff19286e1..10bbd366f3 100644
--- a/Perspex.SceneGraph/Rendering/IRenderRoot.cs
+++ b/Perspex.SceneGraph/Rendering/IRenderRoot.cs
@@ -1,6 +1,6 @@
// -----------------------------------------------------------------------
//
-// Copyright 2013 MIT Licence. See licence.md for more information.
+// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
@@ -8,12 +8,26 @@ namespace Perspex.Rendering
{
using Perspex.Platform;
+ ///
+ /// Represents the root of a renderable tree.
+ ///
public interface IRenderRoot
{
+ ///
+ /// Gets the renderer for the tree.
+ ///
IRenderer Renderer { get; }
+ ///
+ /// Gets the render manager which schedules renders.
+ ///
IRenderManager RenderManager { get; }
+ ///
+ /// Translates a point to screen co-ordinates.
+ ///
+ /// The point.
+ /// The point in screen co-ordinates.
Point TranslatePointToScreen(Point p);
}
}
diff --git a/Perspex.SceneGraph/Rendering/RenderManager.cs b/Perspex.SceneGraph/Rendering/RenderManager.cs
index 081b570299..3f0ad7b4bb 100644
--- a/Perspex.SceneGraph/Rendering/RenderManager.cs
+++ b/Perspex.SceneGraph/Rendering/RenderManager.cs
@@ -10,22 +10,35 @@ namespace Perspex.Rendering
using System.Reactive;
using System.Reactive.Subjects;
+ ///
+ /// Schedules the rendering of a tree.
+ ///
public class RenderManager : IRenderManager
{
private Subject renderNeeded = new Subject();
private bool renderQueued;
+ ///
+ /// Gets an observable that is fired whenever a render is required.
+ ///
public IObservable RenderNeeded
{
get { return this.renderNeeded; }
}
+ ///
+ /// Gets a valuue indicating whether a render is queued.
+ ///
public bool RenderQueued
{
get { return this.renderQueued; }
}
+ ///
+ /// Invalidates the render for the specified visual and raises .
+ ///
+ /// The visual.
public void InvalidateRender(IVisual visual)
{
if (!this.renderQueued)
@@ -35,6 +48,9 @@ namespace Perspex.Rendering
}
}
+ ///
+ /// Called when rendering is finished.
+ ///
public void RenderFinished()
{
this.renderQueued = false;
diff --git a/Perspex.SceneGraph/Rendering/RendererBase.cs b/Perspex.SceneGraph/Rendering/RendererBase.cs
index ccd00736b6..6ad42eedb7 100644
--- a/Perspex.SceneGraph/Rendering/RendererBase.cs
+++ b/Perspex.SceneGraph/Rendering/RendererBase.cs
@@ -71,16 +71,16 @@ namespace Perspex.Rendering
if (visual.IsVisible && opacity > 0)
{
// Translate any existing transform into this controls coordinate system.
- Matrix offset = Matrix.Translation(visual.Bounds.Position);
+ Matrix offset = Matrix.CreateTranslation(visual.Bounds.Position);
transform = offset * transform * -offset;
// Update the current offset.
- translation *= Matrix.Translation(visual.Bounds.Position);
+ translation *= Matrix.CreateTranslation(visual.Bounds.Position);
// Apply the control's render transform, if any.
if (visual.RenderTransform != null)
{
- offset = Matrix.Translation(visual.TransformOrigin.ToPixels(visual.Bounds.Size));
+ offset = Matrix.CreateTranslation(visual.TransformOrigin.ToPixels(visual.Bounds.Size));
transform *= -offset * visual.RenderTransform.Value * offset;
}
diff --git a/Perspex.SceneGraph/Size.cs b/Perspex.SceneGraph/Size.cs
index e96dadf706..f73d976087 100644
--- a/Perspex.SceneGraph/Size.cs
+++ b/Perspex.SceneGraph/Size.cs
@@ -193,7 +193,7 @@ namespace Perspex
///
/// Returns the string representation of the size.
///
- /// The string representation of the size
+ /// The string representation of the size.
public override string ToString()
{
return string.Format(CultureInfo.InvariantCulture, "{0}, {1}", this.width, this.height);
diff --git a/Perspex.SceneGraph/Thickness.cs b/Perspex.SceneGraph/Thickness.cs
index 42e60b250c..7673c239e8 100644
--- a/Perspex.SceneGraph/Thickness.cs
+++ b/Perspex.SceneGraph/Thickness.cs
@@ -8,6 +8,9 @@ namespace Perspex
{
using System;
+ ///
+ /// Describes the thickness of a frame around a rectangle.
+ ///
public struct Thickness
{
///
@@ -152,6 +155,13 @@ namespace Perspex
a.Bottom + b.Bottom);
}
+ ///
+ /// Checks for equality between a thickness and an object.
+ ///
+ /// The object.
+ ///
+ /// True if is a size that equals the current size.
+ ///
public override bool Equals(object obj)
{
if (obj is Thickness)
@@ -166,6 +176,10 @@ namespace Perspex
return false;
}
+ ///
+ /// Returns a hash code for a .
+ ///
+ /// The hash code.
public override int GetHashCode()
{
unchecked
@@ -179,6 +193,10 @@ namespace Perspex
}
}
+ ///
+ /// Returns the string representation of the thickness.
+ ///
+ /// The string representation of the thickness.
public override string ToString()
{
return string.Format("{0},{1},{2},{3}", this.left, this.top, this.right, this.bottom);
diff --git a/Perspex.SceneGraph/Visual.cs b/Perspex.SceneGraph/Visual.cs
index 03473ce7bb..13fb61aec4 100644
--- a/Perspex.SceneGraph/Visual.cs
+++ b/Perspex.SceneGraph/Visual.cs
@@ -262,7 +262,7 @@ namespace Perspex
{
var thisOffset = GetOffsetFromRoot(this).Item2;
var thatOffset = GetOffsetFromRoot(visual).Item2;
- return Matrix.Translation(-thatOffset) * Matrix.Translation(thisOffset);
+ return Matrix.CreateTranslation(-thatOffset) * Matrix.CreateTranslation(thisOffset);
}
///
diff --git a/Perspex.SceneGraph/VisualTree/VisualExtensions.cs b/Perspex.SceneGraph/VisualTree/VisualExtensions.cs
index 3385c2c20f..ae3068d6c5 100644
--- a/Perspex.SceneGraph/VisualTree/VisualExtensions.cs
+++ b/Perspex.SceneGraph/VisualTree/VisualExtensions.cs
@@ -10,8 +10,16 @@ namespace Perspex.VisualTree
using System.Collections.Generic;
using System.Linq;
+ ///
+ /// Provides extension methods for working with visual tree.
+ ///
public static class VisualExtensions
{
+ ///
+ /// Enumerates the ancestors of an in the visual tree.
+ ///
+ /// The visual.
+ /// The visual's ancestors.
public static IEnumerable GetVisualAncestors(this IVisual visual)
{
Contract.Requires(visual != null);
@@ -25,6 +33,11 @@ namespace Perspex.VisualTree
}
}
+ ///
+ /// Enumerates an and its ancestors in the visual tree.
+ ///
+ /// The visual.
+ /// The visual and its ancestors.
public static IEnumerable GetSelfAndVisualAncestors(this IVisual visual)
{
yield return visual;
@@ -35,6 +48,12 @@ namespace Perspex.VisualTree
}
}
+ ///
+ /// Gets the first visual in the visual tree whose bounds contain a point.
+ ///
+ /// The root visual to test.
+ /// The point.
+ /// The visuals at the requested point.
public static IVisual GetVisualAt(this IVisual visual, Point p)
{
Contract.Requires(visual != null);
@@ -42,6 +61,12 @@ namespace Perspex.VisualTree
return visual.GetVisualsAt(p).FirstOrDefault();
}
+ ///
+ /// Enumerates the visuals in the visual tree whose bounds contain a point.
+ ///
+ /// The root visual to test.
+ /// The point.
+ /// The visuals at the requested point.
public static IEnumerable GetVisualsAt(this IVisual visual, Point p)
{
Contract.Requires(visual != null);
@@ -65,11 +90,21 @@ namespace Perspex.VisualTree
}
}
+ ///
+ /// Enumerates the children of an in the visual tree.
+ ///
+ /// The visual.
+ /// The visual children.
public static IEnumerable GetVisualChildren(this IVisual visual)
{
return visual.VisualChildren;
}
+ ///
+ /// Enumerates the descendents of an in the visual tree.
+ ///
+ /// The visual.
+ /// The visual's ancestors.
public static IEnumerable GetVisualDescendents(this IVisual visual)
{
foreach (IVisual child in visual.VisualChildren)
@@ -83,6 +118,11 @@ namespace Perspex.VisualTree
}
}
+ ///
+ /// Enumerates an and its descendents in the visual tree.
+ ///
+ /// The visual.
+ /// The visual and its ancestors.
public static IEnumerable GetSelfAndVisualDescendents(this IVisual visual)
{
yield return visual;
@@ -93,16 +133,36 @@ namespace Perspex.VisualTree
}
}
+ ///
+ /// Gets the visual parent of an .
+ ///
+ /// The visual.
+ /// The parent, or null if the visual is unparented.
public static IVisual GetVisualParent(this IVisual visual)
{
return visual.VisualParent;
}
+ ///
+ /// Gets the visual parent of an .
+ ///
+ /// The type of the visual parent.
+ /// The visual.
+ ///
+ /// The parent, or null if the visual is unparented or its parent is not of type .
+ ///
public static T GetVisualParent(this IVisual visual) where T : class
{
return visual.VisualParent as T;
}
+ ///
+ /// Gets the root visual for an .
+ ///
+ /// The visual.
+ ///
+ /// The root visual or null if the visual is not rooted.
+ ///
public static IVisual GetVisualRoot(this IVisual visual)
{
Contract.Requires(visual != null);
@@ -118,7 +178,16 @@ namespace Perspex.VisualTree
return visual;
}
- public static bool IsVisualParentOf(this IVisual visual, IVisual target)
+ ///
+ /// Tests whether an is an ancestor of another visual.
+ ///
+ /// The visual.
+ /// The potential descendent.
+ ///
+ /// True if is an ancestor of ;
+ /// otherwise false.
+ ///
+ public static bool IsVisualAncestorOf(this IVisual visual, IVisual target)
{
return target.GetVisualAncestors().Any(x => x == visual);
}
diff --git a/Windows/Perspex.Direct2D1/Media/FormattedTextImpl.cs b/Windows/Perspex.Direct2D1/Media/FormattedTextImpl.cs
index ff96956e49..93aedf23e6 100644
--- a/Windows/Perspex.Direct2D1/Media/FormattedTextImpl.cs
+++ b/Windows/Perspex.Direct2D1/Media/FormattedTextImpl.cs
@@ -107,14 +107,9 @@ namespace Perspex.Direct2D1.Media
return new Rect(result.Left, result.Top, result.Width, result.Height);
}
- public IEnumerable HitTestTextRange(int index, int length, Point origin)
+ public IEnumerable HitTestTextRange(int index, int length)
{
- var result = this.TextLayout.HitTestTextRange(
- index,
- length,
- (float)origin.X,
- (float)origin.Y);
-
+ var result = this.TextLayout.HitTestTextRange(index, length, 0, 0);
return result.Select(x => new Rect(x.Left, x.Top, x.Width, x.Height));
}
diff --git a/Windows/Perspex.Direct2D1/PrimitiveExtensions.cs b/Windows/Perspex.Direct2D1/PrimitiveExtensions.cs
index d28bd88cd6..ef44de77db 100644
--- a/Windows/Perspex.Direct2D1/PrimitiveExtensions.cs
+++ b/Windows/Perspex.Direct2D1/PrimitiveExtensions.cs
@@ -104,8 +104,8 @@ namespace Perspex.Direct2D1
(float)matrix.M12,
(float)matrix.M21,
(float)matrix.M22,
- (float)matrix.OffsetX,
- (float)matrix.OffsetY);
+ (float)matrix.M31,
+ (float)matrix.M32);
}
///