// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable UnusedMember.Global
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using CUE.NET.Devices.Generic;
using CUE.NET.Devices.Mouse.Enums;
using CUE.NET.Exceptions;
namespace CUE.NET.Devices.Mouse
{
///
/// Represents the SDK for a corsair mouse.
///
public class CorsairMouse : AbstractCueDevice, IEnumerable
{
#region Properties & Fields
#region Indexer
///
/// Gets the with the specified ID.
///
/// The ID of the LED to get.
/// The LED with the specified ID.
/// is null.
public CorsairLed this[CorsairMouseLedId ledId]
{
get
{
CorsairLed led;
return base.Leds.TryGetValue((int)ledId, out led) ? led : null;
}
}
#endregion
///
/// Gets specific information provided by CUE for the mouse.
///
public CorsairMouseDeviceInfo MouseDeviceInfo { get; }
///
/// Indicates if the mouse has an active effect to deal with.
///
protected override bool HasEffect => false;
///
/// Gets a read-only collection containing all LEDs of the mouse.
///
public new IEnumerable Leds => new ReadOnlyCollection(base.Leds.Values.ToList());
#endregion
#region Constructors
///
/// Initializes a new instance of the class.
///
/// The specific information provided by CUE for the mouse
internal CorsairMouse(CorsairMouseDeviceInfo info)
: base(info)
{
this.MouseDeviceInfo = info;
InitializeLeds();
}
#endregion
#region Methods
private void InitializeLeds()
{
switch (MouseDeviceInfo.PhysicalLayout)
{
case CorsairPhysicalMouseLayout.Zones1:
GetLed((int)CorsairMouseLedId.B1);
break;
case CorsairPhysicalMouseLayout.Zones2:
GetLed((int)CorsairMouseLedId.B1);
GetLed((int)CorsairMouseLedId.B2);
break;
case CorsairPhysicalMouseLayout.Zones3:
GetLed((int)CorsairMouseLedId.B1);
GetLed((int)CorsairMouseLedId.B2);
GetLed((int)CorsairMouseLedId.B3);
break;
case CorsairPhysicalMouseLayout.Zones4:
GetLed((int)CorsairMouseLedId.B1);
GetLed((int)CorsairMouseLedId.B2);
GetLed((int)CorsairMouseLedId.B3);
GetLed((int)CorsairMouseLedId.B4);
break;
default:
throw new WrapperException($"Can't initial mouse with layout '{MouseDeviceInfo.PhysicalLayout}'");
}
}
#region IEnumerable
///
/// Returns an enumerator that iterates over all LEDs of the mouse.
///
/// An enumerator for all LDS of the mouse.
public IEnumerator GetEnumerator()
{
return Leds.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
#endregion
#endregion
}
}