StephaneLenclud@222: using CecSharp;
StephaneLenclud@222: using SharpLib.Ear;
StephaneLenclud@222: using System;
StephaneLenclud@222: using System.Collections.Generic;
StephaneLenclud@253: using System.Diagnostics;
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@264: public override string BriefBase()
StephaneLenclud@222: {
StephaneLenclud@260: string brief = AttributeName + ": " + 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@258: protected override async Task DoExecute()
StephaneLenclud@222: {
StephaneLenclud@222: if (Cec.Client.Static == null)
StephaneLenclud@222: {
StephaneLenclud@253: Trace.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: }