using System.Diagnostics; using RGB.NET.Core; namespace RGB.NET.Devices.Asus { /// /// /// Represents a Id of a on a . /// [DebuggerDisplay("{" + nameof(LedId) + "}")] public class AsusLedId : ILedId { #region Properties & Fields internal readonly AsusLedIds LedId; internal readonly int Index; /// public IRGBDevice Device { get; } /// public bool IsValid => LedId != AsusLedIds.Invalid; #endregion #region Constructors /// /// Initializes a new instance of the class. /// /// The the belongs to. /// The of the represented . public AsusLedId(IRGBDevice device, AsusLedIds ledId) { this.Device = device; this.LedId = ledId; } /// /// Initializes a new instance of the class. /// /// The the belongs to. /// The of the represented . /// The index in the mapping array of the device. public AsusLedId(IRGBDevice device, AsusLedIds ledId, int index) { this.Device = device; this.LedId = ledId; 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() => LedId.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) { AsusLedId compareLedId = obj as AsusLedId; if (ReferenceEquals(compareLedId, null)) return false; if (ReferenceEquals(this, compareLedId)) return true; if (GetType() != compareLedId.GetType()) return false; return compareLedId.LedId == LedId; } /// /// Returns a hash code for this . /// /// An integer value that specifies the hash code for this . public override int GetHashCode() => LedId.GetHashCode(); #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 ==(AsusLedId ledId1, AsusLedId 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 !=(AsusLedId ledId1, AsusLedId ledId2) => !(ledId1 == ledId2); #endregion } }