コード例 #1
0
        private void search(string searchWord)
        {
            searchWord.Replace(',', ' ');

            searchWords = searchWord.Split(separator, StringSplitOptions.RemoveEmptyEntries).ToList();

            if (!string.IsNullOrEmpty(searchWord) && searchWord != defaultSearchString)
            {
                progress.Visibility = System.Windows.Visibility.Visible;
                searchResult.Clear();
                foreach (var product in products)
                {
                    int count = 0;
                    foreach (string str in searchWords)
                    {
                        if (product.productName.ToUpper().Contains(str))
                        {
                            count++;
                        }
                    }
                    if (count > 0)
                    {
                        CProductsSearch prod = new CProductsSearch(product);
                        prod.priority = count;
                        searchResult.Add(prod);
                    }
                }
                searchResult.Sort((v1, v2) => v2.priority - v1.priority);
                lbProducts.ItemsSource = null;
                lbProducts.ItemsSource = searchResult;
                SolidColorBrush brush = new SolidColorBrush(currentAccentColorHex);
                progress.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
コード例 #2
0
ファイル: SearchPage.xaml.cs プロジェクト: kimran777/wpapp
        private void search(string searchWord)
        {
            searchWord.Replace(',', ' ');

            searchWords = searchWord.Split(separator, StringSplitOptions.RemoveEmptyEntries).ToList();

            if (!string.IsNullOrEmpty(searchWord) && searchWord != defaultSearchString)
            {
                progress.Visibility = System.Windows.Visibility.Visible;
                searchResult.Clear();
                foreach (var product in products)
                {
                    int count = 0;
                    foreach (string str in searchWords)
                    {
                        if (product.productName.ToUpper().Contains(str))
                        {
                            count++;
                        }
                    }
                    if (count > 0)
                    {
                        CProductsSearch prod = new CProductsSearch(product);
                        prod.priority = count;
                        searchResult.Add(prod);
                    }

                }
                searchResult.Sort((v1, v2) => v2.priority - v1.priority);
                lbProducts.ItemsSource = null;
                lbProducts.ItemsSource = searchResult;
                SolidColorBrush brush = new SolidColorBrush(currentAccentColorHex);
                progress.Visibility = System.Windows.Visibility.Collapsed;
            }
        }