private void qrWorker_DoWork(object sender, DoWorkEventArgs e) { this.bfClient = new BeanfunClient(); string skey = this.bfClient.GetSessionkey(); this.qrcodeClass = this.bfClient.GetQRCodeValue(skey, (bool)e.Argument); }
public bool init() { try { //this.Text = "BeanfunLogin - v" + currentVersion; this.AcceptButton = this.loginButton; this.bfClient = null; this.accountManager = new AccountManager(); //string[] lines = System.IO.File.ReadAllLines(@"C:\POP\12.txt"); string[] lines = System.IO.File.ReadAllLines(@"\\vmware-host\Shared Folders\ C#POP\2.txt"); string[] words = lines[0].Split((char)9); this.accountInput.Text = words[0]; this.passwdInput.Text = words[1]; this.accountInput.Text = "alanting0004"; this.passwdInput.Text = "sf7778101"; bool res = accountManager.init(); if (res == false) { errexit("帳號記錄初始化失敗,未知的錯誤。", 0); } // Properties.Settings.Default.Reset(); //SetToDefault. this.loginMethodInput.SelectedIndex = 0; this.textBox3.Text = ""; if (this.accountInput.Text == "") { this.ActiveControl = this.accountInput; } else if (this.passwdInput.Text == "") { this.ActiveControl = this.passwdInput; } // .NET textbox full mode bug. this.accountInput.ImeMode = ImeMode.OnHalf; this.passwdInput.ImeMode = ImeMode.OnHalf; return(true); } catch (Exception e) { return(errexit("初始化失敗,未知的錯誤。" + e.Message, 0)); } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { Properties.Settings.Default.loginMethod = this.comboBox1.SelectedIndex; if (Properties.Settings.Default.loginMethod == 4) { this.checkBox1.Location = new Point(49, 155); this.checkBox2.Location = new Point(165, 155); this.label4.Visible = true; this.textBox4.Visible = true; } else { this.checkBox1.Location = new Point(107, 127); this.checkBox2.Location = new Point(107, 155); this.label4.Visible = false; this.textBox4.Visible = false; } if (Properties.Settings.Default.loginMethod == 2) { this.label3.Text = "安全密碼"; this.bfClient = new BeanfunClient(); this.gamaotpClass = this.bfClient.GetGamaotpPassCode(this.bfClient.GetSessionkey()); if (this.bfClient.errmsg != null) { errexit(this.bfClient.errmsg, 2); } else { errexit("通行密碼: " + this.gamaotpClass.motp, 2, "GAMAOTP"); } } else if (Properties.Settings.Default.loginMethod == 3) { this.label3.Text = "安全密碼"; } else if (Properties.Settings.Default.loginMethod == 5) { this.label3.Text = "PIN碼"; } else { this.label3.Text = "密碼"; } }
// Login do work. private void loginWorker_DoWork(object sender, DoWorkEventArgs e) { while (this.pingWorker.IsBusy) { Thread.Sleep(137); } Debug.WriteLine("loginWorker starting"); if (Thread.CurrentThread.Name != null) { Thread.CurrentThread.Name = "Login Worker"; } e.Result = ""; try { if (Properties.Settings.Default.loginMethod != (int)LoginMethod.QRCode) { this.bfClient = new BeanfunClient(); } this.Dispatcher.Invoke(new Action(delegate { this.bfClient.Login(this.tb_account.Text, this.pb_password.Password, Properties.Settings.Default.loginMethod, this.qrcodeClass, this.service_code, this.service_region); })); if (this.bfClient.errmsg != null) { e.Result = this.bfClient.errmsg; } else { e.Result = null; } } catch (Exception ex) { e.Result = "登入失敗,未知的錯誤。\n\n" + ex.Message + "\n" + ex.StackTrace; } }
public bool init() { try { this.Text = "BeanfunLogin - v" + currentVersion; this.AcceptButton = this.loginButton; this.bfClient = null; this.accountManager = new AccountManager(); bool res = accountManager.init(); if (res == false) { errexit("帳號記錄初始化失敗,未知的錯誤。", 0); } refreshAccountList(); // Properties.Settings.Default.Reset(); //SetToDefault. // Handle settings. if (Properties.Settings.Default.rememberAccount == true) { this.accountInput.Text = Properties.Settings.Default.AccountID; } if (Properties.Settings.Default.rememberPwd == true) { this.rememberAccount.Enabled = false; // Load password. if (File.Exists("UserState.dat")) { try { Byte[] cipher = File.ReadAllBytes("UserState.dat"); string entropy = Properties.Settings.Default.entropy; byte[] plaintext = ProtectedData.Unprotect(cipher, Encoding.UTF8.GetBytes(entropy), DataProtectionScope.CurrentUser); this.passwdInput.Text = System.Text.Encoding.UTF8.GetString(plaintext); } catch { File.Delete("UserState.dat"); } } } if (Properties.Settings.Default.autoLogin == true) { this.UseWaitCursor = true; this.panel2.Enabled = false; this.loginButton.Text = "請稍後..."; this.loginWorker.RunWorkerAsync(Properties.Settings.Default.loginMethod); } if (gamePaths.Get("新楓之谷") == "") { ModifyRegistry myRegistry = new ModifyRegistry(); myRegistry.BaseRegistryKey = Registry.CurrentUser; myRegistry.SubKey = "Software\\Gamania\\MapleStory"; if (myRegistry.Read("Path") != "") { gamePaths.Set("新楓之谷", myRegistry.Read("Path")); gamePaths.Save(); } } this.loginMethodInput.SelectedIndex = Properties.Settings.Default.loginMethod; this.textBox3.Text = ""; if (this.accountInput.Text == "") { this.ActiveControl = this.accountInput; } else if (this.passwdInput.Text == "") { this.ActiveControl = this.passwdInput; } // .NET textbox full mode bug. //this.accountInput.ImeMode = ImeMode.OnHalf; //this.passwdInput.ImeMode = ImeMode.OnHalf; return(true); } catch (Exception e) { return(errexit("初始化失敗,未知的錯誤。" + e.Message, 0)); } }
public bool init() { try { this.Text = "BeanfunLogin - v" + Properties.Settings.Default.currentVersion.ToString().Insert(1, ".").Insert(3, "."); this.AcceptButton = this.button1; this.bfClient = null; //Properties.Settings.Default.Reset(); //SetToDefault. // Handle settings. if (Properties.Settings.Default.rememberAccount == true) { this.textBox1.Text = Properties.Settings.Default.AccountID; } if (Properties.Settings.Default.rememberPwd == true && Properties.Settings.Default.loginMethod != 2) { this.checkBox1.Enabled = false; // Load password. if (File.Exists("UserState.dat")) { Byte[] cipher = File.ReadAllBytes("UserState.dat"); string entropy = Properties.Settings.Default.entropy; byte[] plaintext = ProtectedData.Unprotect(cipher, Encoding.UTF8.GetBytes(entropy), DataProtectionScope.CurrentUser); this.textBox2.Text = System.Text.Encoding.UTF8.GetString(plaintext); } } if (Properties.Settings.Default.autoLogin == true && Properties.Settings.Default.loginMethod != 2 && Properties.Settings.Default.loginMethod != 4) { this.UseWaitCursor = true; this.panel2.Enabled = false; this.button1.Text = "請稍後..."; this.backgroundWorker2.RunWorkerAsync(Properties.Settings.Default.loginMethod); } if (Properties.Settings.Default.gamePath == "") { ModifyRegistry myRegistry = new ModifyRegistry(); myRegistry.BaseRegistryKey = Registry.CurrentUser; myRegistry.SubKey = "Software\\Gamania\\MapleStory"; if (myRegistry.Read("Path") != "") { Properties.Settings.Default.gamePath = myRegistry.Read("Path"); } } this.comboBox1.SelectedIndex = Properties.Settings.Default.loginMethod; this.textBox3.Text = ""; if (this.textBox1.Text == "") { this.ActiveControl = this.textBox1; } else if (this.textBox2.Text == "") { this.ActiveControl = this.textBox2; } // .NET textbox full mode bug. this.textBox1.ImeMode = ImeMode.OnHalf; this.textBox2.ImeMode = ImeMode.OnHalf; return(true); } catch { return(errexit("初始化失敗,未知的錯誤。", 0)); } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { Properties.Settings.Default.loginMethod = this.comboBox1.SelectedIndex; if (Properties.Settings.Default.loginMethod == 4) { this.checkBox1.Location = new Point(49, 155); this.checkBox2.Location = new Point(165, 155); this.label4.Visible = true; this.textBox4.Visible = true; } else { this.checkBox1.Location = new Point(107, 127); this.checkBox2.Location = new Point(107, 155); this.label4.Visible = false; this.textBox4.Visible = false; } if (Properties.Settings.Default.loginMethod == 2) { this.label3.Text = "安全密碼"; this.bfClient = new BeanfunClient(); this.gamaotpClass = this.bfClient.GetGamaotpPassCode(this.bfClient.GetSessionkey()); if (this.bfClient.errmsg != null) errexit(this.bfClient.errmsg, 2); else errexit("通行密碼: " + this.gamaotpClass.motp, 2, "GAMAOTP"); } else if (Properties.Settings.Default.loginMethod == 3) { this.label3.Text = "安全密碼"; } else if (Properties.Settings.Default.loginMethod == 5) { this.label3.Text = "PIN碼"; } else { this.label3.Text = "密碼"; } }
public bool init() { try { this.Text = "BeanfunLogin - v" + Properties.Settings.Default.currentVersion.ToString().Insert(1, ".").Insert(3, "."); this.AcceptButton = this.button1; this.bfClient = null; //Properties.Settings.Default.Reset(); //SetToDefault. // Handle settings. if (Properties.Settings.Default.rememberAccount == true) this.textBox1.Text = Properties.Settings.Default.AccountID; if (Properties.Settings.Default.rememberPwd == true && Properties.Settings.Default.loginMethod != 2) { this.checkBox1.Enabled = false; // Load password. if (File.Exists("UserState.dat")) { Byte[] cipher = File.ReadAllBytes("UserState.dat"); string entropy = Properties.Settings.Default.entropy; byte[] plaintext = ProtectedData.Unprotect(cipher, Encoding.UTF8.GetBytes(entropy), DataProtectionScope.CurrentUser); this.textBox2.Text = System.Text.Encoding.UTF8.GetString(plaintext); } } if (Properties.Settings.Default.autoLogin == true && Properties.Settings.Default.loginMethod != 2 && Properties.Settings.Default.loginMethod != 4) { this.UseWaitCursor = true; this.panel2.Enabled = false; this.button1.Text = "請稍後..."; this.backgroundWorker2.RunWorkerAsync(Properties.Settings.Default.loginMethod); } if (Properties.Settings.Default.gamePath == "") { ModifyRegistry myRegistry = new ModifyRegistry(); myRegistry.BaseRegistryKey = Registry.CurrentUser; myRegistry.SubKey = "Software\\Gamania\\MapleStory"; if (myRegistry.Read("Path") != "") Properties.Settings.Default.gamePath = myRegistry.Read("Path"); } this.comboBox1.SelectedIndex = Properties.Settings.Default.loginMethod; this.comboBox2.SelectedIndex = Properties.Settings.Default.loginGame; this.textBox3.Text = ""; if (this.textBox1.Text == "") this.ActiveControl = this.textBox1; else if (this.textBox2.Text == "") this.ActiveControl = this.textBox2; // .NET textbox full mode bug. this.textBox1.ImeMode = ImeMode.OnHalf; this.textBox2.ImeMode = ImeMode.OnHalf; return true; } catch { return errexit("初始化失敗,未知的錯誤。", 0); } }
public bool init() { try { this.bfClient = null; this.accountManager = new AccountManager(); bool res = accountManager.init(); if (res == false) { errexit("帳號記錄初始化失敗,未知的錯誤。", 0); } refreshAccountList(); // Properties.Settings.Default.Reset(); //SetToDefault. // Handle settings. if (Properties.Settings.Default.rememberAccount == true) { this.tb_account.Text = Properties.Settings.Default.AccountID; } if (Properties.Settings.Default.rememberPwd == true) { /* this.rememberAccount.Enabled = false;*/ // Load password. if (File.Exists("UserState.dat")) { try { Byte[] cipher = File.ReadAllBytes("UserState.dat"); string entropy = Properties.Settings.Default.entropy; byte[] plaintext = ProtectedData.Unprotect(cipher, Encoding.UTF8.GetBytes(entropy), DataProtectionScope.CurrentUser); this.pb_password.Password = System.Text.Encoding.UTF8.GetString(plaintext); } catch { File.Delete("UserState.dat"); } } } if (Properties.Settings.Default.autoLogin == true) { /* this.UseWaitCursor = true; * this.panel2.Enabled = false; * this.loginButton.Text = "請稍後..."; * this.loginWorker.RunWorkerAsync(Properties.Settings.Default.loginMethod);*/ } if (gamePaths.Get("新楓之谷") == "") { /* ModifyRegistry myRegistry = new ModifyRegistry(); * myRegistry.BaseRegistryKey = Registry.CurrentUser; * myRegistry.SubKey = "Software\\Gamania\\MapleStory"; * if (myRegistry.Read("Path") != "") * { * gamePaths.Set("新楓之谷", myRegistry.Read("Path")); * gamePaths.Save(); * }*/ } this.cb_login_method.SelectedIndex = Properties.Settings.Default.loginMethod; /* this.textBox3.Text = ""; * * if (this.tb_account.Text == "") * this.ActiveControl = this.tb_account; * else if (this.pb_password.Password == "") * this.ActiveControl = this.pb_password;*/ this.getOtpWorker.WorkerReportsProgress = true; this.getOtpWorker.WorkerSupportsCancellation = true; this.getOtpWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.getOtpWorker_DoWork); this.getOtpWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.getOtpWorker_RunWorkerCompleted); this.loginWorker.WorkerReportsProgress = true; this.loginWorker.WorkerSupportsCancellation = true; this.loginWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.loginWorker_DoWork); this.loginWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.loginWorker_RunWorkerCompleted); this.pingWorker.WorkerReportsProgress = true; this.pingWorker.WorkerSupportsCancellation = true; this.pingWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.pingWorker_DoWork); this.pingWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.pingWorker_RunWorkerCompleted); return(true); } catch (Exception e) { return(errexit("初始化失敗,未知的錯誤。" + e.Message, 0)); } }