Web/App_Code/CreateImages.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;

/// <summary>
///CreateImages 的摘要说明
/// </summary>
public class CreateImages
{

    public CreateImages()
    {
        //
        //TODO: 在此处添加构造函数逻辑
        //
    }
    public static void DrawImage()
    {
        CreateImages img = new CreateImages();
        HttpContext.Current.Session["CheckCode"] = img.GetRandomNumberString(4);
        img.CreateImage(HttpContext.Current.Session["CheckCode"].ToString());
    }
    public string GetRandomNumberString(int int_NumberLength)
    {
        string str_Number = string.Empty;
        Random theRandomNumber = new Random();

        for (int int_index = 0; int_index < int_NumberLength; int_index++)
            str_Number += theRandomNumber.Next(10).ToString();

        return str_Number;
    }
    //生成随机颜色
    public Color GetRandomColor()
    {
        Random RandomNum_First = new Random((int)DateTime.Now.Ticks);
        //  对于C#的随机数,没什么好说的
        System.Threading.Thread.Sleep(RandomNum_First.Next(50));
        Random RandomNum_Sencond = new Random((int)DateTime.Now.Ticks);

        //  为了在白色背景上显示,尽量生成深色
        int int_Red = RandomNum_First.Next(256);
        int int_Green = RandomNum_Sencond.Next(256);
        int int_Blue = (int_Red + int_Green > 400) ? 0 : 400 - int_Red - int_Green;
        int_Blue = (int_Blue > 255) ? 255 : int_Blue;

        return Color.FromArgb(int_Red, int_Green, int_Blue);
    }

后面还有 40 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。