private void PopulateListView() { bool itemModified = false; for (int i = 0; i < results.Count; i++) { IPScanResult result = results[i]; if (result.status == ScanStatus.Complete || result.status == ScanStatus.Partial) { string ip = result.ip.ToString(); ListViewItem[] matchedItems = lvIPList.Items.Find(ip, false); if (matchedItems.Length > 0) { matchedItems[0].Tag = result.response; matchedItems[0].SubItems[0].Text = result.ip.ToString(); matchedItems[0].SubItems[1].Text = GetPingTime(result); matchedItems[0].SubItems[2].Text = result.host; matchedItems[0].SubItems[3].Text = result.identification; } else { ListViewItem lvi = new ListViewItem(new string[] { result.ip.ToString(), GetPingTime(result), result.host, result.identification }); lvi.Name = ip; lvIPList.Items.Add(lvi); } itemModified = true; } } }
private string GetPingTime(IPScanResult result) { if (result.ping > -1) { return(result.ping + " ms"); } return("N/A"); }
private void PopulateListView() { bool itemModified = false; for (int i = 0; i < results.Count; i++) { IPScanResult result = results[i]; if (result.status == ScanStatus.Complete || result.status == ScanStatus.Partial) { if (GetPingTime(result) != "N/A" || viewAll_IP) //withouth no active ip OR view all ip adress { string ip = result.ip.ToString(); ListViewItem[] matchedItems = lvIPList.Items.Find(ip, false); if (matchedItems.Length > 0) { matchedItems[0].Tag = result.response; matchedItems[0].SubItems[0].Text = result.ip.ToString(); matchedItems[0].SubItems[1].Text = GetPingTime(result); matchedItems[0].SubItems[2].Text = result.host; matchedItems[0].SubItems[3].Text = result.identification; if (result.identification.Length > 4) // if HttpTitle find { matchedItems[0].BackColor = Color.Aqua; } } else { ListViewItem lvi = new ListViewItem(new string[] { result.ip.ToString(), GetPingTime(result), result.host, result.identification }); lvi.Name = ip; lvIPList.Items.Add(lvi); } itemModified = true; } } } }