private void StartSearch() { string text = NormalizeString(TextBoxEntered.Text); Logging.ToLog("Поиск по тексту: " + text); if (string.IsNullOrWhiteSpace(text) || string.IsNullOrEmpty(text)) { SetHintText(); return; } pages.Clear(); GridPagesIndicator.RowDefinitions.Clear(); GridPagesIndicator.Children.Clear(); currentPageIndex = 0; List <string> objectsFounded = new List <string>(); int maxElementsPerPage = 1; switch (source) { case PageSelectDepartment.Source.Price: maxElementsPerPage = 4; foreach (List <ItemService> itemServiceList in Services.DataProvider.Services.Values) { foreach (ItemService itemService in itemServiceList) { string[] values = text.Split(' '); bool contains = true; string normalizedName = NormalizeString(itemService.Name); foreach (string value in values) { if (!normalizedName.Contains(value)) { contains = false; break; } } if (contains) { objectsFounded.Add(itemService.Name + "@" + itemService.Cost); } } } break; case PageSelectDepartment.Source.DocInfo: break; case PageSelectDepartment.Source.Timetable: maxElementsPerPage = 5; foreach (KeyValuePair <string, SortedDictionary <string, SortedDictionary <string, string> > > pair in Services.DataProvider.Schedule) { foreach (string doctor in pair.Value.Keys) { if (NormalizeString(doctor).StartsWith(text)) { objectsFounded.Add(doctor + "@" + pair.Key); } } } break; case PageSelectDepartment.Source.DocRate: maxElementsPerPage = 5; foreach (KeyValuePair <string, List <ItemDoctor> > pair in Services.DataProvider.Survey) { foreach (ItemDoctor doctor in pair.Value) { if (NormalizeString(doctor.Name).StartsWith(text)) { objectsFounded.Add(doctor + "@" + pair.Key); } } } break; default: break; } if (objectsFounded.Count == 0) { Logging.ToLog("По заданному тексту докторов не найдено"); SetLabelInfoToNothingFound(); return; } objectsFounded.Sort(); List <string> pageObjects = new List <string>(); for (int i = 0; i < objectsFounded.Count; i++) { pageObjects.Add(objectsFounded[i]); if (pageObjects.Count == maxElementsPerPage) { AddPageToList(pageObjects, maxElementsPerPage); } } if (pageObjects.Count > 0) { AddPageToList(pageObjects, maxElementsPerPage); } if (pages.Count == 0) { SetLabelInfoToNothingFound(); return; } try { UserContent.Navigate(pages[0].Key); } catch (Exception e) { Console.WriteLine(e.Message + Environment.NewLine + e.StackTrace); return; } UserContent.Visibility = Visibility.Visible; TextBlockHint.Visibility = Visibility.Hidden; if (pages.Count > 1) { pages[0].Value.Background = new SolidColorBrush(Colors.Gray); ButtonScrollDown.Visibility = Visibility.Visible; GridPagesIndicator.Visibility = Visibility.Visible; } else { ButtonScrollDown.Visibility = Visibility.Hidden; ButtonScrollUp.Visibility = Visibility.Hidden; GridPagesIndicator.Visibility = Visibility.Hidden; } currentPageIndex = 0; }