Implemented keyboard as key-group

This commit is contained in:
DarthAffe committed 2015-09-20 09:11:22 +02:00
1 parent 35ff696d1c
commit 5d96a1ba11
6 files changed
+24 -17

No files matched your search

+6 -4
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
namespace CUE.NET.Devices.Keyboard.Keys
@@ -9,7 +10,8 @@ namespace CUE.NET.Devices.Keyboard.Keys
protected CorsairKeyboard Keyboard { get; }
public IList<CorsairKey> Keys { get; } = new List<CorsairKey>();
public IEnumerable<CorsairKey> Keys => new ReadOnlyCollection<CorsairKey>(GroupKeys);
protected IList<CorsairKey> GroupKeys { get; } = new List<CorsairKey>();
#endregion
@@ -26,15 +28,15 @@ namespace CUE.NET.Devices.Keyboard.Keys
public virtual void SetColor(Color color)
{
foreach (CorsairKey key in Keys)
foreach (CorsairKey key in GroupKeys)
key.Led.Color = color;
}
public void MergeKeys(IKeyGroup groupToMerge)
{
foreach (CorsairKey key in groupToMerge.Keys)
if (!Keys.Contains(key))
Keys.Add(key);
if (!GroupKeys.Contains(key))
GroupKeys.Add(key);
}
#endregion
+1 -4
View File
@@ -5,11 +5,8 @@ namespace CUE.NET.Devices.Keyboard.Keys
{
public interface IKeyGroup
{
//TODO DarthAffe 19.09.2015: This might be not needed/bad
IList<CorsairKey> Keys { get; }
IEnumerable<CorsairKey> Keys { get; }
void SetColor(Color color);
void MergeKeys(IKeyGroup groupToMerge);
}
}
+1 -1
View File
@@ -35,7 +35,7 @@ namespace CUE.NET.Devices.Keyboard.Keys
this.MinOverlayPercentage = minOverlayPercentage;
foreach (CorsairKey key in Keyboard.Where(x => RectangleHelper.CalculateIntersectPercentage(x.KeyRectangle, requestedRectangle) >= minOverlayPercentage))
Keys.Add(key);
GroupKeys.Add(key);
}
#endregion
+3 -3
View File
@@ -31,7 +31,7 @@ namespace CUE.NET.Devices.Keyboard.Keys
if (keys != null)
foreach (CorsairKey key in keys)
if (key != null && !ContainsKey(key))
Keys.Add(key);
GroupKeys.Add(key);
}
@@ -47,7 +47,7 @@ namespace CUE.NET.Devices.Keyboard.Keys
if (keys != null)
foreach (CorsairKey key in keys)
if (key != null)
Keys.Remove(key);
GroupKeys.Remove(key);
}
public void RemoveKey(params CorsairKeyboardKeyId[] keyIds)
@@ -59,7 +59,7 @@ namespace CUE.NET.Devices.Keyboard.Keys
public bool ContainsKey(CorsairKey key)
{
return key != null && Keys.Contains(key);
return key != null && GroupKeys.Contains(key);
}
public bool ContainsKey(CorsairKeyboardKeyId keyId)