<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      C# 驗證碼

      作者:陳太漢

      C# 驗證碼

      多功能注冊碼,注冊碼可以完全自定義,全部都是動態的,包括字體的顏色,大小,樣式,還有內容

       

      using System;
      using System.Drawing;

      namespace SecurityCode
      {
      public class DrawMethod
      {

      /// <summary>
      /// 畫圖
      /// </summary>
      /// <param name="content"></param>
      /// <param name="size"></param>
      /// <param name="fileName"></param>
      public void Draw(string content,Size size,string fileName)
      {
      Image image
      = new Bitmap(size.Width,size.Height);
      Graphics g
      = Graphics.FromImage(image);
      DrawBorder(g,image.Size);
      DrawContent(g,content,image.Size,(
      int)FontSet.Font.Size);
      DrawRandom(g, image.Size);
      image.Save(
      @"D:\\" + fileName);
      }

      /// <summary>
      /// 畫邊框
      /// </summary>
      /// <param name="g"></param>
      /// <param name="size"></param>
      private void DrawBorder(Graphics g, Size size)
      {
      Pen pen
      = new Pen(SolidBrushSet.SolidBrush);
      Rectangle rect
      =new Rectangle(1,1,size.Width-4,size.Height-4);
      g.DrawRectangle(pen,rect);
      }

      //畫字符串
      private void DrawContent(Graphics g, string content,Size size,int fontHeight)
      {
      Point point
      = new Point();
      int i = 0;
      point.Y
      = (size.Height - fontHeight) / 2;
      int distance = size.Width / (content.Length+1);
      foreach (char c in content)
      {
      point.X
      = i * distance + distance/2;
      g.DrawString(c.ToString(), FontSet.Font, SolidBrushSet.SolidBrush, point);
      i
      ++;
      }
      }

      /// <summary>
      /// 畫干擾
      /// </summary>
      /// <param name="g"></param>
      /// <param name="size"></param>
      private void DrawRandom(Graphics g, Size size)
      {
      Pen pen
      = new Pen(SolidBrushSet.SolidBrush);
      Random rand
      = new Random();
      for (int i = 0; i < 3; i++)
      {
      g.DrawLine(pen, rand.Next(size.Width), rand.Next(size.Width), rand.Next(size.Height), rand.Next(size.Height));
      }

      for (int i = 0; i < 10; i++)
      {
      Rectangle rect
      = new Rectangle(rand.Next(2, size.Width - 2), rand.Next(2, size.Height - 2), 1, 1);
      g.DrawRectangle(pen, rect);
      }
      }

      }
      }

      using System;

      namespace SecurityCode
      {
      /// <summary>
      /// 自動生成字符串
      /// </summary>
      public class CreateContent
      {
      private string so = "1234567890abcdefghijklmnopqrstuvwxyzQWERTYUIOPASDFGHJKLZXCVBNM";

      /// <summary>
      /// 生成內容
      /// </summary>
      /// <returns></returns>
      public string GetContent()
      {
      Random rand
      = new Random();
      string str = null;
      for (int i = 0; i < 6; i++)
      {
      str
      += so.Substring(rand.Next(62), 1);
      }
      return str;
      }
      }
      }

      using System;
      using System.Drawing;

      namespace SecurityCode
      {
      /// <summary>
      /// 字體設置
      /// </summary>
      public class FontSet
      {
      public static Font Font
      {
      get
      {
      FontFamily fFamily
      = GetFontFamily();
      FontStyle fStyle
      = GetFontStyle();
      int emSize = GetFontSize();
      return new Font(fFamily, emSize, fStyle);
      }
      }

      private FontSet() { }


      /// <summary>
      /// 設置字體
      /// </summary>
      private static FontFamily GetFontFamily()
      {
      Random rand
      = new Random();
      return FontFamily.Families[rand.Next(FontFamily.Families.Length)];
      }

      /// <summary>
      /// 設置字體樣式
      /// </summary>
      private static FontStyle GetFontStyle()
      {
      Random rand
      = new Random();
      int index = rand.Next(1, 4);
      index
      = 1 << index;
      return (FontStyle)index;
      }

      /// <summary>
      /// 設置字體大小
      /// </summary>
      public static int GetFontSize()
      {
      Random rand
      = new Random();
      return rand.Next(12, 14);
      }
      }
      }

      using System;
      using System.Drawing;

      namespace SecurityCode
      {
      /// <summary>
      /// 畫筆設置
      /// </summary>
      public class SolidBrushSet
      {
      /// <summary>
      /// 畫筆
      /// </summary>
      public static SolidBrush SolidBrush
      {
      get {
      Color color
      = GetColor();
      return new SolidBrush(color);
      }
      }

      private SolidBrushSet(){}

      /// <summary>
      /// 隨機生成畫筆顏色
      /// </summary>
      /// <returns></returns>
      public static Color GetColor()
      {
      Random rand
      = new Random();
      int r = rand.Next(0,255);
      int g = rand.Next(0, 255);
      int b = rand.Next(0, 255);
      return Color.FromArgb(r,g,b);
      }
      }
      }

      private void Test()
      {
      DrawMethod drawMethod
      = new DrawMethod();
      CreateContent createCont
      = new CreateContent();
      for (int i = 0; i < 10; i++)
      {
      string content = createCont.GetContent();
      Size size
      = new Size(100, 40);
      drawMethod.Draw(content, size, i.ToString()
      + ".jpg");
      }
      }
      posted @ 2011-05-06 18:57  古文觀芷  閱讀(705)  評論(1)    收藏  舉報
      主站蜘蛛池模板: 动漫精品中文无码卡通动漫| 最新国产精品拍自在线观看| 色噜噜亚洲精品中文字幕| 国产精品久久久久久久久久妞妞| 人妻精品久久久无码区色视| 97精品亚成在人线免视频| 天天爽夜夜爱| 久久精品免视看成人国产| 张北县| 精品国产午夜福利伦理片| 人妻中文字幕精品系列| 暖暖 在线 日本 免费 中文| 在线aⅴ亚洲中文字幕| 国产午夜精品理论大片| 亚洲中文字幕乱码一区| 南溪县| 蜜臀av久久国产午夜| 国产精品福利自产拍久久| 高清不卡一区二区三区| 无人区码一码二码三码区 | 国产超碰人人做人人爰| 狠狠综合久久久久综| 日本欧美大码a在线观看| 国产女人水真多18毛片18精品 | 国产成人亚洲综合图区| 国产不卡免费一区二区| 狠狠色综合久久狠狠色综合| 熟女性饥渴一区二区三区| 蜜臀av色欲a片无人一区| 女人与牲口性恔配视频免费| 美女午夜福利视频一区二区| 在线看无码的免费网站| 人妻精品动漫H无码中字| 丰满少妇熟乱xxxxx视频| 狠狠色噜噜狠狠狠狠av不卡| 色综合久久综合中文综合网| 日韩人妻无码精品久久| 日区中文字幕一区二区| 国产精品中出一区二区三区| 开心激情站开心激情网六月婷婷| 精品国产色情一区二区三区|