Server/Actions/ActionCecUserControlReleased.cs
author StephaneLenclud
Thu, 25 Aug 2016 13:34:05 +0200
changeset 255 c57b8ac80fc6
parent 231 4c706feaf706
child 258 e237c2e33545
permissions -rw-r--r--
Published v1.0.2.0.
Fixed Harmony async issue prevent the config to be fetched.
     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 = Name + " to " + DeviceName;
    42             if (Wait)
    43             {
    44                 brief += " (wait)";
    45             }
    46             return brief;
    47         }
    48 
    49         /// <summary>
    50         /// 
    51         /// </summary>
    52         protected override void 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 }