StephaneLenclud@222: using CecSharp; StephaneLenclud@222: using SharpLib.Ear; StephaneLenclud@222: using System; StephaneLenclud@222: using System.Collections.Generic; StephaneLenclud@222: using System.Linq; StephaneLenclud@222: using System.Runtime.InteropServices; StephaneLenclud@222: using System.Runtime.Serialization; StephaneLenclud@222: using System.Text; StephaneLenclud@222: using System.Threading.Tasks; StephaneLenclud@222: StephaneLenclud@222: namespace SharpDisplayManager StephaneLenclud@222: { StephaneLenclud@222: /// StephaneLenclud@222: /// Send a user key press event to the given CEC device. StephaneLenclud@222: /// StephaneLenclud@222: [DataContract] StephaneLenclud@231: [AttributeObject(Id = "Cec.UserControlPressed", Name = "CEC User Control Pressed", Description = "Send user control code to defined CEC device.")] StephaneLenclud@222: public class ActionCecUserControlPressed : ActionCecDevice StephaneLenclud@222: { StephaneLenclud@222: StephaneLenclud@222: public ActionCecUserControlPressed() StephaneLenclud@222: { StephaneLenclud@222: Wait = true; StephaneLenclud@222: } StephaneLenclud@222: StephaneLenclud@222: [DataMember] StephaneLenclud@231: [AttributeObjectProperty( StephaneLenclud@222: Id = "Cec.UserControlPressed.Code", StephaneLenclud@222: Name = "Code", StephaneLenclud@222: Description = "The key code used by this action." StephaneLenclud@222: )] StephaneLenclud@222: public CecUserControlCode Code { get; set; } StephaneLenclud@222: StephaneLenclud@222: [DataMember] StephaneLenclud@231: [AttributeObjectProperty( StephaneLenclud@222: Id = "Cec.UserControlPressed.Wait", StephaneLenclud@222: Name = "Wait", StephaneLenclud@222: Description = "Wait for that command." StephaneLenclud@222: )] StephaneLenclud@222: public bool Wait { get; set; } StephaneLenclud@222: StephaneLenclud@222: /// StephaneLenclud@222: /// StephaneLenclud@222: /// StephaneLenclud@222: /// StephaneLenclud@222: public override string Brief() StephaneLenclud@222: { StephaneLenclud@222: string brief = Name + ": " + Code.ToString() + " to " + DeviceName; StephaneLenclud@222: if (Wait) StephaneLenclud@222: { StephaneLenclud@222: brief += " (wait)"; StephaneLenclud@222: } StephaneLenclud@222: return brief; StephaneLenclud@222: } StephaneLenclud@222: StephaneLenclud@222: /// StephaneLenclud@222: /// StephaneLenclud@222: /// StephaneLenclud@228: protected override void DoExecute() StephaneLenclud@222: { StephaneLenclud@222: if (Cec.Client.Static == null) StephaneLenclud@222: { StephaneLenclud@222: Console.WriteLine("WARNING: No CEC client installed."); StephaneLenclud@222: return; StephaneLenclud@222: } StephaneLenclud@222: StephaneLenclud@222: Cec.Client.Static.Lib.SendKeypress(Device, Code, Wait); StephaneLenclud@222: } StephaneLenclud@222: } StephaneLenclud@222: }