private void btnZapisz_Click(object sender, EventArgs e)
{
if(!chbProxy.Checked)
WebRequest.DefaultWebProxy = null;
int tmp;
if (chbProxy.Checked && (txtSerwer.Text == "" || txtPort.Text == "" || !Int32.TryParse(txtPort.Text, out tmp)))
{
MessageBox.Show("Ustaw poprawnie proxy");
return;
}
if (chbProxy.Checked && chbUwierzytelnienie.Checked && (txtLogin.Text == "" || txtHaslo.Text == ""))
{
MessageBox.Show("Ustaw poprawnie proxy");
return;
}
if (chbProxy.Checked)
{
WebProxy wp = new WebProxy(txtSerwer.Text + ":" + txtPort.Text, chbUwierzytelnienie.Checked);
if (chbUwierzytelnienie.Checked)
wp.Credentials = new NetworkCredential(txtLogin.Text, txtHaslo.Text);
WebRequest.DefaultWebProxy = wp;
}
else
{
WebRequest.DefaultWebProxy = null;
}
log.zmianaProxy(chbProxy.Checked ? 1 : 0, txtSerwer.Text, Int32.Parse(txtPort.Text), chbUwierzytelnienie.Checked ? 1 : 0, txtLogin.Text, txtHaslo.Text);
this.Close();
}