在form窗体登录时,使用一些验证码,感觉挺有意思的。
首先在窗体上放置上一个lable:请输入验证码。再放上一个text文本框,name=“txtValidCode”;然后在放入一个pictureBox。name="picValidCode";在放入一个按钮,text=“提交”。
在同层中加入一个类。ValidCode ,代码如下。
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace 实验1
{
public class ValidCode
{
#region Private Fields
private const double PI = 3.1415926535897932384626433832795;
private const double PI2 = 6.283185307179586476925286766559;
//private readonly int _wordsLen = 4;
private int _len;
private CodeType _codetype;
private readonly Single _jianju = (float)18.0;
private readonly Single _height = (float)24.0;
private string _checkCode;
#endregion
#region Public Property
public string CheckCode
{
get
{
return _checkCode;
}
}
#endregion
#region Constructors
/// <summary>
/// public constructors
/// </summary>
/// <param name="len"> 验证码长度 </param>
///