Ejemplo n.º 1
0
        public void Activated(PluginRuntime pluginRuntime)
        {
            ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>();
            // We initialize the key code map here instead of in the constructor because here, we have access to the plugin's
            // directory (via the pluginRuntime parameter).
            IrInputSettings settings = settingsManager.Load <IrInputSettings>();

            _mappedKeyCodes = new Dictionary <string, Key>();
            ICollection <MappedKeyCode> keyCodes = settings.RemoteMap ??
                                                   LoadRemoteMap(pluginRuntime.Metadata.GetAbsolutePath("DefaultRemoteMap.xml"));

            foreach (MappedKeyCode mkc in keyCodes)
            {
                _mappedKeyCodes.Add(mkc.Code, mkc.Key);
            }

            Thread startupThread = new Thread(Startup)
            {
                IsBackground = true,
                Priority     = ThreadPriority.BelowNormal,
                Name         = "IrInput"
            };

            startupThread.Start();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Connects the IR client to the host configured in the settings.
        /// </summary>
        /// <returns><c>true</c>, if the client could successfully be started, else <c>false</c>.</returns>
        public bool StartClient()
        {
            ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>();
            IrInputSettings  settings        = settingsManager.Load <IrInputSettings>();
            IPAddress        serverIP        = Network.GetIPFromName(settings.ServerHost);
            IPEndPoint       endPoint        = new IPEndPoint(serverIP, Server.DefaultPort);

            return(StartClient(endPoint));
        }