// Methods
 internal static bool ParseTextSizeParam(NameValueCollection parameters, out TextContainerSizeType textSizeType)
 {
     if ((null != parameters) && !string.IsNullOrEmpty(parameters[TextDependentImageCreator.TEXTCONTSIZETYPE_KEY]))
     {
         textSizeType = (TextContainerSizeType)Enum.Parse(typeof(TextContainerSizeType), parameters[TextDependentImageCreator.TEXTCONTSIZETYPE_KEY]);
         return true;
     }
     else
     {
         textSizeType = TextContainerSizeType.Specified;
         return false;
     }
 }
        // Methods
        internal static string ToQueryString(
            int width,
            int height,
            int clientCacheDuration,
            int serverCacheDuration,
            RotateFlipType rotateFlip,
            bool drawGrayscale,
            bool drawSepia,
            DynamicText text,
            DynamicImageFormat imageFormat,
            KeyValuePair<Type, IDictionary<string, string>>? imageCreator,
            Dictionary<Type, IDictionary<string, string>> imageTransformations,
            TextContainerSizeType sizeType,
            CaptchaStyle distortionStyle,
            ReadnessLevel readnessLevel,
            Color backColor)
        {
            string dynamicImageQueryString = DynamicImageProvider.ToQueryString(
                null,
                width,
                height,
                clientCacheDuration,
                serverCacheDuration,
                rotateFlip,
                drawGrayscale,
                drawSepia,
                text,
                imageFormat,
                imageCreator,
                imageTransformations);

            List<string> parameters = new List<string>();
            string parameterFormat = "{0}={1}";

            // size type
            if (TextContainerSizeType.Specified != sizeType)
            {
                parameters.Add(string.Format(parameterFormat, TextDependentImageCreator.TEXTCONTSIZETYPE_KEY, sizeType));
            }

            // distortion style
            if (CaptchaStyle.Confetti != distortionStyle)
            {
                parameters.Add(string.Format(parameterFormat, CaptchaImageTransformation.DISTSTYLE_KEY, distortionStyle));
            }

            // readness level
            if (ReadnessLevel.Normal != readnessLevel)
            {
                parameters.Add(string.Format(parameterFormat, CaptchaImageTransformation.READLEVEL_KEY, readnessLevel));
            }

            // back color
            if (Color.White != backColor)
            {
                parameters.Add(string.Format(parameterFormat, CaptchaImageTransformation.CAPTCHABACKCOLOR_KEY, backColor.ToArgb()));
            }

            return (0 < parameters.Count) ? string.Concat(dynamicImageQueryString, "&", string.Join("&", parameters.ToArray())) : dynamicImageQueryString;
        }
        // Methods
        /// <summary>
        /// Utility method that returns a query string representation based on the provided parameter values.
        /// </summary>
        /// <param name="source">The image source.</param>
        /// <param name="width">The image width.</param>
        /// <param name="height">The image height.</param>
        /// <param name="clientCacheDuration">The image client cache duration.</param>
        /// <param name="serverCacheDuration">The image server cache duration.</param>
        /// <param name="rotateFlip">The image rotate flip type.</param>
        /// <param name="drawGrayscale">The image draw grayscale type.</param>
        /// <param name="drawSepia">The image draw sepia type.</param>
        /// <param name="text">The image dynamic text.</param>
        /// <param name="gradientBackground">The button gradient background.</param>
        /// <param name="sizeType">The button size type.</param>
        /// <param name="textRenderTime">The time when the text is rendered.</param>
        internal static string ToQueryString(
            int width,
            int height,
            int clientCacheDuration,
            int serverCacheDuration,
            RotateFlipType rotateFlip,
            bool drawGrayscale,
            bool drawSepia,
            DynamicText text,
            DynamicImageFormat imageFormat,
            KeyValuePair<Type, IDictionary<string, string>>? imageCreator,
            Dictionary<Type, IDictionary<string, string>> imageTransformations,
            GradientBackground gradientBackground,
            TextContainerSizeType sizeType)
        {
            string dynamicImageQueryString = DynamicImageProvider.ToQueryString(
                null,
                width,
                height,
                clientCacheDuration,
                serverCacheDuration,
                rotateFlip,
                drawGrayscale,
                drawSepia,
                text,
                imageFormat,
                imageCreator,
                imageTransformations);

            List<string> parameters = new List<string>();
            string parameterFormat = "{0}={1}";

            if (null != gradientBackground)
            {
                // gradient border color
                if (Color.Gray != gradientBackground.BorderColor)
                {
                    parameters.Add(string.Format(parameterFormat, GradientButtonImageTransformation.GRADIENTBKGCOLOR_KEY, gradientBackground.BorderColor.ToArgb()));
                }

                // gradient start color
                if (Color.Brown != gradientBackground.GradientStartColor)
                {
                    parameters.Add(string.Format(parameterFormat, GradientButtonImageTransformation.GRADIENTBKGSTARTCOLOR_KEY, gradientBackground.GradientStartColor.ToArgb()));
                }

                // gradient end color
                if (Color.White != gradientBackground.GradientEndColor)
                {
                    parameters.Add(string.Format(parameterFormat, GradientButtonImageTransformation.GRADIENTBKGENDCOLOR_KEY, gradientBackground.GradientEndColor.ToArgb()));
                }

                // gradient round corner radius
                if (0 <= gradientBackground.RoundCornerRadius)
                {
                    parameters.Add(string.Format(parameterFormat, GradientButtonImageTransformation.GRADIENTBKGRCORNER_KEY, gradientBackground.RoundCornerRadius));
                }

                // gradient border width
                if (0 <= gradientBackground.BorderWidth)
                {
                    parameters.Add(string.Format(parameterFormat, GradientButtonImageTransformation.GRADIENTBKGBWIDTH_KEY, gradientBackground.BorderWidth));
                }

                // gradient type
                if (GradientType.BackwardDiagonal != gradientBackground.Type)
                {
                    parameters.Add(string.Format(parameterFormat, GradientButtonImageTransformation.GRADIENTBKGTYPE_KEY, gradientBackground.Type));
                }

                // gradient inner border color
                if (Color.Gray != gradientBackground.InnerBorderColor)
                {
                    parameters.Add(string.Format(parameterFormat, GradientButtonImageTransformation.GRADIENTBKGIBCOLOR_KEY, gradientBackground.InnerBorderColor.ToArgb()));
                }

                // gradient inner border width
                if (0 <= gradientBackground.InnerBorderWidth)
                {
                    parameters.Add(string.Format(parameterFormat, GradientButtonImageTransformation.GRADIENTBKGIBWIDTH_KEY, gradientBackground.InnerBorderWidth));
                }
            }

            // size type
            if (TextContainerSizeType.Specified != sizeType)
            {
                parameters.Add(string.Format(parameterFormat, TextDependentImageCreator.TEXTCONTSIZETYPE_KEY, sizeType));
            }

            return (0 < parameters.Count) ? string.Concat(dynamicImageQueryString, "&", string.Join("&", parameters.ToArray())) : dynamicImageQueryString;
        }