private void DisplayButtonsData() { lvButtons.Items.Clear(); var buttonRows = from btn in _config.RemoteButtons where (btn.RemoteName == _remoteControl.RemoteName) select btn; if (buttonRows != null) { foreach (RCCServiceConfig.RemoteButtonsRow buttonRow in buttonRows) { string[] data = new string[] { buttonRow.ButtonName, Translator.Translate(buttonRow.Enabled ? "TXT_YES" : "TXT_NO"), buttonRow.InputData, _remoteControl.OutputPinName == (typeof(ProTONEOutputPin)).Name ? CommandMapper.GetCommandDescription(buttonRow.OutputData) : buttonRow.OutputData }; ListViewItem item = new ListViewItem(data); item.Tag = buttonRow; lvButtons.Items.Add(item); } } }
private void DisplayRemotes(bool modified) { _modified = modified; string selectedNodeText = string.Empty; string indicator = _modified ? " [*]" : string.Empty; SetTitle(Translator.TranslatedAppName + indicator); tvRemotes.SuspendLayout(); try { List <TreeNode> treeNodes = new List <TreeNode>(); Font remoteFont = ThemeManager.LargeFont; Font buttonFont = ThemeManager.SmallFont; foreach (RCCServiceConfig.RemoteControlRow remoteRow in _config.RemoteControl) { TreeNode remoteNode = new TreeNode(Translator.Translate("TXT_DEVICENAME", remoteRow.RemoteName)); remoteNode.Tag = remoteRow; remoteNode.NodeFont = remoteFont; remoteNode.ImageIndex = remoteRow.Enabled ? (int)TreeImages.Remote : (int)TreeImages.RemoteDisabled; remoteNode.SelectedImageIndex = remoteRow.Enabled ? (int)TreeImages.Remote : (int)TreeImages.RemoteDisabled; TreeNode inputNode = new TreeNode(Translator.Translate("TXT_INPUTPIN", remoteRow.InputPinName, string.IsNullOrEmpty(remoteRow.InputPinCfgData) ? string.Empty : "[ " + remoteRow.InputPinCfgData + " ]")); inputNode.Tag = remoteRow; inputNode.NodeFont = buttonFont; inputNode.ImageIndex = remoteRow.Enabled ? (int)TreeImages.Pin : (int)TreeImages.PinDisabled; inputNode.SelectedImageIndex = remoteRow.Enabled ? (int)TreeImages.Pin : (int)TreeImages.PinDisabled; remoteNode.Nodes.Add(inputNode); TreeNode outputNode = new TreeNode(Translator.Translate("TXT_OUTPUTPIN", remoteRow.OutputPinName, string.IsNullOrEmpty(remoteRow.OutputPinCfgData) ? string.Empty : "[ " + remoteRow.OutputPinCfgData + " ]")); outputNode.Tag = remoteRow; outputNode.NodeFont = buttonFont; outputNode.ImageIndex = remoteRow.Enabled ? (int)TreeImages.Pin : (int)TreeImages.PinDisabled; outputNode.SelectedImageIndex = remoteRow.Enabled ? (int)TreeImages.Pin : (int)TreeImages.PinDisabled; remoteNode.Nodes.Add(outputNode); var buttonRows = from btn in _config.RemoteButtons where btn.RemoteName == remoteRow.RemoteName select btn; if (buttonRows != null && buttonRows.Count() > 0) { TreeNode buttonsNode = new TreeNode(Translator.Translate("TXT_BUTTONS")); buttonsNode.Tag = remoteRow; buttonsNode.NodeFont = buttonFont; buttonsNode.ImageIndex = remoteRow.Enabled ? (int)TreeImages.Buttons : (int)TreeImages.ButtonsDisabled; buttonsNode.SelectedImageIndex = remoteRow.Enabled ? (int)TreeImages.Buttons : (int)TreeImages.ButtonsDisabled; remoteNode.Nodes.Add(buttonsNode); foreach (RCCServiceConfig.RemoteButtonsRow buttonRow in buttonRows) { TreeNode buttonNode = new TreeNode(Translator.Translate("TXT_BUTTONNAME_FULL", buttonRow.ButtonName, buttonRow.InputData, remoteRow.OutputPinName == (typeof(ProTONEOutputPin)).Name ? CommandMapper.GetCommandDescription(buttonRow.OutputData) : buttonRow.OutputData)); buttonNode.NodeFont = buttonFont; buttonNode.ImageIndex = (remoteRow.Enabled && buttonRow.Enabled) ? (int)TreeImages.Button : (int)TreeImages.ButtonDisabled; buttonNode.SelectedImageIndex = (remoteRow.Enabled && buttonRow.Enabled) ? (int)TreeImages.Button : (int)TreeImages.ButtonDisabled; buttonNode.Tag = buttonRow; buttonsNode.Nodes.Add(buttonNode); } } else if (remoteRow.InputPinName == typeof(RemotingInputPin).Name && remoteRow.OutputPinName == typeof(ProTONEOutputPin).Name) { TreeNode buttonsNode = new TreeNode(Translator.Translate("TXT_NOBUTTONSREQUIRED")); buttonsNode.ImageIndex = remoteRow.Enabled ? (int)TreeImages.Buttons : (int)TreeImages.ButtonsDisabled; buttonsNode.SelectedImageIndex = remoteRow.Enabled ? (int)TreeImages.Buttons : (int)TreeImages.ButtonsDisabled; buttonsNode.Tag = remoteRow; buttonsNode.NodeFont = buttonFont; remoteNode.Nodes.Add(buttonsNode); } else { TreeNode buttonsNode = new TreeNode(Translator.Translate("TXT_NO_BUTTONS_YET")); buttonsNode.ImageIndex = remoteRow.Enabled ? (int)TreeImages.Buttons : (int)TreeImages.ButtonsDisabled; buttonsNode.SelectedImageIndex = remoteRow.Enabled ? (int)TreeImages.Buttons : (int)TreeImages.ButtonsDisabled; buttonsNode.Tag = remoteRow; buttonsNode.NodeFont = buttonFont; remoteNode.Nodes.Add(buttonsNode); } treeNodes.Add(remoteNode); } if (tvRemotes.SelectedNode != null) { selectedNodeText = tvRemotes.SelectedNode.Text; } tvRemotes.Nodes.Clear(); tvRemotes.Nodes.AddRange(treeNodes.ToArray()); } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } finally { tvRemotes.ExpandAll(); ConstructTooltips(); if (!string.IsNullOrEmpty(selectedNodeText)) { TreeNode node = tvRemotes.FindNode(selectedNodeText, false); if (node != null) { tvRemotes.SelectedNode = node; } } if (tvRemotes.SelectedNode == null && tvRemotes.Nodes != null && tvRemotes.Nodes.Count > 0) { tvRemotes.SelectedNode = tvRemotes.Nodes[0]; } tvRemotes.ResumeLayout(); } }