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