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