Esempio n. 1
0
        /// <summary>
        /// 将验证码生成验证图片
        /// </summary>
        /// <param name="validCode">验证码</param>
        /// <param name="difficult">是否困难</param>
        /// <returns></returns>
        public static Bitmap ValidCodeToImage(string validCode)
        {
            var helper = new ValidCode();

            using (var image = helper.CreateImage(validCode))
            {
                return(helper.TwistImage(image, true, 8, 3));
            }
        }
Esempio n. 2
0
        private void bgwCode_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            btnLogin.Enabled = true;
            btnRegister.Enabled = true;
            pnlLoading.Controls.Clear();

            if (e.Error != null)
            {
                pnlLoading.Controls.Add(LoadingCtrl.LoadModel(MessageType.Error, "加载验证码失败,请稍后再试!"));
                return;
            }

            ValidCode code = new ValidCode(6, ValidCode.CodeType.Numbers);
            picCode.Image = code.CreateCheckCodeImage(e.Result.ToString());
        }