private void SearchInTrips() { SearchExcludedItems.ForEach(t => { if (!Trips.Contains(t)) { Trips.Add(t); } }); SearchResultItems.Clear(); SearchExcludedItems.Clear(); SearchResultItems = Trips.Where(t => t.AirwayCompany.name.ToUpper().Contains(SearchText.ToUpper()) || t.AirwayCompany.ID_comp.ToString().Contains(SearchText) || t.DepTimeString.Contains(SearchText) || t.ArrTimeString.Contains(SearchText) || t.Plane.ToUpper().Contains(SearchText.ToUpper()) || t.TownFrom.ToUpper().Contains(SearchText.ToUpper()) || t.TownTo.ToUpper().Contains(SearchText.ToUpper()) || t.TripNumber.ToString().Contains(SearchText) ).ToList(); SearchExcludedItems = Trips.Where(t => !t.AirwayCompany.name.ToUpper().Contains(SearchText.ToUpper()) || !t.AirwayCompany.ID_comp.ToString().Contains(SearchText) || !t.DepTimeString.Contains(SearchText) || !t.ArrTimeString.Contains(SearchText) || !t.Plane.ToUpper().Contains(SearchText.ToUpper()) || !t.TownFrom.ToUpper().Contains(SearchText.ToUpper()) || !t.TownTo.ToUpper().Contains(SearchText.ToUpper()) || !t.TripNumber.ToString().Contains(SearchText)).ToList(); Trips.Clear(); SearchResultItems.ForEach(t => Trips.Add(t)); }
public override void OnNavigatingTo(INavigationParameters parameters) { PrimaryWindowCoreLayout.SetCurrentNavigationParameters(parameters); SearchResultItems.Clear(); base.OnNavigatingTo(parameters); }
public void PerformFind() { SearchResultItems.Clear(); List <string> allFiles = new List <string>(); AddFileNamesToList(ProjectPath, allFiles); foreach (string fileName in allFiles) { string contents = File.ReadAllText(fileName); var matches = new List <SearchMatch>(); int count = 0; RegexOptions regexOptions = CaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase; if (UseRegex) { string[] lines = contents.Replace("\r\n", "\n").Split("\n".ToCharArray()); int lineNo = 0; int caretIndex = 0; foreach (string line in lines) { lineNo++; MatchCollection matchCollection = new Regex(SearchText, regexOptions).Matches(line); if (matchCollection.Count > 0) { count += matchCollection.Count; foreach (var match in matchCollection) { matches.Add(new SearchMatch(caretIndex + ((Match)match).Index, ((Match)match).Length, lineNo)); } } caretIndex += line.Length + 2; } } else { //string searchText = CaseSensitive ? SearchText : SearchText.ToLower(); //string fixedContent = CaseSensitive ? contents : contents.ToLower(); string searchText = SearchText; searchText = Regex.Escape(searchText); if (WholeWords) { MatchCollection matchCollection = new Regex("\\b" + searchText + "\\b", regexOptions).Matches(contents); if (matchCollection.Count > 0) { count = matchCollection.Count; foreach (var match in matchCollection) { matches.Add(new SearchMatch(((Match)match).Index, ((Match)match).Length, LineFromPos(contents, ((Match)match).Index))); } } } else { MatchCollection matchCollection = new Regex(searchText, regexOptions).Matches(contents); if (matchCollection.Count > 0) { count = matchCollection.Count; foreach (var match in matchCollection) { matches.Add(new SearchMatch(((Match)match).Index, ((Match)match).Length, LineFromPos(contents, ((Match)match).Index))); } } } } if (count > 0) { SearchResultItems.Add(new SearchResultItem(fileName, fileName.Substring(ProjectPath.Length + 1), count, contents, matches.ToArray())); } } if (SearchResultItems.Count > 0) { SelectedIndex = 0; } OnAfterPerformFind(); }