/// <summary> /// 登录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void btnLogin_Click(object sender, EventArgs e) { try { if (string.IsNullOrWhiteSpace(ddlUserName.Text) || string.IsNullOrWhiteSpace(txtPassWord.Text)) { MessageBox.Show("用户名密码不能为空!", "提示"); return; } lblMsg.Text = "登录中,请稍等..."; EnableControl(false, this); SaveUserInfo(); var name = ddlUserName.Text; var pwd = txtPassWord.Text; var ca = txtCaptcha.Text; var result = await Task.Run(() => { return(HtmlHelp.Login(name, pwd, ca)); }); if (result != null && result.Html.Contains("success")) { btnSingle.Enabled = true; btnMutDown.Enabled = true; picCaptcha.Visible = false; lblMsg.Text = "登录成功!"; } else { lblMsg.Text = "注:若账号密码正确,可能是需要输入验证码!"; MessageBox.Show("登录失败!", "提示"); EnableControl(true, this); btnSingle.Enabled = false; btnMutDown.Enabled = false; //获取验证码 var buffter = HtmlHelp.GetCaptcha("https://accounts.pixiv.net/captcha"); if (buffter != null) { txtCaptcha.Enabled = true; picCaptcha.Image = Image.FromStream(new MemoryStream(buffter)); picCaptcha.Visible = true; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "异常信息"); } }