Esempio n. 1
0
        private void OpenLoginWindow()
        {
            LoginWindow login = new LoginWindow(Bot) { Owner = this };
            bool? result = login.ShowDialog();
            if (result != true)
            {
                return;
            }

            LogMessage("Connecting to the server...");
            LoginButton.IsEnabled = false;
            LoginMenuItem.IsEnabled = false;
            Account account = new Account(login.Username);
            lock (Bot)
            {
                account.Password = login.Password;
                account.Server = login.IsBlueServer ? "BLUE" : "RED";
                if (login.HasProxy)
                {
                    account.Socks.Version = (SocksVersion)login.ProxyVersion;
                    account.Socks.Host = login.ProxyHost;
                    account.Socks.Port = login.ProxyPort;
                    account.Socks.Username = login.ProxyUsername;
                    account.Socks.Password = login.ProxyPassword;
                }
                Bot.Login(account);
            }
        }
Esempio n. 2
0
 public void Login(Account account)
 {
     Account = account;
     _loginRequested = true;
 }
Esempio n. 3
0
        private void SaveAccountButton_Click(object sender, RoutedEventArgs e)
        {
            if (UsernameTextBox.Text == null || UsernameTextBox.Text.Trim() == "")
            {
                return;
            }
            Account account = new Account(UsernameTextBox.Text.Trim());

            if (PasswordTextBox.Password != "" && PasswordTextBox.Password != null)
            {
                account.Password = PasswordTextBox.Password;
            }
            if (IsBlueServer)
            {
                account.Server = "BLUE";
            }
            else
            {
                account.Server = "RED";
            }
            if (HasProxy)
            {
                SocksVersion socksVersion = SocksVersion.None;
                if (ProxyVersion == 4)
                {
                    socksVersion = SocksVersion.Socks4;
                }
                else if (ProxyVersion == 5)
                {
                    socksVersion = SocksVersion.Socks5;
                }
                account.Socks.Version = socksVersion;
                if (ProxyHostTextBox.Text != null && ProxyHostTextBox.Text.Trim() != "")
                {
                    account.Socks.Host = ProxyHostTextBox.Text.Trim();
                }
                if (ProxyPortTextBox.Text != null && ProxyPortTextBox.Text.Trim() != "")
                {
                    int port;
                    if (int.TryParse(ProxyPortTextBox.Text.Trim(), out port))
                    {
                        account.Socks.Port = port;
                    }
                }
                if (ProxyUsernameTextBox.Text != null && ProxyUsernameTextBox.Text.Trim() != "")
                {
                    account.Socks.Username = ProxyUsernameTextBox.Text.Trim();
                }
                if (ProxyPasswordTextBox.Password != null && ProxyPasswordTextBox.Password != "")
                {
                    account.Socks.Password = ProxyPasswordTextBox.Password;
                }
            }
            lock (_bot)
            {
                _bot.AccountManager.Accounts[account.Name] = account;
                _bot.AccountManager.SaveAccount(account.Name);
            }
            RefreshAccountList();
        }