Server/Actions/ActionCecUserControlReleased.cs
author StephaneLenclud
Wed, 27 Jul 2016 11:07:35 +0200
changeset 222 0e8c6c2f4777
child 223 f6272f65d8fc
permissions -rw-r--r--
Adding send and release CEC key actions.
Edit action ComboBox now sorted and selecting proper item.
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@222
    17
    [AttributeAction(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@222
    27
        [AttributeActionProperty(
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@222
    51
        public override void Execute()
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
}