using RGB.NET.Core;
namespace RGB.NET.Devices.Razer
{
///
///
/// Represents a Id of a on a .
///
public class RazerLedId : ILedId
{
#region Properties & Fields
internal int Index { get; }
///
public IRGBDevice Device { get; }
///
public bool IsValid => true;
#endregion
#region Constructors
///
/// Initializes a new instance of the class.
///
/// The the belongs to.
/// The index representing the led-location in the grid.
public RazerLedId(IRGBDevice device, int index)
{
this.Device = device;
this.Index = index;
}
#endregion
#region Methods
///
/// Converts the Id of this to a human-readable string.
///
/// A string that contains the Id of this . For example "Enter".
public override string ToString() => Index.ToString();
///
/// Tests whether the specified object is a and is equivalent to this .
///
/// The object to test.
/// true if is a equivalent to this ; otherwise, false.
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (!(obj is RazerLedId other)) return false;
return (Index == other.Index) && Equals(Device, other.Device);
}
///
/// Returns a hash code for this .
///
/// An integer value that specifies the hash code for this .
public override int GetHashCode()
{
unchecked
{
return (Index * 397) ^ (Device != null ? Device.GetHashCode() : 0);
}
}
#endregion
#region Operators
///
/// Returns a value that indicates whether two specified are equal.
///
/// The first to compare.
/// The second to compare.
/// true if and are equal; otherwise, false.
public static bool operator ==(RazerLedId ledId1, RazerLedId ledId2) => ReferenceEquals(ledId1, null) ? ReferenceEquals(ledId2, null) : ledId1.Equals(ledId2);
///
/// Returns a value that indicates whether two specified are equal.
///
/// The first to compare.
/// The second to compare.
/// true if and are not equal; otherwise, false.
public static bool operator !=(RazerLedId ledId1, RazerLedId ledId2) => !(ledId1 == ledId2);
#endregion
}
}