Пример #1
0
        public async void QuickStart(string username, string password, string accountName)
        {
            try
            {
                Enabled = false;
                var bf = new BeanfunLogin.BeanfunLogin();
                await bf.Login(username, password, LoginMethod.General);

                if (bf.accountList.Count > 0)
                {
                    var account = bf.accountList.Find((a) => a.sacc == accountName);
                    if (account == null)
                    {
                        account = bf.accountList[0];
                    }
                    var gamePassword = await bf.GetGamePasswordAsync(account);

                    mabiEXE.StartClient(true, account.sacc, gamePassword);
                }
            }
            finally
            {
                Application.Exit();
            }
        }
Пример #2
0
 private void Form1_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (_BfLogin != null)
     {
         _BfLogin.Dispose();
         _BfLogin = null;
     }
 }
Пример #3
0
        private async void btn_login_ClickAsync(object sender, EventArgs e)
        {
            if (accountList == null)
            {
                accountList = new Dictionary <string, BeanfunLogin.BeanfunLogin.GameAccount>();
            }
            accountList.Clear();
            listView1.Items.Clear();
            panel1.Enabled = false;

            if (_BfLogin != null)
            {
                _BfLogin.Dispose();
                _BfLogin = null;
            }
            _BfLogin = new BeanfunLogin.BeanfunLogin();
            _BfLogin.OnLoginCompleted += (s, args) =>
            {
                if (checkBox_RememberAccount.Checked)
                {
                    SaveAccount();
                }

                var login = s as BeanfunLogin.BeanfunLogin;
                foreach (var account in login.accountList)
                {
                    string[] row          = { System.Net.WebUtility.HtmlDecode(account.sname), account.sacc };
                    var      listViewItem = new ListViewItem(row);
                    listView1.Items.Add(listViewItem);
                    accountList.Add(account.sacc, account);
                    listView1.AutoResizeColumn(1, ColumnHeaderAutoResizeStyle.HeaderSize);
                }

                panel1.Enabled = true;
                listView1.Focus();
                listView1.Items[0].Selected = true;
            };
            try
            {
                await _BfLogin.Login(textBox_beanfunAccount.Text, textBox_beanfunPassword.Text, loginMethod);
            }
            catch (Exception error)
            {
                MessageBox.Show("登入失敗! \n" + error.Message);
            }
            finally
            {
                panel1.Enabled = true;
            }
        }