mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-12 16:58:29 +00:00
Added a selection for BrushCalculationModes (relative/absolute)
This commit is contained in:
parent
88ac78f19a
commit
93d94fdc5a
@ -52,6 +52,7 @@
|
|||||||
<Compile Include="Devices\Generic\Enums\CorsairDeviceType.cs" />
|
<Compile Include="Devices\Generic\Enums\CorsairDeviceType.cs" />
|
||||||
<Compile Include="Devices\Generic\ExceptionEventArgs.cs" />
|
<Compile Include="Devices\Generic\ExceptionEventArgs.cs" />
|
||||||
<Compile Include="Brushes\AbstractBrush.cs" />
|
<Compile Include="Brushes\AbstractBrush.cs" />
|
||||||
|
<Compile Include="Devices\Keyboard\Enums\BrushCalculationMode.cs" />
|
||||||
<Compile Include="Gradients\AbstractGradient.cs" />
|
<Compile Include="Gradients\AbstractGradient.cs" />
|
||||||
<Compile Include="Gradients\GradientStop.cs" />
|
<Compile Include="Gradients\GradientStop.cs" />
|
||||||
<Compile Include="Gradients\IGradient.cs" />
|
<Compile Include="Gradients\IGradient.cs" />
|
||||||
|
|||||||
@ -105,6 +105,11 @@ namespace CUE.NET.Devices.Keyboard
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int ZIndex { get; set; } = 0;
|
public int ZIndex { get; set; } = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the calculation mode used for the rectangle/points used for color-selection in brushes.
|
||||||
|
/// </summary>
|
||||||
|
public BrushCalculationMode BrushCalculationMode { get; set; } = BrushCalculationMode.Relative;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating if the keyboard has an active effect to deal with or not.
|
/// Gets a value indicating if the keyboard has an active effect to deal with or not.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -178,14 +183,24 @@ namespace CUE.NET.Devices.Keyboard
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
RectangleF brushRectangle = RectangleHelper.CreateRectangleFromRectangles(keys.Select(x => x.KeyRectangle));
|
switch (BrushCalculationMode)
|
||||||
//TODO DarthAffe 16.03.2016: Rework brushes and replace this workaround with a proper selection of absolute/relative calculations
|
{
|
||||||
float offsetX = -brushRectangle.X;
|
case BrushCalculationMode.Relative:
|
||||||
float offsetY = -brushRectangle.Y;
|
RectangleF brushRectangle = RectangleHelper.CreateRectangleFromRectangles(keys.Select(x => x.KeyRectangle));
|
||||||
brushRectangle.X = 0;
|
float offsetX = -brushRectangle.X;
|
||||||
brushRectangle.Y = 0;
|
float offsetY = -brushRectangle.Y;
|
||||||
foreach (CorsairKey key in keys)
|
brushRectangle.X = 0;
|
||||||
key.Led.Color = brush.GetColorAtPoint(brushRectangle, key.KeyRectangle.GetCenter(offsetX, offsetY));
|
brushRectangle.Y = 0;
|
||||||
|
foreach (CorsairKey key in keys)
|
||||||
|
key.Led.Color = brush.GetColorAtPoint(KeyboardRectangle, key.KeyRectangle.GetCenter(offsetX, offsetY));
|
||||||
|
break;
|
||||||
|
case BrushCalculationMode.Absolute:
|
||||||
|
foreach (CorsairKey key in keys)
|
||||||
|
key.Led.Color = brush.GetColorAtPoint(KeyboardRectangle, key.KeyRectangle.GetCenter());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ReSharper disable once CatchAllClause
|
// ReSharper disable once CatchAllClause
|
||||||
catch (Exception ex) { ManageException(ex); }
|
catch (Exception ex) { ManageException(ex); }
|
||||||
|
|||||||
17
Devices/Keyboard/Enums/BrushCalculationMode.cs
Normal file
17
Devices/Keyboard/Enums/BrushCalculationMode.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace CUE.NET.Devices.Keyboard.Enums
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains list of all brush calculation modes.
|
||||||
|
/// </summary>
|
||||||
|
public enum BrushCalculationMode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The calculation rectangle for brushes will be the rectangle around the keygroup the brush is applied to.
|
||||||
|
/// </summary>
|
||||||
|
Relative,
|
||||||
|
/// <summary>
|
||||||
|
/// The calculation rectangle for brushes will always be the whole keyboard.
|
||||||
|
/// </summary>
|
||||||
|
Absolute
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user