mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2026-11-10 20:46:24 +00:00
Added own color-type to have more control over and easier manipulation of collors
This commit is contained in:
1 parent
5c6dba769b
commit
381ec55349
29 files changed
+271
-93
No files matched your search
@@ -254,7 +254,7 @@ namespace CUE.NET.Devices.Generic
|
||||
brush.UpdateEffects();
|
||||
brush.PerformFinalize();
|
||||
|
||||
foreach (KeyValuePair<BrushRenderTarget, Color> renders in brush.RenderedTargets)
|
||||
foreach (KeyValuePair<BrushRenderTarget, CorsairColor> renders in brush.RenderedTargets)
|
||||
this[renders.Key.LedId].Color = renders.Value;
|
||||
}
|
||||
// ReSharper disable once CatchAllClause
|
||||
@@ -263,7 +263,7 @@ namespace CUE.NET.Devices.Generic
|
||||
|
||||
private void UpdateLeds(ICollection<LedUpateRequest> updateRequests)
|
||||
{
|
||||
updateRequests = updateRequests.Where(x => x.Color != Color.Transparent).ToList();
|
||||
updateRequests = updateRequests.Where(x => x.Color != CorsairColor.Transparent).ToList();
|
||||
|
||||
OnLedsUpdating(updateRequests);
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace CUE.NET.Devices.Generic
|
||||
{
|
||||
public class CorsairColor
|
||||
{
|
||||
#region Constants
|
||||
|
||||
public static CorsairColor Transparent => Color.Transparent;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public byte A { get; set; }
|
||||
public byte R { get; set; }
|
||||
public byte G { get; set; }
|
||||
public byte B { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public CorsairColor()
|
||||
{ }
|
||||
|
||||
public CorsairColor(byte r, byte g, byte b) : this(255, r, g, b)
|
||||
{ }
|
||||
|
||||
public CorsairColor(byte a, byte r, byte g, byte b)
|
||||
{
|
||||
this.A = a;
|
||||
this.R = r;
|
||||
this.G = g;
|
||||
this.B = b;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
|
||||
public static implicit operator CorsairColor(Color color)
|
||||
{
|
||||
return new CorsairColor(color.A, color.R, color.G, color.B);
|
||||
}
|
||||
|
||||
public static implicit operator Color(CorsairColor color)
|
||||
{
|
||||
return Color.FromArgb(color.A, color.R, color.G, color.B);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -33,13 +33,13 @@ namespace CUE.NET.Devices.Generic
|
||||
/// <summary>
|
||||
/// Gets the Color the LED should be set to on the next update.
|
||||
/// </summary>
|
||||
public Color RequestedColor { get; private set; } = Color.Transparent;
|
||||
public CorsairColor RequestedColor { get; private set; } = CorsairColor.Transparent;
|
||||
|
||||
private Color _color = Color.Transparent;
|
||||
private CorsairColor _color = CorsairColor.Transparent;
|
||||
/// <summary>
|
||||
/// Gets the current color of the LED. Sets the <see cref="RequestedColor" /> for the next update. />.
|
||||
/// </summary>
|
||||
public Color Color
|
||||
public CorsairColor Color
|
||||
{
|
||||
get { return _color; }
|
||||
set
|
||||
@@ -86,8 +86,8 @@ namespace CUE.NET.Devices.Generic
|
||||
/// </summary>
|
||||
internal void Reset()
|
||||
{
|
||||
_color = Color.Transparent;
|
||||
RequestedColor = Color.Transparent;
|
||||
_color = CorsairColor.Transparent;
|
||||
RequestedColor = CorsairColor.Transparent;
|
||||
IsLocked = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
||||
|
||||
using System.Drawing;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
|
||||
namespace CUE.NET.Devices.Generic
|
||||
@@ -21,7 +20,7 @@ namespace CUE.NET.Devices.Generic
|
||||
/// <summary>
|
||||
/// Gets the requested color of the led.
|
||||
/// </summary>
|
||||
public Color Color { get; set; }
|
||||
public CorsairColor Color { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -32,7 +31,7 @@ namespace CUE.NET.Devices.Generic
|
||||
/// </summary>
|
||||
/// <param name="ledId">The id of the led to update.</param>
|
||||
/// <param name="color">The requested color of the led.</param>
|
||||
public LedUpateRequest(CorsairLedId ledId, Color color)
|
||||
public LedUpateRequest(CorsairLedId ledId, CorsairColor color)
|
||||
{
|
||||
this.LedId = ledId;
|
||||
this.Color = color;
|
||||
|
||||
Reference in new issue
Block a user