Пример #1
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();
        }
 private void UpdateEnabled()
 {
     if (UseProxyCheckBox.Checked)
     {
         ProxyServerTextBox.Enabled = true;
         ProxyPortTextBox.Enabled   = true;
     }
     else
     {
         ProxyServerTextBox.Clear();
         ProxyPortTextBox.Clear();
         ProxyServerTextBox.Enabled = false;
         ProxyPortTextBox.Enabled   = false;
     }
 }
Пример #3
0
        private void AccountListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (AccountListView.SelectedItem == null)
            {
                return;
            }
            string accountName = AccountListView.SelectedItem.ToString();

            lock (_bot)
            {
                if (_bot.AccountManager.Accounts.ContainsKey(accountName))
                {
                    Account account = _bot.AccountManager.Accounts[accountName];
                    UsernameTextBox.Text = account.Name;
                    if (account.Password == null)
                    {
                        PasswordTextBox.Clear();
                    }
                    else
                    {
                        PasswordTextBox.Password = account.Password;
                    }
                    if (account.Server == "YELLOW")
                    {
                        ServerComboBox.SelectedIndex = 2;
                    }
                    else if (account.Server == "BLUE")
                    {
                        ServerComboBox.SelectedIndex = 1;
                    }
                    else
                    {
                        ServerComboBox.SelectedIndex = 0;
                    }
                    if (account.MacAddress != null)
                    {
                        MacRandomCheckBox.IsChecked = false;
                        MacAddressTextBox.Text      = account.MacAddress;
                    }
                    else
                    {
                        MacRandomCheckBox.IsChecked = true;
                    }
                    if (account.Socks.Version != SocksVersion.None || account.Socks.Username != null || account.Socks.Password != null ||
                        account.Socks.Host != null || account.Socks.Port != -1)
                    {
                        ProxyCheckBox.IsChecked = true;
                    }
                    else
                    {
                        ProxyCheckBox.IsChecked = false;
                    }
                    if (account.Socks.Version == SocksVersion.Socks4)
                    {
                        ProxyVersion = 4;
                    }
                    else if (account.Socks.Version == SocksVersion.Socks5)
                    {
                        ProxyVersion = 5;
                    }
                    if (account.Socks.Host == null)
                    {
                        ProxyHostTextBox.Clear();
                    }
                    else
                    {
                        ProxyHostTextBox.Text = account.Socks.Host;
                    }
                    if (account.Socks.Port == -1)
                    {
                        ProxyPortTextBox.Clear();
                    }
                    else
                    {
                        ProxyPortTextBox.Text = account.Socks.Port.ToString();
                    }
                    if (account.Socks.Username != null || account.Socks.Password != null)
                    {
                        AnonymousCheckBox.IsChecked = false;
                    }
                    else
                    {
                        AnonymousCheckBox.IsChecked = true;
                    }
                    if (account.Socks.Username == null)
                    {
                        ProxyUsernameTextBox.Clear();
                    }
                    else
                    {
                        ProxyUsernameTextBox.Text = account.Socks.Username;
                    }
                    if (account.Socks.Password == null)
                    {
                        ProxyPasswordTextBox.Clear();
                    }
                    else
                    {
                        ProxyPasswordTextBox.Password = account.Socks.Password;
                    }
                }
            }
        }