Server/Actions/ActionCecUserControlReleased.cs
author StephaneLenclud
Thu, 18 Aug 2016 18:49:03 +0200
changeset 241 3b5a94f31400
parent 228 6a84d8282226
child 253 2dae7a163fff
permissions -rw-r--r--
Adding support for HID Keyboard events.
     1 using CecSharp;
     2 using SharpLib.Ear;
     3 using System;
     4 using System.Collections.Generic;
     5 using System.Linq;
     6 using System.Runtime.InteropServices;
     7 using System.Runtime.Serialization;
     8 using System.Text;
     9 using System.Threading.Tasks;
    10 
    11 namespace SharpDisplayManager
    12 {
    13     /// <summary>
    14     /// Send a user key press event to the given CEC device.
    15     /// </summary>
    16     [DataContract]
    17     [AttributeObject(Id = "Cec.UserControlReleased", Name = "CEC User Control Released", Description = "Send user control release opcode to a given CEC device.")]
    18     public class ActionCecUserControlReleased : ActionCecDevice
    19     {
    20 
    21         public ActionCecUserControlReleased()
    22         {
    23             Wait = true;
    24         }
    25 
    26         [DataMember]
    27         [AttributeObjectProperty(
    28         Id = "Cec.UserControlPressed.Wait",
    29         Name = "Wait",
    30         Description = "Wait for that command."
    31         )]
    32         public bool Wait { get; set; }
    33 
    34         /// <summary>
    35         /// 
    36         /// </summary>
    37         /// <returns></returns>
    38         public override string Brief()
    39         {
    40             string brief = Name + " to " + DeviceName;
    41             if (Wait)
    42             {
    43                 brief += " (wait)";
    44             }
    45             return brief;
    46         }
    47 
    48         /// <summary>
    49         /// 
    50         /// </summary>
    51         protected override void DoExecute()
    52         {
    53             if (Cec.Client.Static == null)
    54             {
    55                 Console.WriteLine("WARNING: No CEC client installed.");
    56                 return;
    57             }
    58 
    59             Cec.Client.Static.Lib.SendKeyRelease(Device, Wait);
    60         }
    61     }
    62 }