Server/Actions/ActionCecUserControlReleased.cs
author StephaneLenclud
Wed, 27 Jul 2016 11:07:35 +0200
changeset 222 0e8c6c2f4777
child 223 f6272f65d8fc
permissions -rw-r--r--
Adding send and release CEC key actions.
Edit action ComboBox now sorted and selecting proper item.
     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     [AttributeAction(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         [AttributeActionProperty(
    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         public override void Execute()
    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 }