Merge pull request #23 from DarthAffe/Development

Merge ZIndex
This commit is contained in:
DarthAffe committed 2015-10-14 19:53:19 +02:00
commit 21aca569ed
6 files changed
+28 -16

No files matched your search

+16 -14
View File
@@ -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); }
}
+3 -1
View File
@@ -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
+3 -1
View File
@@ -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; }
+2
View File
@@ -15,6 +15,8 @@ namespace CUE.NET.Devices.Keyboard.Keys
public IBrush Brush { get; set; }
public int ZIndex { get; set; } = 0;
#endregion
#region Constructors
+2
View File
@@ -8,5 +8,7 @@ namespace CUE.NET.Devices.Keyboard.Keys
IEnumerable<CorsairKey> Keys { get; }
IBrush Brush { get; set; }
int ZIndex { get; set; }
}
}