public NodeCategoryViewModel(string name, IEnumerable <NodeSearchElementViewModel> entries, IEnumerable <NodeCategoryViewModel> subs)
        {
            ClickedCommand = new DelegateCommand(Expand);

            Name          = name;
            this.entries  = new ObservableCollection <NodeSearchElementViewModel>(entries);
            subCategories = new ObservableCollection <NodeCategoryViewModel>(subs);

            foreach (var category in SubCategories)
            {
                category.PropertyChanged += CategoryOnPropertyChanged;
            }

            Entries.CollectionChanged       += OnCollectionChanged;
            SubCategories.CollectionChanged += OnCollectionChanged;
            SubCategories.CollectionChanged += SubCategoriesOnCollectionChanged;

            items = new ObservableCollection <ISearchEntryViewModel>(
                Entries.Cast <ISearchEntryViewModel>().Concat(SubCategories)
                .OrderBy(x => x.Name));

            Items.CollectionChanged += ItemsOnCollectionChanged;

            foreach (var item in Items)
            {
                item.PropertyChanged += ItemOnPropertyChanged;
            }

            Visibility = true;
            IsExpanded = false;
        }
 private void StartDownload()
 {
     foreach (var downloadItems in Entries.Cast <DownloadList>().Where(downloadItems => downloadItems.Entries.Count > 0))
     {
         var items = downloadItems;
         Task.Factory.StartNew(items.Download);
     }
 }
        private void SyncItems()
        {
            Items.CollectionChanged -= ItemsOnCollectionChanged;

            foreach (var item in items)
            {
                item.PropertyChanged -= ItemOnPropertyChanged;
            }

            items = new ObservableCollection <ISearchEntryViewModel>(
                Entries.Cast <ISearchEntryViewModel>().Concat(SubCategories)
                .OrderBy(x => x.Name));

            Items.CollectionChanged += ItemsOnCollectionChanged;

            foreach (var item in items)
            {
                item.PropertyChanged += ItemOnPropertyChanged;
            }
        }
Exemple #4
0
 /// <summary>
 /// Returns an enumerator that iterates through the collection.
 /// </summary>
 /// <returns>
 /// A <see cref="T:System.Collections.Generic.IEnumerator`1"/> that can be used to iterate through the collection.
 /// </returns>
 /// <filterpriority>1</filterpriority>
 IEnumerator <IAction> IEnumerable <IAction> .GetEnumerator()
 {
     return(Entries.Cast <IAction>().GetEnumerator());
 }
Exemple #5
0
 public List <File> GetFiles()
 {
     return(Entries.Cast <File>().ToList());
 }