Exemplo n.º 1
0
 private void FilterItems()
 {
     if (string.IsNullOrEmpty(filterVideoKey))
     {
         IsAllItems = false;
         if (backupItems.Count > 0)
         {
             ChannelItems.Clear();
             backupItems.ForEach(x => ChannelItems.Add(x));
             ChannelItemsCount = ChannelItemsCollectionView.Cast <IVideoItem>().Count();
         }
         else
         {
             ChannelItemsCollectionView.Filter = FilterVideoByTitle;
             ChannelItemsCount = ChannelItemsCollectionView.Cast <IVideoItem>().Count();
         }
     }
     else
     {
         if (IsAllItems)
         {
             if (filterVideoKey.Length < 2)
             {
                 return;
             }
             if (backupItems.Count == 0)
             {
                 backupItems.Clear();
                 ChannelItems.ForEach(x => backupItems.Add(x));
             }
             string        cleared      = Regex.Replace(filterVideoKey, @"\s+", " ");
             List <string> searchFields =
                 cleared.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x.RemoveSpecialCharacters())).ToList();
             if (searchFields.Count <= 0)
             {
                 return;
             }
             List <VideoItemPOCO> res = db.GetAllItemsAsync(searchFields).Result;
             ChannelItems.Clear();
             res.ForEach(x => ChannelItems.Add(VideoItemFactory.CreateVideoItem(x, SiteType.YouTube, true)));
             ChannelItemsCollectionView.Filter = null;
             ChannelItemsCount = ChannelItemsCollectionView.Cast <IVideoItem>().Count();
         }
         else
         {
             if (backupItems.Count > 0)
             {
                 ChannelItems.Clear();
                 backupItems.ForEach(x => ChannelItems.Add(x));
             }
             ChannelItemsCollectionView.Filter = FilterVideoByTitle;
             ChannelItemsCount = ChannelItemsCollectionView.Cast <IVideoItem>().Count();
         }
     }
 }
 public void RefreshView(string field)
 {
     ChannelItemsCollectionView.SortDescriptions.Clear();
     ChannelItemsCollectionView.SortDescriptions.Add(new SortDescription(field, ListSortDirection.Descending));
     ChannelItemsCollectionView.Refresh();
 }