/// <summary> /// Form Principal /// </summary> public FormPrincipal() { InitializeComponent(); dataGridView.ColumnCount = 2; ActiveControl = textBoxAdress; IEnumerable <NetworkInterface> ethernet = Fonctions.TrouverInterfaceRéseauEthernet(); // trouver interface réseau Ethernet active foreach (NetworkInterface adatper in ethernet) { LabelNomAdaptateur.Text = adatper.Description; // Afficher l'interface réseau Ethernet trouvée string[] row = new string[] { "Id", adatper.Id }; dataGridView.Rows.Add(row); row = new string[] { "IsReceiveOnly", adatper.IsReceiveOnly.ToString() }; dataGridView.Rows.Add(row); row = new string[] { "Name", adatper.Name }; dataGridView.Rows.Add(row); row = new string[] { "Type", adatper.NetworkInterfaceType.ToString() }; dataGridView.Rows.Add(row); row = new string[] { "Status", adatper.OperationalStatus.ToString() }; dataGridView.Rows.Add(row); row = new string[] { "Speed", adatper.Speed.ToString() }; dataGridView.Rows.Add(row); row = new string[] { "Support Multicast", adatper.SupportsMulticast.ToString() }; dataGridView.Rows.Add(row); row = new string[] { "MAC", string.Join(":", (from z in adatper.GetPhysicalAddress().GetAddressBytes() select z.ToString("X2")).ToArray()) }; dataGridView.Rows.Add(row); } }
/// <summary> /// button Traceroute_Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> async private void buttonTrace_Click(object sender, EventArgs e) { Task <string> t = Task.Run(() => Fonctions.TraceRoute(textBoxAdress.Text.Trim())); buttonTrace.Enabled = false; // Desactiver le button pendant le trace route string reponseTrace = await t; // Attendre que la tâche t finisse; buttonTrace.Enabled = true; // Réactiver le boutton traceroute textBoxResultat.AppendText(reponseTrace); }
/// <summary> /// button GetHostEntry_Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> async private void buttonGetHostEntry_Click(object sender, EventArgs e) { Task <IPHostEntry> t = null; IPHostEntry hostEntry = new IPHostEntry(); string adresse = textBoxAdress.Text.Trim(); if (!string.IsNullOrWhiteSpace(adresse)) { t = Fonctions.ObtenirHostEntry(adresse); hostEntry = await t; } if (hostEntry != null) { textBoxResultat.AppendText(String.Join <IPAddress>(Environment.NewLine, hostEntry.AddressList) + Environment.NewLine + hostEntry.AddressList[0].AddressFamily.ToString() + Environment.NewLine + "Host Name : " + hostEntry.HostName + Environment.NewLine); } }
/// <summary> /// button getLocalHostName_Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttongetLocalHostName_Click(object sender, EventArgs e) { textBoxResultat.AppendText("Host Name: " + Fonctions.ObtenirLocalHostName() + Environment.NewLine); }