private void _btnAddHost_Click(object sender, EventArgs e) { IPRouteHop host = (IPRouteHop)_lvRouteList.SelectedItems[0].Tag; HostPinger pinger = new HostPinger(host.HostName, host.Address); ((PingForm)Owner).AddNewHost(pinger); }
private ListViewItem FindListViewItem(IPRouteHop hop) { foreach (ListViewItem item in _lvRouteList.Items) { if (item.Tag == hop) { return(item); } } return(null); }
private void _tracer_OnHopPing(IPRouteTracer tracer, IPRouteHop hop) { if (InvokeRequired) { BeginInvoke(new IPRouteTracer.HopDelegate(_tracer_OnHopPing), tracer, hop); return; } ListViewItem item = FindListViewItem(hop); long respTime = hop.ResponseTimes[hop.PingsCompleted - 1]; item.SubItems.Add(respTime < 0 ? "*" : respTime.ToString() + " ms"); }
void hop_OnHostNameAvailable(IPRouteHop hop) { if (InvokeRequired) { BeginInvoke(new IPRouteHop.HostNameAvailableDelegate(hop_OnHostNameAvailable), hop); return; } ListViewItem item = FindListViewItem(hop); if (item != null) { item.SubItems[2].Text = hop.HostName; } }
private void _tracer_OnHopSuccess(IPRouteTracer tracer, IPRouteHop hop) { if (InvokeRequired) { BeginInvoke(new IPRouteTracer.HopDelegate(_tracer_OnHopSuccess), tracer, hop); return; } ListViewItem item = new ListViewItem(hop.Hop.ToString()); item.Tag = hop; item.SubItems.Add(hop.Address.ToString()); item.SubItems.Add(""); _lvRouteList.Items.Add(item); hop.OnHostNameAvailable += new IPRouteHop.HostNameAvailableDelegate(hop_OnHostNameAvailable); item.SubItems[2].Text = hop.HostName; _lStatus.Text = "Status: Hop " + hop.Hop + " [" + hop.Address + "] successful!"; }