NotificationPlugin.cs
changeset 0 99720d48e299
child 1 b4df02a92dff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/NotificationPlugin.cs	Tue Dec 08 13:52:15 2015 +0100
     1.3 @@ -0,0 +1,127 @@
     1.4 +using System;
     1.5 +using System.Collections.Generic;
     1.6 +using System.Linq;
     1.7 +using System.Text;
     1.8 +using System.Threading.Tasks;
     1.9 +using System.Reflection;
    1.10 +
    1.11 +using SetupTv;
    1.12 +using TvControl;
    1.13 +using TvEngine;
    1.14 +using System.Drawing;
    1.15 +using System.IO;
    1.16 +using TvLibrary.Log;
    1.17 +
    1.18 +
    1.19 +namespace TvServerPlugin
    1.20 +{
    1.21 +
    1.22 +
    1.23 +    public class RecordSatus : ITvServerPlugin
    1.24 +    {
    1.25 +
    1.26 +        /// <summary>
    1.27 +        /// Reference to the tvservice's TVcontroller
    1.28 +        /// </summary>
    1.29 +        private IController _controller;
    1.30 +
    1.31 +
    1.32 +        /// <summary>
    1.33 +        /// Creates a new PowerScheduler plugin
    1.34 +        /// </summary>
    1.35 +        public RecordSatus() { }
    1.36 +
    1.37 +    
    1.38 +        /// <summary>
    1.39 +        /// Called by the tvservice PluginLoader to start this plugin
    1.40 +        /// </summary>
    1.41 +        /// <param name="controller">Reference to the tvservice's TVController</param>
    1.42 +        public void Start(IController controller)
    1.43 +        {
    1.44 +            Log.Debug(Name + " start - begins");
    1.45 +
    1.46 +            _controller = controller;
    1.47 +
    1.48 +            Log.Debug(Name + " start - ends");
    1.49 +        }
    1.50 +
    1.51 +        /// <summary>
    1.52 +        /// Called by the tvservice PluginLoader to stop this plugin
    1.53 +        /// </summary>
    1.54 +        public void Stop()
    1.55 +        {
    1.56 +            Log.Debug(Name + " stop");
    1.57 +            _controller = null;
    1.58 +            //PowerScheduler.Instance.Stop();
    1.59 +        }
    1.60 +
    1.61 +        /// <summary>
    1.62 +        /// Author of this plugin
    1.63 +        /// </summary>
    1.64 +        public string Author
    1.65 +        {
    1.66 +            get { return "Stéphane Lenclud"; }
    1.67 +        }
    1.68 +
    1.69 +        /// <summary>
    1.70 +        /// Should this plugin run only on a master tvserver?
    1.71 +        /// </summary>
    1.72 +        public bool MasterOnly
    1.73 +        {
    1.74 +            get { return false; }
    1.75 +        }
    1.76 +
    1.77 +        /// <summary>
    1.78 +        /// Name of this plugin
    1.79 +        /// </summary>
    1.80 +        public string Name
    1.81 +        {
    1.82 +            get
    1.83 +            {
    1.84 +                return "NotificationTvServerPlugin";
    1.85 +            }
    1.86 +        }
    1.87 +
    1.88 +        /// <summary>
    1.89 +        /// Returns the SectionSettings setup part of this plugin
    1.90 +        /// </summary>
    1.91 +        public SectionSettings Setup
    1.92 +        {
    1.93 +            get { return new RecordStatusSetup(); }
    1.94 +        }
    1.95 +
    1.96 +        /// <summary>
    1.97 +        /// Plugin version
    1.98 +        /// </summary>
    1.99 +        public string Version
   1.100 +        {
   1.101 +            get { return Assembly.GetExecutingAssembly().GetName().Version.ToString(); }
   1.102 +        }
   1.103 +
   1.104 +
   1.105 +        /// <summary>
   1.106 +        /// Access icons from embedded resources.
   1.107 +        /// </summary>
   1.108 +        /// <param name="name"></param>
   1.109 +        /// <returns></returns>
   1.110 +        public static Icon GetIcon(string name)
   1.111 +        {
   1.112 +            string[] names = Assembly.GetExecutingAssembly().GetManifestResourceNames();
   1.113 +            for (int i = 0; i < names.Length; i++)
   1.114 +            {
   1.115 +                if (names[i].EndsWith(name))
   1.116 +                {
   1.117 +                    using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(names[i]))
   1.118 +                    {
   1.119 +                        return new Icon(stream);
   1.120 +                    }
   1.121 +                }
   1.122 +            }
   1.123 +
   1.124 +            return null;
   1.125 +        }
   1.126 +
   1.127 +
   1.128 +    }
   1.129 +
   1.130 +}