diff --git a/Perspex.Layout/LayoutHelper.cs b/Perspex.Layout/LayoutHelper.cs index dc365685ae..95e8750cd9 100644 --- a/Perspex.Layout/LayoutHelper.cs +++ b/Perspex.Layout/LayoutHelper.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,20 @@ namespace Perspex.Layout { using System; + /// + /// Provides helper methods needed for layout. + /// public static class LayoutHelper { + /// + /// Calculates a control's size based on its , + /// , , + /// , and + /// . + /// + /// The control. + /// The space available for the control. + /// The control's size. public static Size ApplyLayoutConstraints(ILayoutable control, Size constraints) { double width = (control.Width > 0) ? control.Width : constraints.Width; diff --git a/Perspex.Layout/LayoutManager.cs b/Perspex.Layout/LayoutManager.cs index e2bdaf8fba..e6c6628993 100644 --- a/Perspex.Layout/LayoutManager.cs +++ b/Perspex.Layout/LayoutManager.cs @@ -302,18 +302,37 @@ namespace Perspex.Layout } } + /// + /// An item to be layed-out. + /// private class Item : IComparable { + /// + /// Initializes a new instance of the class. + /// + /// The control. + /// The control's distance from the layout root. public Item(ILayoutable control, int distance) { this.Control = control; this.Distance = distance; } - public ILayoutable Control { get; private set; } - - public int Distance { get; private set; } - + /// + /// Gets the control. + /// + public ILayoutable Control { get; } + + /// + /// Gets the control's distance from the layout root. + /// + public int Distance { get; } + + /// + /// Compares the distance of two items. + /// + /// The other item/ + /// The comparison. public int CompareTo(Item other) { return this.Distance - other.Distance; diff --git a/Perspex.SceneGraph/VisualTree/BoundsTracker.cs b/Perspex.SceneGraph/VisualTree/BoundsTracker.cs index 35dd95b867..be81c4ebe4 100644 --- a/Perspex.SceneGraph/VisualTree/BoundsTracker.cs +++ b/Perspex.SceneGraph/VisualTree/BoundsTracker.cs @@ -11,13 +11,30 @@ namespace Perspex.VisualTree using System.Linq; using System.Reactive.Linq; + /// + /// Tracks the bounds of a control. + /// + /// + /// This class is used by Adorners to track the control that the adorner is attached to. + /// public class BoundsTracker { + /// + /// Starts tracking the specified visual. + /// + /// The visual. + /// An observable that returns the tracked bounds. public IObservable Track(Visual visual) { return this.Track(visual, (Visual)visual.GetVisualRoot()); } + /// + /// Starts tracking the specified visual relative to another control. + /// + /// The visual. + /// The control that the tracking should be relative to. + /// An observable that returns the tracked bounds. public IObservable Track(Visual visual, Visual relativeTo) { var visuals = visual.GetSelfAndVisualAncestors() @@ -36,6 +53,11 @@ namespace Perspex.VisualTree return Observable.Select(bounds, x => new TransformedBounds((Rect)x, (Rect)new Rect(), (Matrix)Matrix.Identity)); } + /// + /// Sums a collection of rectangles. + /// + /// The collection of rectangles. + /// The summed rectangle. private static Rect ExtractBounds(IList rects) { var position = rects.Select(x => x.Position).Aggregate((a, b) => a + b); diff --git a/Perspex.SceneGraph/VisualTree/TransformedBounds.cs b/Perspex.SceneGraph/VisualTree/TransformedBounds.cs index b241d88a43..a7f9165486 100644 --- a/Perspex.SceneGraph/VisualTree/TransformedBounds.cs +++ b/Perspex.SceneGraph/VisualTree/TransformedBounds.cs @@ -6,8 +6,17 @@ namespace Perspex.VisualTree { + /// + /// Holds information about the bounds of a control, together with a transform and a clip/ + /// public class TransformedBounds { + /// + /// Initializes a new instance of the class. + /// + /// The control's bounds. + /// The control's clip rectangle. + /// The control's transform. public TransformedBounds(Rect bounds, Rect clip, Matrix transform) { this.Bounds = bounds; @@ -15,10 +24,19 @@ namespace Perspex.VisualTree this.Transform = transform; } + /// + /// Gets the control's bounds. + /// public Rect Bounds { get; } + /// + /// Gets the control's clip rectangle. + /// public Rect Clip { get; } + /// + /// Gets the control's transform. + /// public Matrix Transform { get; } } } diff --git a/Windows/Perspex.Direct2D1/Media/GeometryImpl.cs b/Windows/Perspex.Direct2D1/Media/GeometryImpl.cs index f93911d553..0cd3952579 100644 --- a/Windows/Perspex.Direct2D1/Media/GeometryImpl.cs +++ b/Windows/Perspex.Direct2D1/Media/GeometryImpl.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,25 +10,40 @@ namespace Perspex.Direct2D1.Media using SharpDX.Direct2D1; using Splat; + /// + /// The platform-specific interface for . + /// public abstract class GeometryImpl : IGeometryImpl { private TransformedGeometry transformed; + /// + /// Gets the geometry's bounding rectangle. + /// public abstract Rect Bounds { get; } + /// + /// Gets the geomentry without any transforms applied. + /// public abstract Geometry DefiningGeometry { get; } + /// + /// Gets the Direct2D . + /// public Geometry Geometry { get { return this.transformed ?? this.DefiningGeometry; } } + /// + /// Gets or sets the transform for the geometry. + /// public Matrix Transform { get @@ -60,6 +75,11 @@ namespace Perspex.Direct2D1.Media } } + /// + /// Gets the geometry's bounding rectangle with the specified stroke thickness. + /// + /// The stroke thickness. + /// The bounding rectangle. public Rect GetRenderBounds(double strokeThickness) { if (this.transformed != null) diff --git a/Windows/Perspex.Direct2D1/Media/Imaging/BitmapImpl.cs b/Windows/Perspex.Direct2D1/Media/Imaging/BitmapImpl.cs index af09444545..40518a553a 100644 --- a/Windows/Perspex.Direct2D1/Media/Imaging/BitmapImpl.cs +++ b/Windows/Perspex.Direct2D1/Media/Imaging/BitmapImpl.cs @@ -11,12 +11,20 @@ namespace Perspex.Direct2D1.Media using Perspex.Platform; using SharpDX.WIC; + /// + /// A Direct2D implementation of a . + /// public class BitmapImpl : IBitmapImpl { private ImagingFactory factory; private SharpDX.Direct2D1.Bitmap direct2D; + /// + /// Initializes a new instance of the class. + /// + /// The WIC imaging factory to use. + /// The filename of the bitmap to load. public BitmapImpl(ImagingFactory factory, string fileName) { this.factory = factory; @@ -27,6 +35,12 @@ namespace Perspex.Direct2D1.Media } } + /// + /// Initializes a new instance of the class. + /// + /// The WIC imaging factory to use. + /// The width of the bitmap. + /// The height of the bitmap. public BitmapImpl(ImagingFactory factory, int width, int height) { this.factory = factory; @@ -38,22 +52,36 @@ namespace Perspex.Direct2D1.Media BitmapCreateCacheOption.CacheOnLoad); } - public int PixelHeight + /// + /// Gets the width of the bitmap, in pixels. + /// + public int PixelWidth { - get { return this.WicImpl.Size.Width; } + get { return this.WicImpl.Size.Height; } } - public int PixelWidth + /// + /// Gets the height of the bitmap, in pixels. + /// + public int PixelHeight { - get { return this.WicImpl.Size.Height; } + get { return this.WicImpl.Size.Width; } } + /// + /// Gets the WIC implementation of the bitmap. + /// public Bitmap WicImpl { get; private set; } + /// + /// Gets a Direct2D bitmap to use on the specified render target. + /// + /// The render target. + /// The Direct2D bitmap. public SharpDX.Direct2D1.Bitmap GetDirect2DBitmap(SharpDX.Direct2D1.RenderTarget renderTarget) { if (this.direct2D == null) @@ -66,6 +94,10 @@ namespace Perspex.Direct2D1.Media return this.direct2D; } + /// + /// Saves the bitmap to a file. + /// + /// The filename. public void Save(string fileName) { if (Path.GetExtension(fileName) != ".png") diff --git a/Windows/Perspex.Direct2D1/Media/StreamGeometryImpl.cs b/Windows/Perspex.Direct2D1/Media/StreamGeometryImpl.cs index 9bd9082844..f446934df4 100644 --- a/Windows/Perspex.Direct2D1/Media/StreamGeometryImpl.cs +++ b/Windows/Perspex.Direct2D1/Media/StreamGeometryImpl.cs @@ -1,44 +1,58 @@ // ----------------------------------------------------------------------- // -// Copyright 2014 MIT Licence. See licence.md for more information. +// Copyright 2015 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- namespace Perspex.Direct2D1.Media { - using System; using Perspex.Media; using Perspex.Platform; - using SharpDX; using SharpDX.Direct2D1; using Splat; using D2DGeometry = SharpDX.Direct2D1.Geometry; + /// + /// A Direct2D implementation of a . + /// public class StreamGeometryImpl : GeometryImpl, IStreamGeometryImpl { private PathGeometry path; + /// + /// Initializes a new instance of the class. + /// public StreamGeometryImpl() { Factory factory = Locator.Current.GetService(); this.path = new PathGeometry(factory); } + /// + /// Initializes a new instance of the class. + /// + /// An existing Direct2D . protected StreamGeometryImpl(PathGeometry geometry) { this.path = geometry; } + /// public override Rect Bounds { get { return this.path.GetBounds().ToPerspex(); } } + /// public override D2DGeometry DefiningGeometry { get { return this.path; } } + /// + /// Clones the geometry. + /// + /// A cloned geometry. public IStreamGeometryImpl Clone() { Factory factory = Locator.Current.GetService(); @@ -49,6 +63,12 @@ namespace Perspex.Direct2D1.Media return new StreamGeometryImpl(result); } + /// + /// Opens the geometry to start defining it. + /// + /// + /// A which can be used to define the geometry. + /// public IStreamGeometryContextImpl Open() { return new StreamGeometryContextImpl(this.path.Open());