Server/Actions/ActionCecUserControlReleased.cs
changeset 222 0e8c6c2f4777
child 223 f6272f65d8fc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Server/Actions/ActionCecUserControlReleased.cs	Wed Jul 27 11:07:35 2016 +0200
     1.3 @@ -0,0 +1,62 @@
     1.4 +using CecSharp;
     1.5 +using SharpLib.Ear;
     1.6 +using System;
     1.7 +using System.Collections.Generic;
     1.8 +using System.Linq;
     1.9 +using System.Runtime.InteropServices;
    1.10 +using System.Runtime.Serialization;
    1.11 +using System.Text;
    1.12 +using System.Threading.Tasks;
    1.13 +
    1.14 +namespace SharpDisplayManager
    1.15 +{
    1.16 +    /// <summary>
    1.17 +    /// Send a user key press event to the given CEC device.
    1.18 +    /// </summary>
    1.19 +    [DataContract]
    1.20 +    [AttributeAction(Id = "Cec.UserControlReleased", Name = "CEC User Control Released", Description = "Send user control release opcode to a given CEC device.")]
    1.21 +    public class ActionCecUserControlReleased : ActionCecDevice
    1.22 +    {
    1.23 +
    1.24 +        public ActionCecUserControlReleased()
    1.25 +        {
    1.26 +            Wait = true;
    1.27 +        }
    1.28 +
    1.29 +        [DataMember]
    1.30 +        [AttributeActionProperty(
    1.31 +        Id = "Cec.UserControlPressed.Wait",
    1.32 +        Name = "Wait",
    1.33 +        Description = "Wait for that command."
    1.34 +        )]
    1.35 +        public bool Wait { get; set; }
    1.36 +
    1.37 +        /// <summary>
    1.38 +        /// 
    1.39 +        /// </summary>
    1.40 +        /// <returns></returns>
    1.41 +        public override string Brief()
    1.42 +        {
    1.43 +            string brief = Name + " to " + DeviceName;
    1.44 +            if (Wait)
    1.45 +            {
    1.46 +                brief += " (wait)";
    1.47 +            }
    1.48 +            return brief;
    1.49 +        }
    1.50 +
    1.51 +        /// <summary>
    1.52 +        /// 
    1.53 +        /// </summary>
    1.54 +        public override void Execute()
    1.55 +        {
    1.56 +            if (Cec.Client.Static == null)
    1.57 +            {
    1.58 +                Console.WriteLine("WARNING: No CEC client installed.");
    1.59 +                return;
    1.60 +            }
    1.61 +
    1.62 +            Cec.Client.Static.Lib.SendKeyRelease(Device, Wait);
    1.63 +        }
    1.64 +    }
    1.65 +}