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); } } } } }; }
public void Remove() { //**************************************** var MySeed = Environment.TickCount; var MyRandom = new Random(MySeed); var MyDictionary = new SortedList <int, int>(1024); //**************************************** for (var Index = 0; Index < 1024; Index++) { int Key, Value; do { Key = MyRandom.Next(); } while (MyDictionary.ContainsKey(Key)); Value = MyRandom.Next(); MyDictionary.Add(Key, Value); } var MyRecords = new ObservableSortedList <int, int>(MyDictionary); //**************************************** for (var Index = 0; Index < 512; Index++) { var InnerIndex = MyRandom.Next(MyRecords.Count); var Key = MyRecords.Keys[InnerIndex]; Assert.IsTrue(MyRecords.Remove(Key)); Assert.IsTrue(MyDictionary.Remove(Key)); } //**************************************** Assert.AreEqual(512, MyRecords.Count, "Count incorrect. Bad Seed was {0}", MySeed); CollectionAssert.AreEquivalent(MyDictionary, MyRecords, "Collections don't match. Bad Seed was {0}", MySeed); foreach (var MyPair in MyDictionary) { Assert.IsTrue(MyRecords.TryGetValue(MyPair.Key, out var Value)); Assert.AreEqual(MyPair.Value, Value); } Thread.Sleep(1); }
private void HandleMemorizedTapped() { var verse = Front.Data; verse.Memorized = !verse.Memorized; if (verse.Memorized) { verse.Category = Category.Review; Front.ImageView.Image = MemorizedImage; Back.ImageView.Image = MemorizedImage; if (Tour.Instance.Step == 7) { new UIAlertView("Nice work!", "To exit, swipe right. You should periodically review your memorized verses by tapping the \"Review\" button in the memorization tab.", null, "Okay", null).Show(); Tour.Instance.StepCompleted(7); } AppDelegate.Current.Database.UpdateVerse(verse); LocalyticsSession.Shared.TagEvent("Verse Memorized"); } else { if (verse.Category == Category.Review) { verse.Category = Category.Queue; AppDelegate.Current.Database.UpdateVerse(verse); data.Remove(verse); } Front.ImageView.Image = NotMemorizedImage; Back.ImageView.Image = NotMemorizedImage; } VersesTableViewController.Current.Verses.Remove(verse); VersesTableViewController.Current.Verses.Add(verse); }
void MoveVerseToCategory(Category category) { if (Tour.Instance.Step == 4) { Tour.Instance.StepCompleted(4); } foreach (var verse in selected) { if (verse.Category != category) { verse.Category = category; if (category == Category.Review) { verse.Memorized = true; } if (category != Category.Review && verse.Memorized == true) { verse.Memorized = false; } AppDelegate.Current.Database.UpdateVerse(verse); data.Remove(verse); } } selected.RemoveAll(x => x == x); if (data.Count == 0) { tableViewController.TableView.Source = new MemorizationDayOfWeekSource(tableViewController, data); } tableViewController.TableView.ReloadData(); }
public void RemoveVerse(Verse verse) { Verses.Remove(verse); AppDelegate.Current.Database.RemoveVerse(verse); }
public void DelItem(PoeItem item) { ItemsList.Remove(item); OnPropertyChanged("ItemCountDisplay"); }
/// <summary> /// Creates a list of incidents types to be displayed to the user. /// </summary> /// <param name="searchText"> /// An optional search parameter. /// If left blank, all incident types are returned. /// If specified, both the incident type name and any associtated keywords are matched.</param> /// <returns>A list of incident types.</returns> internal void BuildIncidentTypesList(string searchText = "") { //first search through the filtered list and remove any incident types that don't have a matching name or keyword List <IncidentType> toDelete = new List <IncidentType>(); foreach (IncidentType type in IncidentTypes) { bool matching = false; if (type.Name.ToUpper().Contains(searchText.ToUpper())) { matching = true; } foreach (string keyword in type.Keywords) { if (keyword.ToUpper().Contains(searchText.ToUpper())) { matching = true; } } if (!matching) { toDelete.Add(type); } } foreach (IncidentType type in toDelete) { filteredIncidentTypes.Remove(type); } //then search through the full list and add any incident types that DO have a matching name or keyword List <IncidentType> toAdd = new List <IncidentType>(); foreach (IncidentType type in fullList) { bool matching = false; if (type.Name.ToUpper().Contains(searchText.ToUpper())) { matching = true; } foreach (string keyword in type.Keywords) { if (keyword.ToUpper().Contains(searchText.ToUpper())) { matching = true; } } if (matching) { toAdd.Add(type); } } foreach (IncidentType type in toAdd) { if (!filteredIncidentTypes.Contains(type)) { filteredIncidentTypes.Add(type); } } }