예제 #1
0
        /// <summary>
        /// Find the first line which contains/match a specified text.
        /// </summary>
        /// <param name="text">The text to find.</param>
        /// <param name="searchOption">Whether the line contains the text, or match the text.</param>
        /// <returns>An instance of OCRLine.</returns>
        public OCRLine FindText(string text, SearchOptions searchOption = SearchOptions.Containing)
        {
            OCRLine result = null;

            foreach (OCRPage page in Pages)
            {
                result = page.FindText(text, searchOption);
                if (result != null)
                {
                    break;
                }
            }
            return(result);
        }
예제 #2
0
        /// <summary>
        /// Find the first line which contains/match a specified text.
        /// </summary>
        /// <param name="text">The text to find.</param>
        /// <param name="searchOption">Whether the line contains the text, or match the text.</param>
        /// <returns>An instance of OCRLine.</returns>
        public OCRLine FindText(string text, SearchOptions searchOption = SearchOptions.Containing)
        {
            OCRLine result = null;

            foreach (OCRBlock block in Blocks)
            {
                result = block.FindText(text, searchOption);
                if (result != null)
                {
                    break;
                }
            }
            return(result);
        }
예제 #3
0
        /// <summary>
        /// Find the first line which contains/match a specified text.
        /// </summary>
        /// <param name="text">The text to find.</param>
        /// <param name="searchOption">Whether the line contains the text, or match the text.</param>
        /// <returns>An instance of OCRLine.</returns>
        public OCRLine FindText(string text, SearchOptions searchOption = SearchOptions.Containing)
        {
            string  trip;
            OCRLine result = null;
            Regex   regex;

            switch (searchOption)
            {
            case SearchOptions.Containing:
                foreach (OCRLine line in Lines)
                {
                    if (line.FindWord(text, searchOption) != null)
                    {
                        result = line;
                        break;
                    }
                }
                break;

            case SearchOptions.Exact:
                foreach (OCRLine line in Lines)
                {
                    if (line.GetText() == text)
                    {
                        result = line;
                        break;
                    }
                }
                break;

            case SearchOptions.Spaces_Ignored:
                trip = text.Replace(" ", "");
                foreach (OCRLine line in Lines)
                {
                    if (line.GetNoSpacesText() == trip)
                    {
                        result = line;
                        break;
                    }
                }
                break;

            case SearchOptions.Containing_Spaces_Ignored:
                trip = text.Replace(" ", "");
                foreach (OCRLine line in Lines)
                {
                    if (line.GetNoSpacesText().Contains(trip))
                    {
                        result = line;
                        break;
                    }
                }
                break;

            case SearchOptions.Regex:
                regex = new Regex(text);
                foreach (OCRLine line in Lines)
                {
                    if (regex.IsMatch(line.GetText()))
                    {
                        result = line;
                        break;
                    }
                }
                break;

            case SearchOptions.Regex_Spaces_Ignored:
                regex = new Regex(text);
                foreach (OCRLine line in Lines)
                {
                    if (regex.IsMatch(line.GetNoSpacesText()))
                    {
                        result = line;
                        break;
                    }
                }
                break;
            }
            return(result);
        }