mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2026-11-11 04:56:44 +00:00
Introduced "KeyGroups"
This commit is contained in:
1 parent
fc66ac0ceb
commit
0167828a19
8 files changed
+149
-14
No files matched your search
@@ -0,0 +1,42 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Keys
|
||||
{
|
||||
public class BaseKeyGroup : IKeyGroup
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
protected CorsairKeyboard Keyboard { get; }
|
||||
|
||||
public IList<CorsairKey> Keys { get; } = new List<CorsairKey>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
protected BaseKeyGroup(CorsairKeyboard keyboard)
|
||||
{
|
||||
this.Keyboard = keyboard;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public virtual void SetColor(Color color)
|
||||
{
|
||||
foreach (CorsairKey key in Keys)
|
||||
key.Led.Color = color;
|
||||
}
|
||||
|
||||
public void MergeKeys(IKeyGroup groupToMerge)
|
||||
{
|
||||
foreach (CorsairKey key in groupToMerge.Keys)
|
||||
if (!Keys.Contains(key))
|
||||
Keys.Add(key);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using CUE.NET.Devices.Generic;
|
||||
using CUE.NET.Devices.Keyboard.Enums;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Keys
|
||||
{
|
||||
public class CorsairKey
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public CorsairKeyboardKeyId KeyId { get; }
|
||||
public CorsairLed Led { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
internal CorsairKey(CorsairKeyboardKeyId keyId, CorsairLed led)
|
||||
{
|
||||
this.KeyId = keyId;
|
||||
this.Led = led;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Keys
|
||||
{
|
||||
public interface IKeyGroup
|
||||
{
|
||||
//TODO DarthAffe 19.09.2015: This might be not needed/bad
|
||||
IList<CorsairKey> Keys { get; }
|
||||
|
||||
void SetColor(Color color);
|
||||
|
||||
void MergeKeys(IKeyGroup groupToMerge);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using CUE.NET.Devices.Keyboard.Enums;
|
||||
|
||||
namespace CUE.NET.Devices.Keyboard.Keys
|
||||
{
|
||||
public class SimpleKeyGroup : BaseKeyGroup
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public SimpleKeyGroup(CorsairKeyboard keyboard)
|
||||
: base(keyboard)
|
||||
{ }
|
||||
|
||||
public SimpleKeyGroup(CorsairKeyboard keyboard, params CorsairKey[] keys)
|
||||
: base(keyboard)
|
||||
{
|
||||
AddKey(keys);
|
||||
}
|
||||
|
||||
public SimpleKeyGroup(CorsairKeyboard keyboard, params CorsairKeyboardKeyId[] keys)
|
||||
: base(keyboard)
|
||||
{
|
||||
AddKey(keys);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public void AddKey(params CorsairKey[] keys)
|
||||
{
|
||||
if (keys != null)
|
||||
foreach (CorsairKey key in keys)
|
||||
if (key != null && !ContainsKey(key))
|
||||
Keys.Add(key);
|
||||
|
||||
}
|
||||
|
||||
public void AddKey(params CorsairKeyboardKeyId[] keyIds)
|
||||
{
|
||||
if (keyIds != null)
|
||||
foreach (CorsairKeyboardKeyId keyId in keyIds)
|
||||
AddKey(Keyboard[keyId]);
|
||||
}
|
||||
|
||||
public void RemoveKey(params CorsairKey[] keys)
|
||||
{
|
||||
if (keys != null)
|
||||
foreach (CorsairKey key in keys)
|
||||
if (key != null)
|
||||
Keys.Remove(key);
|
||||
}
|
||||
|
||||
public void RemoveKey(params CorsairKeyboardKeyId[] keyIds)
|
||||
{
|
||||
if (keyIds != null)
|
||||
foreach (CorsairKeyboardKeyId keyId in keyIds)
|
||||
RemoveKey(Keyboard[keyId]);
|
||||
}
|
||||
|
||||
public bool ContainsKey(CorsairKey key)
|
||||
{
|
||||
return key != null && Keys.Contains(key);
|
||||
}
|
||||
|
||||
public bool ContainsKey(CorsairKeyboardKeyId keyId)
|
||||
{
|
||||
return ContainsKey(Keyboard[keyId]);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user