SHARE
TWEET

Untitled

a guest Mar 15th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private void SortFriends(object sender, TextChangedEventArgs e) {
  2.           var text = (sender as WatermarkTextBox).Text;
  3.           if (text != string.Empty) {
  4.             text = text.ToLowerInvariant();
  5.             var translatedColl = FriendCollectionTranslated.Where(i => i.FirstName.StartsWith(text) || i.LastName.StartsWith(text) ||
  6.                                                 i.FirstNameT.StartsWith(text) ||
  7.                                                 i.LastNameT.StartsWith(text));
  8.  
  9.             var newCollection = ((App)App.Current).CollectionFriends.Where(i => translatedColl.First(n => n.Uid == i.Uid) != null);
  10.  
  11.             friendsBox.ItemsSource = newCollection;
  12.           }
  13.           else friendsBox.ItemsSource = ((App)App.Current).CollectionFriends;
  14.         }
  15.     public class HumanTranslated {
  16.           public string Uid { get; set; }
  17.           public string FirstName { get; set; }
  18.           public string LastName { get; set; }
  19.           public string FirstNameT { get; set; }//Translit
  20.           public string LastNameT { get; set; }//Translit
  21.           public bool IsChecked { get; set; }
  22.         }
  23. private void PrepareCollection()//Ретранслируем наши данные для быстрого поиска
  24.     {
  25.       foreach (var t in ((App)App.Current).CollectionFriends) {
  26.         var item = new HumanTranslated {
  27.           Uid = t.Uid,
  28.           LastNameT = ToTranslit(t.LastName.ToLowerInvariant()),
  29.           FirstNameT = ToTranslit(t.FirstName.ToLowerInvariant()),
  30.           FirstName = t.FirstName.ToLowerInvariant(),
  31.           LastName = t.LastName.ToLowerInvariant()
  32.         };
  33.         FriendCollectionTranslated.Add(item);
  34.       }
  35.     }
  36. public class Human {
  37.           public string Uid { get; set; }
  38.           public string FirstName { get; set; }
  39.           public string LastName { get; set; }
  40.           public bool IsChecked { get; set; }
  41.         }
  42.    
  43. var translatedColl = FriendCollectionTranslated.Where(
  44.                       i => i.FirstName.ToLowerInvariant().StartsWith(text) ||
  45.                            i.LastName.ToLowerInvariant().StartsWith(text) ||
  46.                            i.FirstNameT.ToLowerInvariant().StartsWith(text) ||
  47.                            i.LastNameT.ToLowerInvariant().StartsWith(text));
  48.    
  49. var translatedColl = FriendCollectionTranslated.Where(
  50.               i => i.FirstName.StartsWith(text,StringComparison.InvariantCultureIgnoreCase) ||
  51.                    i.LastName.StartsWith(text,StringComparison.InvariantCultureIgnoreCase) ||
  52.                    i.FirstNameT.StartsWith(text,StringComparison.InvariantCultureIgnoreCase) ||
  53.                    i.LastNameT.StartsWith(text, StringComparison.InvariantCultureIgnoreCase));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top