Exemple #1
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            if (UseProxyCheckBox.Checked)
            {
                int port;
                int timeout;
                if (!int.TryParse(ProxyPortTextBox.Text, out port))
                {
                    MessageBox.Show(I18N.GetString("Illegal port number format"));
                    return;
                }

                if (!int.TryParse(ProxyTimeoutTextBox.Text, out timeout))
                {
                    MessageBox.Show(I18N.GetString("Illegal timeout format"));
                    return;
                }

                var type  = ProxyTypeComboBox.SelectedIndex;
                var proxy = ProxyServerTextBox.Text;
                try
                {
                    Configuration.CheckServer(proxy);
                    Configuration.CheckPort(port);
                    Configuration.CheckTimeout(timeout, ProxyConfig.MaxProxyTimeoutSec);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }

                controller.EnableProxy(type, proxy, port, timeout);
            }
            else
            {
                controller.DisableProxy();
            }

            this.Close();
        }