Server/Actions/ActionCecDevicePowerOn.cs
author StephaneLenclud
Tue, 26 Jul 2016 15:30:46 +0200
changeset 221 5770478e1fe3
parent 220 e5910d7b6a81
child 222 0e8c6c2f4777
permissions -rw-r--r--
Improved support for action enum properties.
     1 using CecSharp;
     2 using SharpLib.Ear;
     3 using System;
     4 using System.Collections.Generic;
     5 using System.Linq;
     6 using System.Runtime.InteropServices;
     7 using System.Runtime.Serialization;
     8 using System.Text;
     9 using System.Threading.Tasks;
    10 
    11 namespace SharpDisplayManager
    12 {
    13     [DataContract]
    14     [AttributeAction(Id = "Cec.Device.PowerOn", Name = "CEC Device Power On", Description = "Turns on the specified CEC device on your HDMI bus.")]
    15     public class ActionCecDevicePowerOn : ActionCecDevice
    16     {
    17         /// <summary>
    18         /// 
    19         /// </summary>
    20         /// <returns></returns>
    21         public override string Brief()
    22         {
    23             if (Device == CecLogicalAddress.Broadcast)
    24             {
    25                 //Because of duplicated values it would display Unregistered
    26                 return "CEC Power On Broadcast";
    27             }
    28 
    29             return "CEC Power On " + Device.ToString();
    30         }
    31 
    32         /// <summary>
    33         /// 
    34         /// </summary>
    35         public override void Execute()
    36         {
    37             if (Cec.Client.Static == null)
    38             {
    39                 Console.WriteLine("WARNING: No CEC client installed.");
    40                 return;
    41             }
    42 
    43             Cec.Client.Static.Lib.PowerOnDevices(Device);
    44         }
    45     }
    46 }