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