private void AddFoundConnections(IEnumerable<Info> iEnumerable) { try { var l = new List<EXImageListViewItem>(); foreach (var info in iEnumerable) { var item = new EXImageListViewItem { Tag = info }; item.SubItems.Add(new EXBoolListViewSubItem(true)); item.SubItems.Add(new EXImageListViewSubItem(Connection.Icon.FromString(info.Icon).ToBitmap())); item.SubItems.Add(info.Description); item.SubItems.Add(info.Protocol.ToString()); item.SubItems.Add(info.Hostname); item.SubItems.Add(info.Port.ToString()); l.Add(item); } if (lvFoundConections.InvokeRequired) { lvFoundConections.Invoke(new MethodInvoker(() => { lvFoundConections.Items.AddRange(l.ToArray()); })); } else { lvFoundConections.Items.AddRange(l.ToArray()); } } catch (Exception) { } }
IEnumerable<TreeNode> GetAllNodes(TreeNode nodes) { var allNodes = new List<TreeNode>(); allNodes.Add(nodes); foreach (TreeNode tn in nodes.Nodes) { allNodes.AddRange(GetAllNodes(tn)); } return allNodes; }