Represents the options used during a search operation.
예제 #1
0
        /* Public members */


        /// <summary>Searches for text using the specified search options.</summary>
        /// <param name="options">The search options.</param>
        /// <returns>The search results, or null in case no results were found.</returns>
        public SubtitleSearchResults Find(SubtitleSearchOptions options)
        {
            if (options.Backwards)
            {
                return(FindBackward(options));
            }
            else
            {
                return(FindForward(options));
            }
        }
예제 #2
0
        /// <summary>Searches backward for text using the specified search options.</summary>
        /// <param name="options">The search options.</param>
        /// <returns>The search results, or null in case no results were found.</returns>
        private SubtitleSearchResults FindBackward(SubtitleSearchOptions options)
        {
            SubtitleCollection collection = subtitles.Collection;

            if (collection.Count == 0)
            {
                return(null);
            }

            /* Search the subtitle starting at the startIndex */
            SubtitleSearchResults results = FindInSubtitleFromIndex(options.StartSubtitle, options.LineBreak, options.Regex, options.StartIndex, options.TextType, options.Backwards);

            if (results != null)
            {
                return(results);
            }

            /* Iterate through the start of the collection */
            for (int subtitleNumber = options.StartSubtitle - 1; subtitleNumber > 0; subtitleNumber--)
            {
                results = FindInSubtitle(subtitleNumber, options.LineBreak, options.Regex, options.Backwards);
                if (results != null)
                {
                    return(results);
                }
            }

            if (options.Wrap)
            {
                /* Iterate from the end back to the subtitle */
                for (int subtitleNumber = collection.Count - 1; subtitleNumber > options.StartSubtitle; subtitleNumber--)
                {
                    results = FindInSubtitle(subtitleNumber, options.LineBreak, options.Regex, options.Backwards);
                    if (results != null)
                    {
                        return(results);
                    }
                }
                /* Search the subtitle ending at the startIndex */
                results = FindInSubtitleTillIndex(options.StartSubtitle, options.LineBreak, options.Regex, options.StartIndex, options.TextType, options.Backwards);
                if (results != null)
                {
                    return(results);
                }
            }

            /* Text not found */
            return(null);
        }
예제 #3
0
	/* Public members */


	/// <summary>Searches for text using the specified search options.</summary>
	/// <param name="options">The search options.</param>
	/// <returns>The search results, or null in case no results were found.</returns>
	public SubtitleSearchResults Find (SubtitleSearchOptions options) {
		if (options.Backwards)
			return FindBackward(options);
		else
			return FindForward(options);
	}
예제 #4
0
	/// <summary>Searches backward for text using the specified search options.</summary>
	/// <param name="options">The search options.</param>
	/// <returns>The search results, or null in case no results were found.</returns>
	private SubtitleSearchResults FindBackward (SubtitleSearchOptions options) {
		SubtitleCollection collection = subtitles.Collection;

		if (collection.Count == 0)
			return null;

		/* Search the subtitle starting at the startIndex */
		SubtitleSearchResults results = FindInSubtitleFromIndex(options.StartSubtitle, options.LineBreak, options.Regex, options.StartIndex, options.TextType, options.Backwards);
		if (results != null)
			return results;

		/* Iterate through the start of the collection */
		for (int subtitleNumber = options.StartSubtitle - 1 ; subtitleNumber > 0 ; subtitleNumber--) {
			results = FindInSubtitle(subtitleNumber, options.LineBreak, options.Regex, options.Backwards);
			if (results != null)
				return results;
		}

		if (options.Wrap) {
			/* Iterate from the end back to the subtitle */
			for (int subtitleNumber = collection.Count - 1 ; subtitleNumber > options.StartSubtitle ; subtitleNumber--) {
				results = FindInSubtitle(subtitleNumber, options.LineBreak, options.Regex, options.Backwards);
				if (results != null)
					return results;
			}
			/* Search the subtitle ending at the startIndex */
			results = FindInSubtitleTillIndex(options.StartSubtitle, options.LineBreak, options.Regex, options.StartIndex, options.TextType, options.Backwards);
			if (results != null)
				return results;
		}

		/* Text not found */
		return null;
	}