예제 #1
0
        public MemorizationViewController() : base("Memorization")
        {
            verses = VersesTableViewController.Current.Verses;
            verses.CollectionChanged += delegate(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) {
                if (tableView != null)
                {
                    var newItems = e.NewItems;
                    var oldItems = e.OldItems;

                    if (newItems != null)
                    {
                        foreach (Verse verse in newItems)
                        {
                            if (verse.Category == categoryToFilter)
                            {
                                filteredVerses.Add(verse);
                                Console.WriteLine(verse.Title);
                            }
                        }
                    }

                    if (oldItems != null)
                    {
                        foreach (Verse verse in oldItems)
                        {
                            if (filteredVerses.Any(item => item.Id == verse.Id))
                            {
                                filteredVerses.Remove(verse);
                                Console.WriteLine(verse.Title);
                            }
                        }
                    }
                }
            };
        }