private void btnBaglan_Click(object sender, EventArgs e) { IPAddress ip1; if (!IPAddress.TryParse(txtIP.Text, out ip1)) { MessageBox.Show("Yazdığınız IP adresi hatalı!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } try { Ping ping = new Ping(); PingReply pingReply = ping.Send(ip1); if (pingReply.Status != IPStatus.Success) { MessageBox.Show("Yazdığınız IP adresine ulaşılamıyor.\nAçıklama: " + pingReply.Status.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } catch { return; } if (chipbox1 != null) chipbox1.CloseAll(); try { chipbox1 = new ChipboxHD(txtIP.Text); btnBaglan.Checked = true; btnBaglan.Text = "Bağlı"; Settings.Default.txtIP = txtIP.Text; Settings.Default.Save(); } catch { return; } }
bool SessizBaglan() { IPAddress ip1; if (!IPAddress.TryParse(txtIP.Text, out ip1)) return false; try { Ping ping = new Ping(); PingReply pingReply = ping.Send(ip1); if (pingReply.Status != IPStatus.Success) return false; } catch { return false; } if (chipbox1 != null) chipbox1.CloseAll(); try { chipbox1 = new ChipboxHD(txtIP.Text); btnBaglan.Checked = true; btnBaglan.Text = "Bağlı"; Settings.Default.txtIP = txtIP.Text; Settings.Default.Save(); return true; } catch { return false; } }