예제 #1
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            if (UseProxyCheckBox.Checked)
            {
                try
                {
                    var proxy = ProxyServerTextBox.Text;
                    var port  = int.Parse(ProxyPortTextBox.Text);
                    Configuration.CheckServer(proxy);
                    Configuration.CheckPort(port);

                    controller.EnableProxy(proxy, port);
                }
                catch (FormatException)
                {
                    MessageBox.Show(I18N.GetString("Illegal port number format"));
                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            else
            {
                controller.DisableProxy();
            }
            this.Close();
        }
예제 #2
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            var type    = ProxyTypeComboBox.SelectedIndex;
            var proxy   = ProxyServerTextBox.Text;
            var port    = 0;
            var timeout = 3;

            if (UseProxyCheckBox.Checked)
            {
                try
                {
                    port = int.Parse(ProxyPortTextBox.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show(I18N.GetString("Illegal port number format"));
                    ProxyPortTextBox.Clear();
                    return;
                }

                try
                {
                    timeout = int.Parse(ProxyTimeoutTextBox.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show(I18N.GetString("Illegal timeout format"));
                    ProxyTimeoutTextBox.Clear();
                    return;
                }

                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);
            }
            else
            {
                controller.DisableProxy();
            }

            _modifiedConfiguration.useProxy     = UseProxyCheckBox.Checked;
            _modifiedConfiguration.proxyType    = type;
            _modifiedConfiguration.proxyServer  = proxy;
            _modifiedConfiguration.proxyPort    = port;
            _modifiedConfiguration.proxyTimeout = timeout;
            controller.SaveProxyConfig(_modifiedConfiguration);

            this.Close();
        }
예제 #3
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();
        }
예제 #4
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            if (UseProxyCheckBox.Checked)
            {
                try
                {
                    var type  = ProxyTypeComboBox.SelectedIndex;
                    var proxy = ProxyServerTextBox.Text;
                    var port  = int.Parse(ProxyPortTextBox.Text);
                    Configuration.CheckServer(proxy);
                    Configuration.CheckPort(port);

                    controller.EnableProxy(type, proxy, port);
                }
                catch (FormatException)
                {
                    MessageBox.Show(I18N.GetString("Illegal port number format"));
                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            else
            {
                controller.DisableProxy();
            }

            _modifiedConfiguration.useProxy    = UseProxyCheckBox.Checked;
            _modifiedConfiguration.proxyType   = ProxyTypeComboBox.SelectedIndex;
            _modifiedConfiguration.proxyServer = ProxyServerTextBox.Text;
            var tmpProxyPort = 0;

            int.TryParse(ProxyPortTextBox.Text, out tmpProxyPort);
            _modifiedConfiguration.proxyPort = tmpProxyPort;
            controller.SaveProxyConfig(_modifiedConfiguration);

            this.Close();
        }