Server/Actions/ActionCecActiveSource.cs
author StephaneLenclud
Fri, 12 Aug 2016 20:25:05 +0200
changeset 231 4c706feaf706
parent 228 6a84d8282226
child 253 2dae7a163fff
permissions -rw-r--r--
Events can now be instantiated.
Action editor is now a generic object editor.
StephaneLenclud@214
     1
using CecSharp;
StephaneLenclud@214
     2
using SharpLib.Ear;
StephaneLenclud@214
     3
using System;
StephaneLenclud@214
     4
using System.Collections.Generic;
StephaneLenclud@214
     5
using System.Linq;
StephaneLenclud@214
     6
using System.Runtime.Serialization;
StephaneLenclud@214
     7
using System.Text;
StephaneLenclud@214
     8
using System.Threading.Tasks;
StephaneLenclud@214
     9
StephaneLenclud@214
    10
namespace SharpDisplayManager
StephaneLenclud@214
    11
{
StephaneLenclud@214
    12
    [DataContract]
StephaneLenclud@231
    13
    [AttributeObject(Id = "Cec.ActiveSource", Name = "CEC Active Source", Description = "Set this CEC device as active source.")]
StephaneLenclud@222
    14
    class ActionCecActiveSource : ActionCecDeviceType
StephaneLenclud@214
    15
    {
StephaneLenclud@222
    16
        /// <summary>
StephaneLenclud@222
    17
        /// Build a user readable string to describe this action.
StephaneLenclud@222
    18
        /// </summary>
StephaneLenclud@222
    19
        /// <returns></returns>
StephaneLenclud@222
    20
        public override string Brief()
StephaneLenclud@222
    21
        {
StephaneLenclud@222
    22
            return "CEC Active Source to " + DeviceType.ToString();
StephaneLenclud@222
    23
        }
StephaneLenclud@222
    24
StephaneLenclud@222
    25
        /// <summary>
StephaneLenclud@222
    26
        /// Set the defined device type as active source.
StephaneLenclud@222
    27
        /// </summary>
StephaneLenclud@228
    28
        protected override void DoExecute()
StephaneLenclud@214
    29
        {
StephaneLenclud@214
    30
            if (Cec.Client.Static == null)
StephaneLenclud@214
    31
            {
StephaneLenclud@214
    32
                Console.WriteLine("WARNING: No CEC client installed.");
StephaneLenclud@222
    33
                return;
StephaneLenclud@214
    34
            }
StephaneLenclud@214
    35
StephaneLenclud@222
    36
            Cec.Client.Static.Lib.SetActiveSource(DeviceType);
StephaneLenclud@214
    37
        }
StephaneLenclud@214
    38
    }
StephaneLenclud@214
    39
}