/// <summary> /// Search method that matches the title of windows with the user search text /// </summary> /// <param name="openWindows">what windows are open</param> /// <returns>Returns search results</returns> private List <SearchResult> FuzzySearchOpenWindows(List <Window> openWindows) { List <SearchResult> result = new List <SearchResult>(); List <SearchString> searchStrings = new List <SearchString>(); searchStrings.Add(new SearchString(searchText, SearchResult.SearchType.Fuzzy)); foreach (var searchString in searchStrings) { foreach (var window in openWindows) { var titleMatch = FuzzyMatching.FindBestFuzzyMatch(window.Title, searchString.SearchText); var processMatch = FuzzyMatching.FindBestFuzzyMatch(window.ProcessInfo.Name, searchString.SearchText); if ((titleMatch.Count != 0 || processMatch.Count != 0) && window.Title.Length != 0) { var temp = new SearchResult(window, titleMatch, processMatch, searchString.SearchType); result.Add(temp); } } } System.Diagnostics.Debug.Print("Found " + result.Count + " windows that match the search text"); return(result); }
/// <summary> /// Search method that matches the title of windows with the user search text /// </summary> /// <param name="openWindows">what windows are open</param> /// <returns>Returns search results</returns> private List <SearchResult> FuzzySearchOpenWindows(List <Window> openWindows) { List <SearchResult> result = new List <SearchResult>(); List <SearchString> searchStrings = new List <SearchString>(); searchStrings.Add(new SearchString(searchText, SearchResult.SearchType.FuzzyOrSimple)); foreach (var searchString in searchStrings) { foreach (var window in openWindows) { List <int> titleMatch = new List <int>(); List <int> processMatch = new List <int>(); if (searchString.SearchText.StartsWith(" ", true, CultureInfo.CurrentCulture)) { string trimmedSearchText = searchString.SearchText.Trim(); titleMatch = FuzzyMatching.FindBestFuzzyMatch(window.Title, trimmedSearchText); processMatch = FuzzyMatching.FindBestFuzzyMatch(window.ProcessName, trimmedSearchText); } else { titleMatch = SimpleMatching.FindMatch(window.Title, searchString.SearchText); processMatch = SimpleMatching.FindMatch(window.ProcessName, searchString.SearchText); } if ((titleMatch.Count != 0 || processMatch.Count != 0) && window.Title.Length != 0) { var temp = new SearchResult(window, titleMatch, processMatch, searchString.SearchType); result.Add(temp); } } } System.Diagnostics.Debug.Print("Found " + result.Count + " windows that match the search text"); return(result); }