/// <summary> /// Decodes incoming Infra-Red signal's remote key into WinLIRC.NET remote key format /// </summary> /// <param name="signal">WinLIRC.NET signal</param> private void FindRemote(ref Signal signal) { try { ConfigurationSource file = new ConfigurationSource(); bool identified = false; foreach (irconfig config in file.ReadXml(new FileInfo(TransmitterSettings.Default.RemoteKeys))) { foreach (code code in config.remote_codes) { if (((int)signal.RemoteKey) == ((int)code.key)) { signal.RemoteName = config.name; signal.KeyCode = code.value; signal.KeyName = code.name; signal.RepeatCount = 0; identified = true; break; } } if (identified) { break; } } } catch (Exception e) { e.HandleException(); } }
/// <summary> /// Handler to read WinLIRC.NET XML formatted configuration /// </summary> /// <param name="sender">Object which raised the event</param> /// <param name="e">Event arguments</param> private void OnXmlConfigRead(object sender, EventArgs e) { try { OpenFileDialog d = new OpenFileDialog(); d.AddExtension = true; d.CheckFileExists = true; d.CheckPathExists = true; d.Multiselect = false; d.RestoreDirectory = true; d.Title = "Select XML WinLIRC configuration file to open"; d.ValidateNames = true; d.Filter = "All Files|*.*"; d.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); if (d.ShowDialog() == DialogResult.OK) { Invalidate(); if (_file != null) { _config = _file.ReadXml(new FileInfo(d.FileName)); if (_config != null && _config.Count > 0) { foreach (irconfig c in _config) { cboIndex.Items.Add(c.name); } cboIndex.SelectedIndex = 0; } } } } catch (Exception err) { Program.HandleException(err); } }
/// <summary> /// Decodes incoming Infra-Red signal's remote key into WinLIRC.NET remote key format /// </summary> /// <param name="signal">WinLIRC.NET signal</param> private void FindRemoteKey(ref Signal signal) { try { Trace.TraceInformation("Attempting to detect remote key for signal {0}...", signal.ToString()); ConfigurationSource file = new ConfigurationSource(); foreach (irconfig config in file.ReadXml(new FileInfo(ReceiverSettings.Default.RemoteKeys))) { if (signal.RemoteName.Equals(config.name)) { foreach (code code in config.remote_codes) { if (signal.KeyName.Equals(code.name)) { signal.RemoteKey = (RemoteKey)(int)code.key; Trace.TraceInformation("RemoteKey found - {0}.", signal.RemoteKey.ToString()); break; } } break; } } if (signal.RemoteKey == RemoteKey.Unknown) { Trace.TraceWarning("Unknown remote key signal received"); } } catch (Exception e) { e.HandleException(); } }