using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LibrarySDR.Enums { public sealed class RegistrationStatus { private readonly String name; private readonly int value; public Color Color { get { return GetColor(GetRegistrationStatus(value)); } } public static readonly RegistrationStatus Connecting = new RegistrationStatus(1, "Connecting"); public static readonly RegistrationStatus Connected = new RegistrationStatus(2, "Connected"); public static readonly RegistrationStatus NotConnected = new RegistrationStatus(3, "Not Connected"); public static readonly RegistrationStatus Disconnected = new RegistrationStatus(4, "Disconnected"); public static readonly RegistrationStatus Unknown = new RegistrationStatus(11, "Unknown"); private RegistrationStatus(int value, String name) { this.name = name; this.value = value; } public override String ToString() { return name; } public override bool Equals(object obj) { if (obj is RegistrationStatus) return this.value == ((RegistrationStatus)obj).value; return base.Equals(obj); } public static RegistrationStatus GetRegistrationStatus(string status) { switch (status) { case "1": return Connecting; case "2": return Connected; case "3": return NotConnected; case "4": return Disconnected; default: return Unknown; } } public static RegistrationStatus GetRegistrationStatus(int value) { if (value == Connecting.value) return Connecting; else if (value == Connected.value) return Connected; else if (value == NotConnected.value) return NotConnected; else if (value == Disconnected.value) return Disconnected; else return Unknown; } public static Color GetColor(RegistrationStatus status) { int value = status.value; if (value == Connecting.value) return Color.FromArgb(112, 112, 112); else if (value == Connected.value) return Color.FromArgb(57, 181, 74); else if (value == Disconnected.value) return Color.FromArgb(193, 39, 39); else return Color.FromArgb(255, 255, 255, 255); } public static RegistrationStatus Random() { Random r = new Random(); return GetRegistrationStatus(r.Next(1, 4)); } }; }