Added even more xml-comments

This commit is contained in:
DarthAffe committed 2015-10-18 11:41:42 +02:00
1 parent 6de1087c1f
commit 5fc7abc9db
30 files changed
+639 -17

No files matched your search

+27
View File
@@ -3,17 +3,32 @@ using CUE.NET.Helper;
namespace CUE.NET.Devices.Keyboard.Brushes
{
/// <summary>
/// Represents a basic brush.
/// </summary>
public abstract class AbstractBrush : IBrush
{
#region Properties & Fields
/// <summary>
/// Gets or sets the overall percentage brightness of the brush.
/// </summary>
public float Brightness { get; set; }
/// <summary>
/// Gets or sets the overall percentage opacity of the brush.
/// </summary>
public float Opacity { get; set; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="AbstractBrush"/> class.
/// </summary>
/// <param name="brightness">The overall percentage brightness of the brush. (default: 1f)</param>
/// <param name="opacity">The overall percentage opacity of the brush. (default: 1f)</param>
protected AbstractBrush(float brightness = 1f, float opacity = 1f)
{
this.Brightness = brightness;
@@ -24,8 +39,20 @@ namespace CUE.NET.Devices.Keyboard.Brushes
#region Methods
/// <summary>
/// Gets the color at an specific point assuming the brush is drawn into the given rectangle.
/// </summary>
/// <param name="rectangle">The rectangle in which the brush should be drawn.</param>
/// <param name="point">The point from which the color should be taken.</param>
/// <returns>The color at the specified point.</returns>
public abstract Color GetColorAtPoint(RectangleF rectangle, PointF point);
/// <summary>
/// Finalizes the color by appliing the overall brightness and opacity.<br/>
/// This method should always be the last call of a <see cref="GetColorAtPoint" /> implementation.
/// </summary>
/// <param name="color">The color to finalize.</param>
/// <returns>The finalized color.</returns>
protected virtual Color FinalizeColor(Color color)
{
// Since we use HSV to calculate there is no way to make a color 'brighter' than 100%
@@ -6,19 +6,32 @@ using System.Linq;
namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
{
/// <summary>
/// Represents a basic gradient.
/// </summary>
public abstract class AbstractGradient : IGradient
{
#region Properties & Fields
/// <summary>
/// Gets a list of the stops used by this gradient.
/// </summary>
public IList<GradientStop> GradientStops { get; } = new List<GradientStop>();
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="AbstractGradient"/> class.
/// </summary>
protected AbstractGradient()
{ }
/// <summary>
/// Initializes a new instance of the <see cref="AbstractGradient"/> class.
/// </summary>
/// <param name="gradientStops">The stops with which the gradient should be initialized.</param>
protected AbstractGradient(params GradientStop[] gradientStops)
{
foreach (GradientStop gradientStop in gradientStops)
@@ -29,6 +42,11 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
#region Methods
/// <summary>
/// Clips the offset and ensures, that it is inside the bounds of the stop list.
/// </summary>
/// <param name="offset"></param>
/// <returns></returns>
protected float ClipOffset(float offset)
{
float max = GradientStops.Max(n => n.Offset);
@@ -42,6 +60,11 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
return offset;
}
/// <summary>
/// Gets the color of the gradient on the specified offset.
/// </summary>
/// <param name="offset">The percentage offset to take the color from.</param>
/// <returns>The color at the specific offset.</returns>
public abstract Color GetColor(float offset);
#endregion
@@ -5,18 +5,32 @@ using System.Drawing;
namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
{
/// <summary>
/// Represents a stop on a gradient.
/// </summary>
public class GradientStop
{
#region Properties & Fields
/// <summary>
/// Gets or sets the percentage offset to place this stop. This should be inside the range of [0..1] but it's not necessary.
/// </summary>
public float Offset { get; set; }
/// <summary>
/// Gets or sets the color of the stop.
/// </summary>
public Color Color { get; set; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="GradientStop"/> class.
/// </summary>
/// <param name="offset">The percentage offset to place this stop.</param>
/// <param name="color">The color of the stop.</param>
public GradientStop(float offset, Color color)
{
this.Offset = offset;
@@ -2,8 +2,16 @@
namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
{
/// <summary>
/// Represents a basic gradient.
/// </summary>
public interface IGradient
{
/// <summary>
/// Gets the color of the gradient on the specified offset.
/// </summary>
/// <param name="offset">The percentage offset to take the color from.</param>
/// <returns>The color at the specific offset.</returns>
Color GetColor(float offset);
}
}
@@ -3,13 +3,23 @@ using System.Linq;
namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
{
/// <summary>
/// Represents a linear interpolated gradient with n stops.
/// </summary>
public class LinearGradient : AbstractGradient
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="LinearGradient"/> class.
/// </summary>
public LinearGradient()
{ }
/// <summary>
/// Initializes a new instance of the <see cref="LinearGradient"/> class.
/// </summary>
/// <param name="gradientStops">The stops with which the gradient should be initialized.</param>
public LinearGradient(params GradientStop[] gradientStops)
: base(gradientStops)
{ }
@@ -18,6 +28,11 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
#region Methods
/// <summary>
/// Gets the linear interpolated color at the given offset.
/// </summary>
/// <param name="offset">The percentage offset to take the color from.</param>
/// <returns>The color at the specific offset.</returns>
public override Color GetColor(float offset)
{
if (!GradientStops.Any()) return Color.Transparent;
@@ -5,17 +5,33 @@ using CUE.NET.Helper;
namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
{
/// <summary>
/// Represents a rainbow gradient which circles through all color colors of the HUE-color-space.<br />
/// See <see cref="http://upload.wikimedia.org/wikipedia/commons/a/ad/HueScale.svg" /> as reference
/// </summary>
public class RainbowGradient : IGradient
{
#region Properties & Fields
/// <summary>
/// Gets or sets the hue (in degrees) to start from.
/// </summary>
public float StartHue { get; set; }
/// <summary>
/// Gets or sets the hue (in degrees) to end the with.
/// </summary>
public float EndHue { get; set; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="RainbowGradient"/> class.
/// </summary>
/// <param name="startHue">The hue (in degrees) to start from (default: 0)</param>
/// <param name="endHue">The hue (in degrees) to end with (default: 360)</param>
public RainbowGradient(float startHue = 0f, float endHue = 360f)
{
this.StartHue = startHue;
@@ -28,6 +44,11 @@ namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
#endregion
/// <summary>
/// Gets the color on the rainbow at the given offset.
/// </summary>
/// <param name="offset">The percentage offset to take the color from.</param>
/// <returns>The color at the specific offset.</returns>
public Color GetColor(float offset)
{
float range = EndHue - StartHue;
+16
View File
@@ -2,11 +2,27 @@ using System.Drawing;
namespace CUE.NET.Devices.Keyboard.Brushes
{
/// <summary>
/// Represents a basic brush.
/// </summary>
public interface IBrush
{
/// <summary>
/// Gets or sets the overall percentage brightness of the brush.
/// </summary>
float Brightness { get; set; }
/// <summary>
/// Gets or sets the overall percentage opacity of the brush.
/// </summary>
float Opacity { get; set; }
/// <summary>
/// Gets the color at an specific point assuming the brush is drawn into the given rectangle.
/// </summary>
/// <param name="rectangle">The rectangle in which the brush should be drawn.</param>
/// <param name="point">The point from which the color should be taken.</param>
/// <returns>The color at the specified point.</returns>
Color GetColorAtPoint(RectangleF rectangle, PointF point);
}
}
@@ -9,26 +9,52 @@ using CUE.NET.Helper;
namespace CUE.NET.Devices.Keyboard.Brushes
{
/// <summary>
/// Represents a brush drawing a linear gradient.
/// </summary>
public class LinearGradientBrush : AbstractBrush
{
#region Properties & Fields
/// <summary>
/// Gets or sets the start point (as percentage in the range [0..1]) of the gradient drawn by the brush. (default: 0f, 0.5f)
/// </summary>
public PointF StartPoint { get; set; } = new PointF(0f, 0.5f);
/// <summary>
/// Gets or sets the end point (as percentage in the range [0..1]) of the gradient drawn by the brush. (default: 1f, 0.5f)
/// </summary>
public PointF EndPoint { get; set; } = new PointF(1f, 0.5f);
/// <summary>
/// Gets or sets the gradient drawn by the brush. If null it will default to full transparent.
/// </summary>
public IGradient Gradient { get; set; }
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="LinearGradientBrush"/> class.
/// </summary>
public LinearGradientBrush()
{ }
/// <summary>
/// Initializes a new instance of the <see cref="LinearGradientBrush"/> class.
/// </summary>
/// <param name="gradient">The gradient drawn by the brush.</param>
public LinearGradientBrush(IGradient gradient)
{
this.Gradient = gradient;
}
/// <summary>
/// Initializes a new instance of the <see cref="LinearGradientBrush"/> class.
/// </summary>
/// <param name="startPoint">The start point (as percentage in the range [0..1]).</param>
/// <param name="endPoint">The end point (as percentage in the range [0..1]).</param>
/// <param name="gradient">The gradient drawn by the brush.</param>
public LinearGradientBrush(PointF startPoint, PointF endPoint, IGradient gradient)
{
this.StartPoint = startPoint;
@@ -40,6 +66,12 @@ namespace CUE.NET.Devices.Keyboard.Brushes
#region Methods
/// <summary>
/// Gets the color at an specific point assuming the brush is drawn into the given rectangle.
/// </summary>
/// <param name="rectangle">The rectangle in which the brush should be drawn.</param>
/// <param name="point">The point from which the color should be taken.</param>
/// <returns>The color at the specified point.</returns>
public override Color GetColorAtPoint(RectangleF rectangle, PointF point)
{
if (Gradient == null) return Color.Transparent;
@@ -8,25 +8,47 @@ using CUE.NET.Helper;
namespace CUE.NET.Devices.Keyboard.Brushes
{
/// <summary>
/// Represents a brush drawing a radial gradient around a center point.
/// </summary>
public class RadialGradientBrush : AbstractBrush
{
#region Properties & Fields
/// <summary>
/// Gets or sets the center point (as percentage in the range [0..1]) around which the brush should be drawn.
/// </summary>
public PointF Center { get; set; } = new PointF(0.5f, 0.5f);
/// <summary>
/// Gets or sets the gradient drawn by the brush. If null it will default to full transparent.
/// </summary>
public IGradient Gradient { get; set; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="RadialGradientBrush"/> class.
/// </summary>
public RadialGradientBrush()
{ }
/// <summary>
/// Initializes a new instance of the <see cref="RadialGradientBrush"/> class.
/// </summary>
/// <param name="gradient">The gradient drawn by the brush.</param>
public RadialGradientBrush(IGradient gradient)
{
this.Gradient = gradient;
}
/// <summary>
/// Initializes a new instance of the <see cref="RadialGradientBrush"/> class.
/// </summary>
/// <param name="center">The center point (as percentage in the range [0..1]).</param>
/// <param name="gradient">The gradient drawn by the brush.</param>
public RadialGradientBrush(PointF center, IGradient gradient)
{
this.Center = center;
@@ -37,6 +59,12 @@ namespace CUE.NET.Devices.Keyboard.Brushes
#region Methods
/// <summary>
/// Gets the color at an specific point assuming the brush is drawn into the given rectangle.
/// </summary>
/// <param name="rectangle">The rectangle in which the brush should be drawn.</param>
/// <param name="point">The point from which the color should be taken.</param>
/// <returns>The color at the specified point.</returns>
public override Color GetColorAtPoint(RectangleF rectangle, PointF point)
{
PointF centerPoint = new PointF(rectangle.X + rectangle.Width * Center.X, rectangle.Y + rectangle.Height * Center.Y);
@@ -5,6 +5,10 @@ using CUE.NET.Helper;
namespace CUE.NET.Devices.Keyboard.Brushes
{
//TODO DarthAffe 30.09.2015: Like this the brush seems kinda useless. Think about making it cool.
/// <summary>
/// Represents a brush drawing random colors.
/// </summary>
public class RandomColorBrush : AbstractBrush
{
#region Properties & Fields
@@ -15,6 +19,12 @@ namespace CUE.NET.Devices.Keyboard.Brushes
#region Methods
/// <summary>
/// Gets a random color.
/// </summary>
/// <param name="rectangle">This value isn't used.</param>
/// <param name="point">This value isn't used.</param>
/// <returns>A random color.</returns>
public override Color GetColorAtPoint(RectangleF rectangle, PointF point)
{
return FinalizeColor(ColorHelper.ColorFromHSV((float)_random.NextDouble() * 360f, 1, 1));
@@ -1,19 +1,30 @@
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
using System.Drawing;
namespace CUE.NET.Devices.Keyboard.Brushes
{
/// <summary>
/// Represents a brush drawing only a single color.
/// </summary>
public class SolidColorBrush : AbstractBrush
{
#region Properties & Fields
/// <summary>
/// Gets or sets the color drawn by the brush.
/// </summary>
public Color Color { get; set; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="SolidColorBrush"/> class.
/// </summary>
/// <param name="color">The color drawn by the brush.</param>
public SolidColorBrush(Color color)
{
this.Color = color;
@@ -23,6 +34,12 @@ namespace CUE.NET.Devices.Keyboard.Brushes
#region Methods
/// <summary>
/// Returns the <see cref="Color" /> of the brush.
/// </summary>
/// <param name="rectangle">This value isn't used.</param>
/// <param name="point">This value isn't used.</param>
/// <returns>The <see cref="Color" /> of the brush.</returns>
public override Color GetColorAtPoint(RectangleF rectangle, PointF point)
{
return FinalizeColor(Color);