Added key-rectangle to BrushRenderTarget

This commit is contained in:
DarthAffe committed 2016-11-06 17:38:01 +01:00
1 parent 74824e3363
commit deb043b6b2
3 files changed
+26 -6

No files matched your search

+11 -3
View File
@@ -3,6 +3,7 @@
using System.Drawing;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Helper;
namespace CUE.NET.Brushes
{
@@ -18,6 +19,11 @@ namespace CUE.NET.Brushes
/// </summary>
public CorsairLedId LedId { get; }
/// <summary>
/// Gets the rectangle representing the area to render the target-LED.
/// </summary>
public RectangleF Rectangle { get; }
/// <summary>
/// Gets the point representing the position to render the target-LED.
/// </summary>
@@ -31,11 +37,13 @@ namespace CUE.NET.Brushes
/// Initializes a new instance of the <see cref="BrushRenderTarget"/> class.
/// </summary>
/// <param name="ledId">The ID of the target-LED.</param>
/// <param name="point">The point representing the position to render the target-LED.</param>
public BrushRenderTarget(CorsairLedId ledId, PointF point)
/// <param name="rectangle">The rectangle representing the area to render the target-LED.</param>
public BrushRenderTarget(CorsairLedId ledId, RectangleF rectangle)
{
this.Point = point;
this.Rectangle = rectangle;
this.LedId = ledId;
Point = rectangle.GetCenter();
}
#endregion
+2 -2
View File
@@ -239,10 +239,10 @@ namespace CUE.NET.Devices.Generic
float offsetY = -brushRectangle.Y;
brushRectangle.X = 0;
brushRectangle.Y = 0;
brush.PerformRender(brushRectangle, leds.Select(x => new BrushRenderTarget(x.Id, x.LedRectangle.GetCenter(offsetX, offsetY))));
brush.PerformRender(brushRectangle, leds.Select(x => new BrushRenderTarget(x.Id, x.LedRectangle.Move(offsetX, offsetY))));
break;
case BrushCalculationMode.Absolute:
brush.PerformRender(DeviceRectangle, leds.Select(x => new BrushRenderTarget(x.Id, x.LedRectangle.GetCenter())));
brush.PerformRender(DeviceRectangle, leds.Select(x => new BrushRenderTarget(x.Id, x.LedRectangle)));
break;
default:
throw new ArgumentException();
+13 -1
View File
@@ -10,7 +10,19 @@ namespace CUE.NET.Helper
public static class RectangleHelper
{
/// <summary>
/// Calculates the center-point of a rectangle adding a offset.
/// Moves a rectangle by a adding an offset.
/// </summary>
/// <param name="rectangle">The rectangle.</param>
/// <param name="offsetX">The offset for the x-value</param>
/// <param name="offsetY">The offset for the y-value</param>
/// <returns>The moved rectangle.</returns>
public static RectangleF Move(this RectangleF rectangle, float offsetX = 0f, float offsetY = 0f)
{
return new RectangleF(rectangle.X + offsetX, rectangle.Y + offsetY, rectangle.Width, rectangle.Height);
}
/// <summary>
/// Calculates the center-point of a rectangle adding an offset.
/// </summary>
/// <param name="rectangle">The rectangle.</param>
/// <param name="offsetX">The offset for the x-value</param>