资源简介
winform简单用户登录(带验证码)
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DrawCheckCode
{
public partial class Form1 : Form
{
private static string CheckCode;
private static bool Lock=true;
public Form1()
{
InitializeComponent();
pictureBox2.Image = Image.FromFile(@“..\..\Img\ICO\Key3.ico“);
CheckCode = CreateCheckCode();
CodeImg(CheckCode);
}
//生成随机数
private string CreateCheckCode()
{
int num;
char code;
string CheckCode = string.Empty;
Random r = new Random();
for (int i = 0; i < 6; i++)
{
num = r.Next();
if (num%2 == 0)
{
code = (char)(‘0‘ + (char)(num % 10));
}
else
{
code = (char)(‘A‘ + (char)(num % 26));
}
CheckCode += code;
}
return CheckCode;
}
//写入图片
private void CodeImg(string CheckCode)
{
if (string.IsNullOrEmpty(CheckCode))
{
return;
}
Bitmap img=new Bitmap((int)Math.Ceiling((CheckCode.Length*11.1))22);
Graphics g = Graphics.FromImage(img);
try
{
Random random = new Random();
g.Clear(Color.White);
for (int i = 0; i < 3; i++)
{
int x1 = random.Next(img.Width);
int x2 = random.Next(img.Width);
int y1 = random.Next(img.Height);
int y2 = random.Next(img.Height);
g.DrawLine(new Pen(Color.Black) x1 y1 x2 y2);
}
Font ft = new Font(“Arial“ 12 Fontstyle.Bold);
g.DrawString(CheckCode ft new SolidBrush(Color.Red) 2 2);
for (int i = 0; i < 150; i++)
{
int x = random.Next(img.Width);
int y = random.Next(img.Height);
img.SetPixel(xyColor.FromArgb(random.Next()));
}
g.DrawRectangle(new Pen(Color.Silver)00img.Width-1img.Height-1);
this.pictureBox1.Width=img.Width;
this.pictureBox1.Height=img.Height;
this.pictureBox1.BackgroundImage=img;
}
catch (Exception)
{
throw;
}
}
//刷新
private void button1_Click(object sender EventArgs e)
{
CheckCode = CreateCheckCode();
CodeImg(CheckCode);
}
//点
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 825 2020-09-30 11:46 DrawCheckCode\app.config
文件 26624 2020-09-30 15:37 DrawCheckCode\bin\Debug\DrawCheckCode.exe
文件 825 2020-09-30 11:46 DrawCheckCode\bin\Debug\DrawCheckCode.exe.config
文件 56832 2020-09-30 15:37 DrawCheckCode\bin\Debug\DrawCheckCode.pdb
文件 14328 2020-09-30 15:37 DrawCheckCode\bin\Debug\DrawCheckCode.vshost.exe
文件 825 2020-09-30 11:46 DrawCheckCode\bin\Debug\DrawCheckCode.vshost.exe.config
文件 490 2009-06-11 05:14 DrawCheckCode\bin\Debug\DrawCheckCode.vshost.exe.manifest
文件 325632 2017-06-12 09:27 DrawCheckCode\bin\Debug\Newtonsoft.Json.Net35.dll
文件 109 2020-09-30 14:30 DrawCheckCode\Data\1
文件 4671 2020-09-30 15:15 DrawCheckCode\DrawCheckCode.csproj
文件 5289 2020-09-30 15:39 DrawCheckCode\Form1.cs
文件 7882 2020-09-30 15:38 DrawCheckCode\Form1.Designer.cs
文件 6893 2020-09-30 15:38 DrawCheckCode\Form1.resx
文件 742 2020-09-30 15:21 DrawCheckCode\Frm_Main.cs
文件 9013 2020-09-30 15:21 DrawCheckCode\Frm_Main.Designer.cs
文件 9207 2020-09-30 15:21 DrawCheckCode\Frm_Main.resx
文件 766 2000-03-27 15:44 DrawCheckCode\Img\ICO\0++.ico
文件 766 2000-03-27 15:43 DrawCheckCode\Img\ICO\0.ico
文件 766 2000-03-27 15:45 DrawCheckCode\Img\ICO\1++.ico
文件 2238 2000-03-27 16:13 DrawCheckCode\Img\ICO\1+.ico
文件 766 2000-03-27 15:43 DrawCheckCode\Img\ICO\1.ico
文件 766 2000-03-27 15:45 DrawCheckCode\Img\ICO\2++.ico
文件 766 2000-03-27 15:43 DrawCheckCode\Img\ICO\2.ico
文件 766 2000-03-27 15:45 DrawCheckCode\Img\ICO\3++.ico
文件 766 2000-03-27 15:44 DrawCheckCode\Img\ICO\3.ico
文件 766 2000-03-18 10:55 DrawCheckCode\Img\ICO\3D.ico
文件 766 1997-06-22 18:07 DrawCheckCode\Img\ICO\3Dimpact.ico
文件 766 2000-03-27 15:45 DrawCheckCode\Img\ICO\4++.ico
文件 766 2000-03-27 15:44 DrawCheckCode\Img\ICO\4.ico
文件 766 2000-03-27 15:45 DrawCheckCode\Img\ICO\5++.ico
............此处省略505个文件信息
相关资源
- WPF 简单控件集
- C#简单三层架构,免去写增删改查
- vs2017+mysql的用户角色权限管理(附数
- C# 动态 时钟用户控件(基于System.Dr
- C#简单连接查询sqlite数据库
- asp.net 简单的Ajax应用
- 最简单的WPF+Mvvm
- WPF+MVVM学习 DataGrid简单案例
- asp.net 简单新闻发布系统源码(附数据
- c#简单的本地登录
- 简单tcp 通讯网口工具客户端
- C# 简单计算器
- 有史以来最简单的三层(C#)
- 一个简单的ASP.NET三层架构登陆模式
- C#中WebBrowser控件的简单调用
- C# 、.NET 读取AD域里用户名或组
- 微信公众平台网页授权获取用户基本
- .net实现微信公众帐号主动发消息给用
- C#上位机与单片机的完美结合内附有用
- C# 简单的作业调度
- C# 用三层架构实现简单的增删改查
- c#写的简单的机场售票系统
- 基于VS2008 C#编写的简单学生成绩管理
- C#实现的简单在线考试系统功能齐全
- 基于MVC的简单验证码验证不区分大小
- c#简单的客户管理系统
- 新闻发布系统包括用户界面部分和后
- 简单监控界面软件设计
- 简单的医院叫号系统
- 实用的WPF,包括两个框架和十个简单
评论
共有 条评论