protected override string TranslateToOutputPinFormat(string data, RCCServiceConfig.RemoteButtonsRow button) { if (button != null) return button.OutputData; return data; }
protected override string TranslateToOutputPinFormat(string data, RCCServiceConfig.RemoteButtonsRow button) { string output = data; if (button != null) { // keyCode, repeat, command, windowName, remoteName output = string.Format("{0},{1},{2},{3},{4}", data, 0, button.OutputData, button.TargetWndName, button.RemoteName); } return output; }
private void tsmiImportReplace_Click(object sender, EventArgs e) { OPMOpenFileDialog dlg = new OPMOpenFileDialog(); dlg.InitialDirectory = Path.Combine(Environment.CurrentDirectory, "Templates\\RemoteControl"); dlg.Filter = Translator.Translate("TXT_CONFIG_FILES_FILTER"); dlg.Title = Translator.Translate("TXT_IMPORT_FULL"); if (dlg.ShowDialog() == DialogResult.OK) { _config = new RCCServiceConfig(); _config.ReadXml(dlg.FileName); _config.AcceptChanges(); DisplayRemotes(true); } }
private void ReadFromFile() { string asmPath = Assembly.GetExecutingAssembly().Location; string folder = Path.GetDirectoryName(asmPath); _cfgPath = Path.Combine(folder, "RCCService.Config"); _config = new RCCServiceConfig(); _config.ReadXml(_cfgPath); _config.AcceptChanges(); DisplayRemotes(false); BringToFront(); }
private void tsmiExportPartial_Click(object sender, EventArgs e) { try { string selRemoteName = string.Empty; TreeNode node = tvRemotes.SelectedNode; if (node != null) { if (node.Tag is RCCServiceConfig.RemoteControlRow) { selRemoteName = (node.Tag as RCCServiceConfig.RemoteControlRow).RemoteName; } else if (node.Tag is RCCServiceConfig.RemoteButtonsRow) { selRemoteName = (node.Tag as RCCServiceConfig.RemoteButtonsRow).RemoteName; } } RCCServiceConfig partialConfig = new RCCServiceConfig(); var remote = (from rc in _config.RemoteControl where rc.RemoteName == selRemoteName select rc).FirstOrDefault(); if (remote != null) { partialConfig.RemoteControl.AddRemoteControlRow(selRemoteName, remote.InputPinName, remote.InputPinCfgData, remote.OutputPinName, remote.OutputPinCfgData, remote.Enabled); var buttons = (from rb in _config.RemoteButtons where rb.RemoteName == selRemoteName select rb); if (buttons != null) { foreach (var button in buttons) { partialConfig.RemoteButtons.AddRemoteButtonsRow(selRemoteName, button.InputData, button.OutputData, button.ButtonName, button.TargetWndName, button.Enabled, button.TimedRepeatRate); } partialConfig.RemoteButtons.AcceptChanges(); } partialConfig.RemoteControl.AcceptChanges(); OPMSaveFileDialog dlg = new OPMSaveFileDialog(); dlg.Filter = Translator.Translate("TXT_CONFIG_FILES_FILTER"); dlg.DefaultExt = "config"; dlg.Title = Translator.Translate("TXT_EXPORT_PARTIAL"); if (dlg.ShowDialog() == DialogResult.OK) { partialConfig.WriteXml(dlg.FileName); } } } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } }
public void SendRequest(string request, RCCServiceConfig.RemoteButtonsRow button) { string translatedRequest = TranslateToOutputPinFormat(request, button); SendRequestInternal(translatedRequest); }
protected override string TranslateToOutputPinFormat(string data, RCCServiceConfig.RemoteButtonsRow button) { string output = data; if (button != null) { // keyCode repeat command remoteName output = string.Format("{0} {1} {2} {3}", data, 0, button.OutputData.Replace(" ", ""), button.RemoteName.Replace(" ", "")); } return output; }
protected virtual string TranslateToOutputPinFormat(string data, RCCServiceConfig.RemoteButtonsRow button) { return data; }
private bool DispatchToOutputPin(string remoteName, string request, out RCCServiceConfig.RemoteButtonsRow button) { bool canDispatch = false; button = null; RCCServiceConfig.RemoteControlRow remote = _config.RemoteControl.FindByRemoteName(remoteName); if (remote != null && remote.Enabled) { var rows = from btn in _config.RemoteButtons where (btn.Enabled && btn.RemoteName == remoteName && btn.InputData == request) select btn; if (rows != null && rows.Count() > 0) { button = rows.First(); if (TimedButtonProcessing.CanProcessData(remoteName, button.TimedRepeatRate, request)) { canDispatch = true; Logger.LogInfo("OK to dispatch command on remote '{0}'", remoteName); } else { if (button.TimedRepeatRate > 0) { Logger.LogInfo("Can't dispatch command on remote '{2}'. Must wait {0} seconds before processing this data again: {1}", rows.First().TimedRepeatRate, request, remoteName); } else { Logger.LogInfo("Can't dispatch command on remote '{1}'. This data is to be only processed once: {0}", request, remoteName); } } } else { Logger.LogInfo("Can't dispatch command on remote '{1}'. Either there are no buttons defined for this data: {0} or they are disabled.", request, remoteName); } } else { Logger.LogInfo("Can't dispatch command on remote '{0}' as it seems to be disabled.", remoteName); } return canDispatch; }
private void tsmiExportPartial_Click(object sender, EventArgs e) { try { string selRemoteName = string.Empty; TreeNode node = tvRemotes.SelectedNode; if (node != null) { if (node.Tag is RCCServiceConfig.RemoteControlRow) { selRemoteName = (node.Tag as RCCServiceConfig.RemoteControlRow).RemoteName; } else if (node.Tag is RCCServiceConfig.RemoteButtonsRow) { selRemoteName = (node.Tag as RCCServiceConfig.RemoteButtonsRow).RemoteName; } } RCCServiceConfig partialConfig = new RCCServiceConfig(); var remote = (from rc in _config.RemoteControl where rc.RemoteName == selRemoteName select rc).FirstOrDefault(); if (remote != null) { partialConfig.RemoteControl.AddRemoteControlRow(selRemoteName, remote.InputPinName, remote.InputPinCfgData, remote.OutputPinName, remote.OutputPinCfgData, remote.Enabled); var buttons = (from rb in _config.RemoteButtons where rb.RemoteName == selRemoteName select rb); if (buttons != null) { foreach(var button in buttons) { partialConfig.RemoteButtons.AddRemoteButtonsRow(selRemoteName, button.InputData, button.OutputData, button.ButtonName, button.TargetWndName, button.Enabled, button.TimedRepeatRate); } partialConfig.RemoteButtons.AcceptChanges(); } partialConfig.RemoteControl.AcceptChanges(); OPMSaveFileDialog dlg = new OPMSaveFileDialog(); dlg.Filter = Translator.Translate("TXT_CONFIG_FILES_FILTER"); dlg.DefaultExt = "config"; dlg.Title = Translator.Translate("TXT_EXPORT_PARTIAL"); if (dlg.ShowDialog() == DialogResult.OK) { partialConfig.WriteXml(dlg.FileName); } } } catch (Exception ex) { ErrorDispatcher.DispatchError(ex); } }