SoFunction
Updated on 2025-03-07

Simple generation of registration code (number + uppercase and lowercase letters)


using ;
using ;
using ;

namespace
{
/// <summary>
/// Summary description of SigowayDraw
/// </summary>
public class SigowayDraw
{
#region constructor

/// <summary>
/// Construct method
/// </summary>
public SigowayDraw() { }

#endregion

#region Draw the verification code

/// <summary>
/// Draw the verification code
/// </summary>
/// <returns>Check code</returns>
public string DrawString()
{
// Set font
Font drawFont = new Font("Arial", 10);
// Create bitmap elements
Bitmap objBitmap = new Bitmap(50, 20);
// Create drawing objects
Graphics objGraphics = (objBitmap);
// Set the canvas background color
();
// Get random string
string[] strDrawString = ();

// Draw strings
(strDrawString[0], drawFont, new SolidBrush(), 1, 2);
(strDrawString[1], drawFont, new SolidBrush(), 12, 2);
(strDrawString[2], drawFont, new SolidBrush(), 24, 2);
(strDrawString[3], drawFont, new SolidBrush(), 35, 2);

// Draw interference lines
(, 5, 10, 40, 3);
(, 10, 5, 45, 15);
(, 15, 20, 30, 10);
(, 10, 15, 35, 20);

// Draw the image into the bitmap object
(objBitmap, 0, 0);

// Set the image path and name
string strFile = () + "/Resource/img/";

// Output file
(strFile, );

//Connect the check code string
string strCheckCode = ;
foreach (string strTemp in strDrawString)
{
strCheckCode += strTemp;
}

// Return to the verification code
return strCheckCode;
}

#endregion
}
}