StephaneLenclud@241: using System;
StephaneLenclud@241: using System.Collections.Generic;
StephaneLenclud@241: using System.Linq;
StephaneLenclud@241: using System.Text;
StephaneLenclud@241: using System.Threading.Tasks;
StephaneLenclud@241: using System.Runtime.Serialization;
StephaneLenclud@241: using System.Windows.Forms;
StephaneLenclud@241: using Ear = SharpLib.Ear;
StephaneLenclud@241: using Hid = SharpLib.Hid;
StephaneLenclud@241:
StephaneLenclud@241: namespace SharpDisplayManager
StephaneLenclud@241: {
StephaneLenclud@241: [DataContract]
StephaneLenclud@241: [Ear.AttributeObject(Id = "Event.Hid.Keyboard", Name = "HID Keyboard", Description = "Corresponding HID message received.")]
StephaneLenclud@241: public class EventHidKeyboard : Ear.Event
StephaneLenclud@241: {
StephaneLenclud@241: public EventHidKeyboard()
StephaneLenclud@241: {
StephaneLenclud@241: }
StephaneLenclud@241:
StephaneLenclud@241: [DataMember]
StephaneLenclud@241: [Ear.AttributeObjectProperty
StephaneLenclud@241: (
StephaneLenclud@241: Id = "HID.Keyboard.Key",
StephaneLenclud@241: Name = "Key",
StephaneLenclud@241: Description = "The virtual key code."
StephaneLenclud@241: )]
StephaneLenclud@241: public Keys Key { get; set; }
StephaneLenclud@241:
StephaneLenclud@241: [DataMember]
StephaneLenclud@241: [Ear.AttributeObjectProperty
StephaneLenclud@241: (
StephaneLenclud@241: Id = "HID.Keyboard.IsKeyUp",
StephaneLenclud@241: Name = "Key Up",
StephaneLenclud@241: Description = "Key up if set, key down otherwise."
StephaneLenclud@241: )]
StephaneLenclud@241: public bool IsKeyUp { get; set; } = true;
StephaneLenclud@241:
StephaneLenclud@241: [DataMember]
StephaneLenclud@241: [Ear.AttributeObjectProperty
StephaneLenclud@241: (
StephaneLenclud@241: Id = "HID.Keyboard.HasModifierShift",
StephaneLenclud@241: Name = "Shift",
StephaneLenclud@241: Description = "Shift modifier applied."
StephaneLenclud@241: )]
StephaneLenclud@241: public bool HasModifierShift { get; set; } = false;
StephaneLenclud@241:
StephaneLenclud@241: [DataMember]
StephaneLenclud@241: [Ear.AttributeObjectProperty
StephaneLenclud@241: (
StephaneLenclud@241: Id = "HID.Keyboard.HasModifierControl",
StephaneLenclud@241: Name = "Control",
StephaneLenclud@241: Description = "Control modifier applied."
StephaneLenclud@241: )]
StephaneLenclud@241: public bool HasModifierControl { get; set; } = false;
StephaneLenclud@241:
StephaneLenclud@241: [DataMember]
StephaneLenclud@241: [Ear.AttributeObjectProperty
StephaneLenclud@241: (
StephaneLenclud@241: Id = "HID.Keyboard.HasModifierAlt",
StephaneLenclud@241: Name = "Alt",
StephaneLenclud@241: Description = "Alt modifier applied."
StephaneLenclud@241: )]
StephaneLenclud@241: public bool HasModifierAlt { get; set; } = false;
StephaneLenclud@241:
StephaneLenclud@241: [DataMember]
StephaneLenclud@241: [Ear.AttributeObjectProperty
StephaneLenclud@241: (
StephaneLenclud@241: Id = "HID.Keyboard.HasModifierWindows",
StephaneLenclud@241: Name = "Windows",
StephaneLenclud@241: Description = "Windows modifier applied."
StephaneLenclud@241: )]
StephaneLenclud@241: public bool HasModifierWindows { get; set; } = false;
StephaneLenclud@241:
StephaneLenclud@241:
StephaneLenclud@241:
StephaneLenclud@241: ///
StephaneLenclud@241: /// Make sure we distinguish between various configuration of this event
StephaneLenclud@241: ///
StephaneLenclud@241: ///
StephaneLenclud@241: public override string Brief()
StephaneLenclud@241: {
StephaneLenclud@241: string brief = Name + ": " + Key.ToString();
StephaneLenclud@241:
StephaneLenclud@241: if (IsKeyUp)
StephaneLenclud@241: {
StephaneLenclud@241: brief += " (UP)";
StephaneLenclud@241: }
StephaneLenclud@241: else
StephaneLenclud@241: {
StephaneLenclud@241: brief += " (DOWN)";
StephaneLenclud@241: }
StephaneLenclud@241:
StephaneLenclud@241: if (HasModifierAlt)
StephaneLenclud@241: {
StephaneLenclud@241: brief += " + ALT";
StephaneLenclud@241: }
StephaneLenclud@241:
StephaneLenclud@241: if (HasModifierControl)
StephaneLenclud@241: {
StephaneLenclud@241: brief += " + CTRL";
StephaneLenclud@241: }
StephaneLenclud@241:
StephaneLenclud@241: if (HasModifierShift)
StephaneLenclud@241: {
StephaneLenclud@241: brief += " + SHIFT";
StephaneLenclud@241: }
StephaneLenclud@241:
StephaneLenclud@241: if (HasModifierWindows)
StephaneLenclud@241: {
StephaneLenclud@241: brief += " + WIN";
StephaneLenclud@241: }
StephaneLenclud@241:
StephaneLenclud@241: return brief;
StephaneLenclud@241: }
StephaneLenclud@241:
StephaneLenclud@241: ///
StephaneLenclud@241: ///
StephaneLenclud@241: ///
StephaneLenclud@241: ///
StephaneLenclud@241: ///
StephaneLenclud@241: public override bool Equals(object obj)
StephaneLenclud@241: {
StephaneLenclud@241: if (obj is EventHidKeyboard)
StephaneLenclud@241: {
StephaneLenclud@241: EventHidKeyboard e = (EventHidKeyboard)obj;
StephaneLenclud@241: return e.Key == Key
StephaneLenclud@241: && e.IsKeyUp == IsKeyUp
StephaneLenclud@241: && e.HasModifierAlt == HasModifierAlt
StephaneLenclud@241: && e.HasModifierControl == HasModifierControl
StephaneLenclud@241: && e.HasModifierShift == HasModifierShift
StephaneLenclud@241: && e.HasModifierWindows == HasModifierWindows;
StephaneLenclud@241: }
StephaneLenclud@241:
StephaneLenclud@241: return false;
StephaneLenclud@241: }
StephaneLenclud@241: }
StephaneLenclud@241: }