StephaneLenclud@244: using System; StephaneLenclud@244: using System.Collections.Generic; StephaneLenclud@244: using System.Linq; StephaneLenclud@244: using System.Reflection; StephaneLenclud@244: using System.Text; StephaneLenclud@244: using System.Threading.Tasks; StephaneLenclud@244: using System.Runtime.Serialization; StephaneLenclud@244: using System.Windows.Forms; StephaneLenclud@244: using Ear = SharpLib.Ear; StephaneLenclud@244: using Hid = SharpLib.Hid; StephaneLenclud@244: StephaneLenclud@244: namespace SharpDisplayManager StephaneLenclud@244: { StephaneLenclud@244: [DataContract] StephaneLenclud@244: [Ear.AttributeObject(Id = "Event.Hid", Name = "HID", Description = "Corresponding HID message received.")] StephaneLenclud@244: public class EventHid: Ear.Event StephaneLenclud@244: { StephaneLenclud@244: public EventHid() StephaneLenclud@244: { StephaneLenclud@244: } StephaneLenclud@244: StephaneLenclud@244: [DataMember] StephaneLenclud@244: public ushort UsagePage { get; set; } StephaneLenclud@244: StephaneLenclud@244: [DataMember] StephaneLenclud@244: public ushort UsageCollection { get; set; } StephaneLenclud@244: StephaneLenclud@244: [DataMember] StephaneLenclud@244: public ushort Usage { get; set; } StephaneLenclud@244: StephaneLenclud@244: [DataMember] StephaneLenclud@244: public Keys Key { get; set; } StephaneLenclud@244: StephaneLenclud@244: [DataMember] StephaneLenclud@244: [Ear.AttributeObjectProperty StephaneLenclud@244: ( StephaneLenclud@244: Id = "HID.Keyboard.IsKeyUp", StephaneLenclud@244: Name = "Key Up", StephaneLenclud@244: Description = "Key up if set, key down otherwise." StephaneLenclud@244: )] StephaneLenclud@244: public bool IsKeyUp { get; set; } = false; StephaneLenclud@244: StephaneLenclud@244: [DataMember] StephaneLenclud@244: public bool IsMouse { get; set; } StephaneLenclud@244: StephaneLenclud@244: [DataMember] StephaneLenclud@244: public bool IsKeyboard { get; set; } StephaneLenclud@244: StephaneLenclud@244: [DataMember] StephaneLenclud@244: public bool IsGeneric { get; set; } StephaneLenclud@244: StephaneLenclud@244: [DataMember] StephaneLenclud@244: public bool HasModifierShift { get; set; } = false; StephaneLenclud@244: StephaneLenclud@244: [DataMember] StephaneLenclud@244: public bool HasModifierControl { get; set; } = false; StephaneLenclud@244: StephaneLenclud@244: [DataMember] StephaneLenclud@244: public bool HasModifierAlt { get; set; } = false; StephaneLenclud@244: StephaneLenclud@244: [DataMember] StephaneLenclud@244: public bool HasModifierWindows { get; set; } = false; StephaneLenclud@244: StephaneLenclud@244: StephaneLenclud@244: protected override void DoConstruct() StephaneLenclud@244: { StephaneLenclud@244: base.DoConstruct(); StephaneLenclud@244: UpdateDynamicProperties(); StephaneLenclud@244: } StephaneLenclud@244: StephaneLenclud@244: private void UpdateDynamicProperties() StephaneLenclud@244: { StephaneLenclud@244: StephaneLenclud@244: } StephaneLenclud@244: StephaneLenclud@244: StephaneLenclud@244: /// StephaneLenclud@244: /// Make sure we distinguish between various configuration of this event StephaneLenclud@244: /// StephaneLenclud@244: /// StephaneLenclud@244: public override string Brief() StephaneLenclud@244: { StephaneLenclud@244: string brief = Name + ": "; StephaneLenclud@244: StephaneLenclud@244: if (IsKeyboard) StephaneLenclud@244: { StephaneLenclud@244: brief += Key.ToString(); StephaneLenclud@244: StephaneLenclud@244: if (HasModifierAlt) StephaneLenclud@244: { StephaneLenclud@244: brief += " + ALT"; StephaneLenclud@244: } StephaneLenclud@244: StephaneLenclud@244: if (HasModifierControl) StephaneLenclud@244: { StephaneLenclud@244: brief += " + CTRL"; StephaneLenclud@244: } StephaneLenclud@244: StephaneLenclud@244: if (HasModifierShift) StephaneLenclud@244: { StephaneLenclud@244: brief += " + SHIFT"; StephaneLenclud@244: } StephaneLenclud@244: StephaneLenclud@244: if (HasModifierWindows) StephaneLenclud@244: { StephaneLenclud@244: brief += " + WIN"; StephaneLenclud@244: } StephaneLenclud@244: } StephaneLenclud@244: else if (IsGeneric) StephaneLenclud@244: { StephaneLenclud@244: StephaneLenclud@244: } StephaneLenclud@244: StephaneLenclud@244: if (IsKeyUp) StephaneLenclud@244: { StephaneLenclud@244: brief += " (UP)"; StephaneLenclud@244: } StephaneLenclud@244: else StephaneLenclud@244: { StephaneLenclud@244: brief += " (DOWN)"; StephaneLenclud@244: } StephaneLenclud@244: StephaneLenclud@244: return brief; StephaneLenclud@244: } StephaneLenclud@244: StephaneLenclud@244: /// StephaneLenclud@244: /// StephaneLenclud@244: /// StephaneLenclud@244: /// StephaneLenclud@244: /// StephaneLenclud@244: public override bool Equals(object obj) StephaneLenclud@244: { StephaneLenclud@244: if (obj is EventHidKeyboard) StephaneLenclud@244: { StephaneLenclud@244: EventHidKeyboard e = (EventHidKeyboard)obj; StephaneLenclud@244: return e.Key == Key StephaneLenclud@244: && e.IsKeyUp == IsKeyUp StephaneLenclud@244: && e.HasModifierAlt == HasModifierAlt StephaneLenclud@244: && e.HasModifierControl == HasModifierControl StephaneLenclud@244: && e.HasModifierShift == HasModifierShift StephaneLenclud@244: && e.HasModifierWindows == HasModifierWindows; StephaneLenclud@244: } StephaneLenclud@244: StephaneLenclud@244: return false; StephaneLenclud@244: } StephaneLenclud@244: } StephaneLenclud@244: }