示例#1
0
        private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            App.Current.EntityService.SearchQuery = SearchTextBox.Text;
            string q         = SearchTextBox.Text.ToLower();
            string translite = _helper.ReverseString(q);

            if (!string.IsNullOrEmpty(q))
            {
                SearchDescription.Visibility = System.Windows.Visibility.Collapsed;

                var friendsSel = App.Current.EntityService.Friends.Where(x => x.FullName.ToLower().StartsWith(q) ||
                                                                         x.FullName.ToLower().StartsWith(translite));

                _friends.Clear();
                foreach (var friend in friendsSel)
                {
                    _friends.Add(friend);
                }

                var contacts = _invisibleContacts.Where(x => x.FullName.ToLower().StartsWith(q) || x.ContactName.ToLower().StartsWith(q) ||
                                                        x.FullName.ToLower().StartsWith(translite) || x.ContactName.ToLower().StartsWith(translite));

                _contacts.Clear();
                foreach (var contact in contacts)
                {
                    _contacts.Add(contact);
                }

                var others = App.Current.EntityService.OtherUsers.Where(x => x.FullName.ToLower().StartsWith(q) ||
                                                                        x.FullName.ToLower().StartsWith(translite));

                _others.Clear();
                foreach (var other in others)
                {
                    _others.Add(other);
                }
            }
            else
            {
                SearchDescription.Visibility = System.Windows.Visibility.Visible;

                _friends.Clear();
                _contacts.Clear();
            }

            _model = new SearchResultsByType(_friends, _contacts, _others);
            friends.ItemsSource = _model;
        }
示例#2
0
        public SearchPage()
        {
            InitializeComponent();

            _invisibleContacts = App.Current.EntityService.Contacts;

            _friends = new ObservableCollection<FriendViewModel>();
            _contacts = new ObservableCollection<PhoneContact>();
            _others = new ObservableCollection<UserInfo>();

            _model = new SearchResultsByType(_friends, _contacts, _others);

            friends.ItemsSource = _model;

            _helper = new TransliteHelper();
        }
示例#3
0
        public SearchPage()
        {
            InitializeComponent();

            _invisibleContacts = App.Current.EntityService.Contacts;

            _friends  = new ObservableCollection <FriendViewModel>();
            _contacts = new ObservableCollection <PhoneContact>();
            _others   = new ObservableCollection <UserInfo>();

            _model = new SearchResultsByType(_friends, _contacts, _others);

            friends.ItemsSource = _model;

            _helper = new TransliteHelper();
        }
示例#4
0
        private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            App.Current.EntityService.SearchQuery = SearchTextBox.Text;
            string q = SearchTextBox.Text.ToLower();
            string translite = _helper.ReverseString(q);

            if (!string.IsNullOrEmpty(q))
            {
                SearchDescription.Visibility = System.Windows.Visibility.Collapsed;

                var friendsSel = App.Current.EntityService.Friends.Where(x => x.FullName.ToLower().StartsWith(q) ||
                    x.FullName.ToLower().StartsWith(translite));

                _friends.Clear();
                foreach (var friend in friendsSel)
                {
                    _friends.Add(friend);
                }

                var contacts = _invisibleContacts.Where(x => x.FullName.ToLower().StartsWith(q) || x.ContactName.ToLower().StartsWith(q) ||
                    x.FullName.ToLower().StartsWith(translite) || x.ContactName.ToLower().StartsWith(translite));

                _contacts.Clear();
                foreach (var contact in contacts)
                {
                    _contacts.Add(contact);
                }

                var others = App.Current.EntityService.OtherUsers.Where(x => x.FullName.ToLower().StartsWith(q) ||
                    x.FullName.ToLower().StartsWith(translite));

                _others.Clear();
                foreach (var other in others)
                {
                    _others.Add(other);
                }
            }
            else
            {
                SearchDescription.Visibility = System.Windows.Visibility.Visible;

                _friends.Clear();
                _contacts.Clear();
            }

            _model = new SearchResultsByType(_friends, _contacts, _others);
            friends.ItemsSource = _model;
        }