Beispiel #1
0
        /// <summary>
        /// 登录相关逻辑
        /// </summary>
        private void DoLogin()
        {
            picQRCode.Image    = null;
            picQRCode.SizeMode = PictureBoxSizeMode.Zoom;
            lblTip.Text        = "手机微信扫一扫以登录";
            ((Action)(delegate()
            {
                //异步加载二维码
                LoginService ls = new LoginService();
                Image qrcode = ls.GetQRCode();
                if (qrcode != null)
                {
                    this.BeginInvoke((Action) delegate()
                    {
                        picQRCode.Image = qrcode;
                    });

                    object login_result = null;
                    while (true)  //循环判断手机扫面二维码结果
                    {
                        login_result = ls.LoginCheck();
                        if (login_result is Image) //已扫描 未登录
                        {
                            this.BeginInvoke((Action) delegate()
                            {
                                lblTip.Text = "请点击手机上登录按钮";
                                picQRCode.SizeMode = PictureBoxSizeMode.CenterImage;  //显示头像
                                picQRCode.Image = login_result as Image;
                                linkReturn.Visible = true;
                            });
                        }
                        if (login_result is string)  //已完成登录
                        {
                            //访问登录跳转URL
                            ls.GetSidUid(login_result as string);
                            //打开主界面
                            this.BeginInvoke((Action) delegate()
                            {
                                this.Hide();
                                //frmMainForm frmmf = new frmMainForm();
                                //frmmf.Show();
                                //frmMain frmmf = new frmMain();
                                frmMainForm frmmf = new frmMainForm();
                                frmmf.Show();
                            });
                            break;
                        }
                    }
                }
            })).BeginInvoke(null, null);
        }
Beispiel #2
0
        /// <summary>
        /// 登录相关逻辑
        /// </summary>
        private void DoLogin()
        {
            picQRCode.Image = null;
            picQRCode.SizeMode = PictureBoxSizeMode.Zoom;
            lblTip.Text = "手机微信扫一扫以登录";
            ((Action)(delegate()
            {
                //异步加载二维码
                LoginService ls = new LoginService();
                Image qrcode = ls.GetQRCode();
                if (qrcode != null)
                {
                    this.BeginInvoke((Action)delegate()
                    {
                        picQRCode.Image = qrcode;
                    });

                    object login_result = null;
                    while (true)  //循环判断手机扫面二维码结果
                    {
                        login_result = ls.LoginCheck();
                        if (login_result is Image) //已扫描 未登录
                        {
                            this.BeginInvoke((Action)delegate()
                            {
                                lblTip.Text = "请点击手机上登录按钮";
                                picQRCode.SizeMode = PictureBoxSizeMode.CenterImage;  //显示头像
                                picQRCode.Image = login_result as Image;
                                linkReturn.Visible = true;
                            });
                        }
                        if (login_result is string)  //已完成登录
                        {
                            //访问登录跳转URL
                            ls.GetSidUid(login_result as string);

                            //打开主界面
                            this.BeginInvoke((Action)delegate()
                            {
                                this.Hide();
                                frmMainForm frmmf = new frmMainForm();
                                frmmf.Show();
                            });
                            break;
                        }
                    }
                }
            })).BeginInvoke(null, null);
        }