コード例 #1
0
        /// <summary>
        /// Constructor of the WinFormCaptcha class. (For math captcha.)
        /// </summary>
        /// <param name="width">The width of the captcha box to be created.</param>
        /// <param name="height">The height of the captcha box to be created.></param>
        /// <param name="isIncludeMathAddition">
        /// Checks that the math captcha contains addition math problems.
        /// </param>
        /// <param name="isIncludeMathSubstract">
        /// /// Checks that the math captcha contains substract math problems.
        /// </param>
        /// <param name="isIncludeMathMultiply">
        /// /// Checks that the math captcha contains multiply math problems.
        /// </param>
        /// <param name="isIncludeMathDivide">
        /// /// Checks that the math captcha contains divide math problems.
        /// </param>
        /// <param name="isIncludeLineOnCaptcha">
        /// Checks that the captcha contains lines on text.
        /// </param>
        /// <param name="isIncludeNoiseOnCaptcha">
        /// Checks that the captcha contains noises on text.
        /// </param>
        /// <param name="isMessyText">
        /// Checks that the captcha contains messy texts.
        /// </param>
        /// <param name="isDistortImage">
        /// Checks that the captcha distort.
        /// </param>
        public WinFormCaptcha(int width, int height, bool isIncludeMathAddition,
                              bool isIncludeMathSubstract, bool isIncludeMathMultiply, bool isIncludeMathDivide,
                              bool isIncludeLineOnCaptcha, bool isIncludeNoiseOnCaptcha, bool isMessyText,
                              bool isDistortImage)
        {
            rnd          = new Random();
            CaptchaStyle = CaptchaStyles.Math;

            Width  = width;
            Height = height;

            ChangeMathCaptchaSettings(isIncludeMathAddition, isIncludeMathSubstract,
                                      isIncludeMathMultiply, isIncludeMathDivide,
                                      isIncludeLineOnCaptcha, isIncludeNoiseOnCaptcha, isMessyText,
                                      isDistortImage);

            bmSz   = new Size(Width, Height);
            txtSz  = new Size(Width, Height);
            rectPt = new Point(0, 0);
            txtPt  = new Point(2, Height / TextLength);

            hatchStyleArray = Enum.GetValues(typeof(HatchStyle));
            fontStyleArray  = Enum.GetValues(typeof(FontStyle));

            tts = new TTS();
            ListFont();
        }
コード例 #2
0
        /// <summary>
        /// Constructor of the WinFormCaptcha class. (For normal captcha.)
        /// </summary>
        /// <param name="textLenght">The length of the text to be created.</param>
        /// <param name="width">The width of the captcha box to be created.</param>
        /// <param name="height">The height of the captcha box to be created.></param>
        /// <param name="isIncludeNumeric">Checks that the captcha contains numbers.</param>
        /// <param name="isIncludeLowerCaseChar">
        /// Checks that the captcha contains lower case characters.
        /// </param>
        /// <param name="isIncludeUpperCaseChar">
        /// Checks that the captcha contains upper case characters.
        /// </param>
        /// <param name="isIncludeSymbol">
        /// Checks that the captcha contains symbol.
        /// </param>
        /// <param name="isIncludeLineOnCaptcha">
        /// Checks that the captcha contains lines on text.
        /// </param>
        /// <param name="isIncludeNoiseOnCaptcha">
        /// Checks that the captcha contains noises on text.
        /// </param>
        /// <param name="isMessyText">
        /// Checks that the captcha contains messy texts.
        /// </param>
        /// <param name="isDistortImage">
        /// Checks that the captcha distort.
        /// </param>
        public WinFormCaptcha(int textLenght, int width, int height,
                              bool isIncludeNumeric       = true, bool isIncludeLowerCaseChar  = true,
                              bool isIncludeUpperCaseChar = true, bool isIncludeSymbol         = true,
                              bool isIncludeLineOnCaptcha = true, bool isIncludeNoiseOnCaptcha = true,
                              bool isMessyText            = true, bool isDistortImage = true)
        {
            rnd          = new Random();
            CaptchaStyle = CaptchaStyles.Normal;

            TextLength = textLenght;

            Width  = width;
            Height = height;

            ChangeNormCaptchaSettings(isIncludeNumeric, isIncludeLowerCaseChar,
                                      isIncludeUpperCaseChar, isIncludeSymbol, isIncludeLineOnCaptcha,
                                      isIncludeNoiseOnCaptcha, isMessyText, isDistortImage);

            bmSz   = new Size(Width, Height);
            txtSz  = new Size(Width, Height);
            rectPt = new Point(0, 0);
            txtPt  = new Point(2, Height / TextLength);

            hatchStyleArray = Enum.GetValues(typeof(HatchStyle));
            fontStyleArray  = Enum.GetValues(typeof(FontStyle));

            tts = new TTS();
            ListFont();
        }