Ejemplo n.º 1
0
        private void lookupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedCells.Count == 1)
            {
                DataGridViewCell dc = dataGridView1.SelectedCells[0];
                DataGridViewColumn dgc = dataGridView1.Columns[dc.ColumnIndex];
                if (dgc.Name.Equals("src-ip") || dgc.Name.Equals("dst-ip"))
                {
                    string Ip = dc.Value.ToString();
                    if (!Ip.StartsWith("192.168") && !Ip.StartsWith("255.") && !Ip.Equals("239.255.255.250"))
                    {
                        
                            System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
                            ping.PingCompleted += (a, b) =>
                            {
                                MessageBox.Show(Ip + "\n" + b.Reply.Status.ToString());
                            };
                            IPAddress address;
                            if (IPAddress.TryParse(Ip, out address))
                            {
                                if (!iptrace.ContainsKey(address))
                                {
                                    if (!iphost.ContainsKey(address))
                                    {
                                        try
                                        {
                                            IPHostEntry iph = System.Net.Dns.EndGetHostEntry(System.Net.Dns.BeginGetHostEntry(address, (a) =>
                                            {
                                                if (a.IsCompleted)
                                                {
                                                    string s = "";
                                                }
                                            }, null));
                                            iphost.Add(address, iph);
                                            AddToolTipTextToIp(address, iph);
                                        }
                                        catch { }
                                    }
                                    else
                                    {
                                        AddToolTipTextToIp(address, iphost[address]);
                                    }
                                    BackgroundWorker bw = new BackgroundWorker();
                                    bw.DoWork += (a, b) =>
                                        {
                                            IPAddress ipaddress = (IPAddress)b.Argument;
                                            TraceForm tf = new TraceForm(ipaddress);
                                            tf.Tag = Diag.PerformPathping(ipaddress, 50, 5000);
                                            iptrace.Add(address,tf);
                                            tf.ShowDialog();
                                        };
                                    bw.RunWorkerAsync(address);
                                }
                                else
                                {
                                    iptrace[address].ShowDialog();
                                }
                            }
                            //ping.SendAsync(dc.Value.ToString(),null);

                        
                    }
                }
                
            }
        }
Ejemplo n.º 2
0
 private void lookupToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedCells.Count == 1)
     {
         DataGridViewCell   dc  = dataGridView1.SelectedCells[0];
         DataGridViewColumn dgc = dataGridView1.Columns[dc.ColumnIndex];
         if (dgc.Name.Equals("src-ip") || dgc.Name.Equals("dst-ip"))
         {
             string Ip = dc.Value.ToString();
             if (!Ip.StartsWith("192.168") && !Ip.StartsWith("255.") && !Ip.Equals("239.255.255.250"))
             {
                 System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
                 ping.PingCompleted += (a, b) =>
                 {
                     MessageBox.Show(Ip + "\n" + b.Reply.Status.ToString());
                 };
                 IPAddress address;
                 if (IPAddress.TryParse(Ip, out address))
                 {
                     if (!iptrace.ContainsKey(address))
                     {
                         if (!iphost.ContainsKey(address))
                         {
                             try
                             {
                                 IPHostEntry iph = System.Net.Dns.EndGetHostEntry(System.Net.Dns.BeginGetHostEntry(address, (a) =>
                                 {
                                     if (a.IsCompleted)
                                     {
                                         string s = "";
                                     }
                                 }, null));
                                 iphost.Add(address, iph);
                                 AddToolTipTextToIp(address, iph);
                             }
                             catch { }
                         }
                         else
                         {
                             AddToolTipTextToIp(address, iphost[address]);
                         }
                         BackgroundWorker bw = new BackgroundWorker();
                         bw.DoWork += (a, b) =>
                         {
                             IPAddress ipaddress = (IPAddress)b.Argument;
                             TraceForm tf        = new TraceForm(ipaddress);
                             tf.Tag = Diag.PerformPathping(ipaddress, 50, 5000);
                             iptrace.Add(address, tf);
                             tf.ShowDialog();
                         };
                         bw.RunWorkerAsync(address);
                     }
                     else
                     {
                         iptrace[address].ShowDialog();
                     }
                 }
                 //ping.SendAsync(dc.Value.ToString(),null);
             }
         }
     }
 }