private async void reconnectbutton_Click(object sender, EventArgs e) { reconnectbutton.Enabled = false; buttonclicked = true; //String ssid = cw.display_current(); circularProgress1.IsRunning = true; await Task.Delay(1000); reconnectmsg.Visible = false; reconnectbutton.Visible = false; reconnecting.Text += Environment.NewLine + ssid1 + " ...."; await Task.Delay(500); reconnecting.Visible = true; circularProgress1.Visible = true; await Task.Delay(1000); String res = netsh.Connect(ssid1); await Task.Delay(8000); Hide(); }
public async void WifiConnect(Object sender, System.EventArgs e) { Button btn = (Button)sender; if (netsh.CheckProfile(btn.Text) == "not present") { Form5 f2 = new Form5(); Hide(); await Task.Delay(2000); ConnectWIFI.Visible = false; f2.ShowDialog(); await Task.Delay(1000); ConnectWIFI.Visible = true; if (f2.Okbuttonclicked == true) { security_key = f2.secretkey; xml.GenerateWPA2psk(btn.Text, security_key, Application.StartupPath + @"\" + btn.Text + ".xml"); netsh.ProfileAdd(Application.StartupPath + @"\" + btn.Text + ".xml"); Form3 f = new Form3(); f.LabelText = "Connecting to " + btn.Text + " ........."; ConnectWIFI.Visible = false; Hide(); f.Show(); await Task.Delay(2000); String res = netsh.Connect(btn.Text); if (!res.Contains("successfully")) { f.Hide(); Form3 f1 = new Form3(); f1.LabelText = "Windows was unable to connect to " + btn.Text; ConnectWIFI.Visible = false; f1.ShowDialog(); ConnectWIFI.Visible = true; } else { panel3.Visible = false; circularProgress2.Visible = true; circularProgress2.IsRunning = true; List_of_wifi(sender, e); } await Task.Delay(5000); ConnectWIFI.Visible = true; Show(); this.Activate(); } else { ConnectWIFI.Visible = true; Show(); this.Activate(); } } else { Form3 f = new Form3(); f.LabelText = "Connecting to " + btn.Text + " ........."; ConnectWIFI.Visible = false; Hide(); f.Show(); await Task.Delay(2000); String res = netsh.Connect(btn.Text); if (!res.Contains("successfully")) { f.Hide(); Form3 f1 = new Form3(); f1.LabelText = "Windows was unable to connect to " + btn.Text; ConnectWIFI.Visible = false; f1.ShowDialog(); ConnectWIFI.Visible = true; } else { panel3.Visible = false; circularProgress2.Visible = true; circularProgress2.IsRunning = true; await Task.Delay(3000); List_of_wifi(sender, e); } await Task.Delay(5000); ConnectWIFI.Visible = true; Show(); this.Activate(); } }