Пример #1
0
        /// <summary>
        /// The position in the original string where the first character of the captured substring was found.
        /// </summary>
        /// <param name="queryString">The query string to search.</param>
        /// <returns>
        /// The zero-based starting position in the original string where the captured substring was found.
        /// </returns>
        public int MatchRegexIndex(string queryString)
        {
            int index = 0;

            // Set the sort order to max to allow filtering.
            this.SortOrder = int.MaxValue;

            foreach (Match match in this.RegexPattern.Matches(queryString))
            {
                if (match.Success)
                {
                    if (index == 0)
                    {
                        // Set the index on the first instance only.
                        this.SortOrder = match.Index;
                        int percentage = CommonParameterParserUtility.ParseIn100Range(match.Value);
                        this.Processor.DynamicParameter = percentage;
                    }

                    index += 1;
                }
            }

            return(this.SortOrder);
        }
Пример #2
0
        /// <summary>
        /// The position in the original string where the first character of the captured substring was found.
        /// </summary>
        /// <param name="queryString">
        /// The query string to search.
        /// </param>
        /// <returns>
        /// The zero-based starting position in the original string where the captured substring was found.
        /// </returns>
        public int MatchRegexIndex(string queryString)
        {
            int index = 0;

            // Set the sort order to max to allow filtering.
            this.SortOrder = int.MaxValue;

            foreach (Match match in this.RegexPattern.Matches(queryString))
            {
                if (match.Success)
                {
                    if (index == 0)
                    {
                        // Set the index on the first instance only.
                        this.SortOrder = match.Index;

                        // Normalise and set the variables.
                        int    maxSize;
                        double maxSigma;
                        int    maxThreshold;

                        int.TryParse(this.Processor.Settings["MaxSize"], NumberStyles.Any, CultureInfo.InvariantCulture, out maxSize);
                        double.TryParse(this.Processor.Settings["MaxSigma"], NumberStyles.Any, CultureInfo.InvariantCulture, out maxSigma);
                        int.TryParse(this.Processor.Settings["MaxThreshold"], NumberStyles.Any, CultureInfo.InvariantCulture, out maxThreshold);

                        this.Processor.DynamicParameter = CommonParameterParserUtility.ParseGaussianLayer(queryString, maxSize, maxSigma, maxThreshold);
                    }

                    index += 1;
                }
            }

            return(this.SortOrder);
        }
Пример #3
0
        /// <summary>
        /// The position in the original string where the first character of the captured substring was found.
        /// </summary>
        /// <param name="queryString">
        /// The query string to search.
        /// </param>
        /// <returns>
        /// The zero-based starting position in the original string where the captured substring was found.
        /// </returns>
        public int MatchRegexIndex(string queryString)
        {
            int index = 0;

            // Set the sort order to max to allow filtering.
            this.SortOrder = int.MaxValue;

            foreach (Match match in this.RegexPattern.Matches(queryString))
            {
                if (match.Success)
                {
                    if (index == 0)
                    {
                        // Set the index on the first instance only.
                        this.SortOrder = match.Index;

                        Color color = CommonParameterParserUtility.ParseColor(match.Value.Split('=')[1]);
                        if (color.Equals(Color.Transparent))
                        {
                            color = Color.Black;
                        }

                        this.Processor.DynamicParameter = color;
                    }

                    index += 1;
                }
            }

            return(this.SortOrder);
        }
Пример #4
0
        /// <summary>
        /// The position in the original string where the first character of the captured substring was found.
        /// </summary>
        /// <param name="queryString">
        /// The query string to search.
        /// </param>
        /// <returns>
        /// The zero-based starting position in the original string where the captured substring was found.
        /// </returns>
        public int MatchRegexIndex(string queryString)
        {
            int index = 0;

            // Set the sort order to max to allow filtering.
            this.SortOrder = int.MaxValue;

            foreach (Match match in this.RegexPattern.Matches(queryString))
            {
                if (match.Success)
                {
                    if (index == 0)
                    {
                        // Set the index on the first instance only.
                        this.SortOrder = match.Index;
                        float angle    = CommonParameterParserUtility.ParseAngle(match.Value);
                        bool  keepSize = BoundRegex.Match(queryString).Success;
                        Tuple <float, bool> rotateParams = new Tuple <float, bool>(angle, keepSize);

                        this.Processor.DynamicParameter = rotateParams;
                    }

                    index += 1;
                }
            }

            return(this.SortOrder);
        }
Пример #5
0
        /// <summary>
        /// Returns the correct <see cref="int"/> for the given string.
        /// </summary>
        /// <param name="input">
        /// The input string containing the value to parse.
        /// </param>
        /// <returns>
        /// The correct <see cref="int"/>
        /// </returns>
        private int ParseOpacity(string input)
        {
            int   opacity = 100;
            Match match   = OpacityRegex.Match(input);

            if (match.Success)
            {
                opacity = Math.Abs(CommonParameterParserUtility.ParseIn100Range(match.Value.Split('=')[1]));
            }

            return(opacity);
        }
Пример #6
0
        /// <summary>
        /// Returns the angle to alter the hue.
        /// </summary>
        /// <param name="input">
        /// The input containing the value to parse.
        /// </param>
        /// <returns>
        /// The <see cref="int"/> representing the angle.
        /// </returns>
        public Color[] ParseColor(string input)
        {
            IEnumerable <Color> colors = Enumerable.Empty <Color>();
            Match match = ReplaceRegex.Match(input);

            if (match.Success)
            {
                string[] colorQuery = match.Value.Split('=')[1].Split(new[] { "],[" }, StringSplitOptions.None);
                colors = colorQuery.Select(s => CommonParameterParserUtility.ParseColor(s.Replace("[", string.Empty).Replace("]", string.Empty)));
            }

            return(colors.ToArray());
        }
Пример #7
0
        /// <summary>
        /// Returns the correct <see cref="T:System.Drawing.Color"/> for the given string.
        /// </summary>
        /// <param name="input">
        /// The input string containing the value to parse.
        /// </param>
        /// <returns>
        /// The correct <see cref="T:System.Drawing.Color"/>
        /// </returns>
        private Color ParseColor(string input)
        {
            foreach (Match match in ColorRegex.Matches(input))
            {
                string value     = match.Value.Split(new[] { '=', '-' })[1];
                Color  textColor = CommonParameterParserUtility.ParseColor(value);
                if (!textColor.Equals(Color.Transparent))
                {
                    return(textColor);
                }
            }

            return(Color.Black);
        }