mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-13 00:58:31 +00:00
commit
21aca569ed
@ -51,6 +51,7 @@ namespace CUE.NET.Devices.Keyboard
|
||||
public CorsairKeyboardDeviceInfo KeyboardDeviceInfo { get; }
|
||||
public RectangleF KeyboardRectangle { get; private set; }
|
||||
public IBrush Brush { get; set; }
|
||||
public int ZIndex { get; set; } = 0;
|
||||
|
||||
protected override bool HasEffect
|
||||
{
|
||||
@ -89,13 +90,25 @@ namespace CUE.NET.Devices.Keyboard
|
||||
base.Update(flushLeds);
|
||||
}
|
||||
|
||||
private void UpdateKeyGroups()
|
||||
{
|
||||
if (Brush != null)
|
||||
ApplyBrush(this.ToList(), Brush);
|
||||
|
||||
lock (_keyGroups)
|
||||
{
|
||||
foreach (IKeyGroup keyGroup in _keyGroups.OrderBy(x => x.ZIndex))
|
||||
ApplyBrush(keyGroup.Keys.ToList(), keyGroup.Brush);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateEffects()
|
||||
{
|
||||
List<IEffect> effectsToRemove = new List<IEffect>();
|
||||
lock (_effects)
|
||||
{
|
||||
long currentTicks = DateTime.Now.Ticks;
|
||||
foreach (EffectTimeContainer effect in _effects)
|
||||
foreach (EffectTimeContainer effect in _effects.OrderBy(x => x.ZIndex))
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -116,6 +129,7 @@ namespace CUE.NET.Devices.Keyboard
|
||||
if (effect.Effect.IsDone)
|
||||
effectsToRemove.Add(effect.Effect);
|
||||
}
|
||||
// ReSharper disable once CatchAllClause
|
||||
catch (Exception ex) { ManageException(ex); }
|
||||
}
|
||||
}
|
||||
@ -124,19 +138,6 @@ namespace CUE.NET.Devices.Keyboard
|
||||
DetachEffect(effect);
|
||||
}
|
||||
|
||||
private void UpdateKeyGroups()
|
||||
{
|
||||
if (Brush != null)
|
||||
ApplyBrush(this.ToList(), Brush);
|
||||
|
||||
lock (_keyGroups)
|
||||
{
|
||||
//TODO DarthAffe 20.09.2015: Add some sort of priority
|
||||
foreach (IKeyGroup keyGroup in _keyGroups)
|
||||
ApplyBrush(keyGroup.Keys.ToList(), keyGroup.Brush);
|
||||
}
|
||||
}
|
||||
|
||||
// ReSharper disable once MemberCanBeMadeStatic.Local - idc
|
||||
private void ApplyBrush(ICollection<CorsairKey> keys, IBrush brush)
|
||||
{
|
||||
@ -146,6 +147,7 @@ namespace CUE.NET.Devices.Keyboard
|
||||
foreach (CorsairKey key in keys)
|
||||
key.Led.Color = brush.GetColorAtPoint(brushRectangle, key.KeyRectangle.GetCenter());
|
||||
}
|
||||
// ReSharper disable once CatchAllClause
|
||||
catch (Exception ex) { ManageException(ex); }
|
||||
}
|
||||
|
||||
|
||||
@ -11,9 +11,11 @@ namespace CUE.NET.Devices.Keyboard.Effects
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public IEnumerable<CorsairKey> KeyList { get; protected set; }
|
||||
|
||||
public abstract IBrush EffectBrush { get; }
|
||||
|
||||
public IEnumerable<CorsairKey> KeyList { get; protected set; }
|
||||
public int ZIndex { get; set; } = 0;
|
||||
|
||||
public bool IsDone { get; protected set; }
|
||||
|
||||
|
||||
@ -11,6 +11,8 @@ namespace CUE.NET.Devices.Keyboard.Effects
|
||||
|
||||
internal long TicksAtLastUpdate { get; set; }
|
||||
|
||||
internal int ZIndex => Effect?.ZIndex ?? 0;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
@ -8,9 +8,11 @@ namespace CUE.NET.Devices.Keyboard.Effects
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
IEnumerable<CorsairKey> KeyList { get; }
|
||||
|
||||
IBrush EffectBrush { get; }
|
||||
|
||||
IEnumerable<CorsairKey> KeyList { get; }
|
||||
int ZIndex { get; set; }
|
||||
|
||||
bool IsDone { get; }
|
||||
|
||||
|
||||
@ -15,6 +15,8 @@ namespace CUE.NET.Devices.Keyboard.Keys
|
||||
|
||||
public IBrush Brush { get; set; }
|
||||
|
||||
public int ZIndex { get; set; } = 0;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
@ -8,5 +8,7 @@ namespace CUE.NET.Devices.Keyboard.Keys
|
||||
IEnumerable<CorsairKey> Keys { get; }
|
||||
|
||||
IBrush Brush { get; set; }
|
||||
|
||||
int ZIndex { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user