public static void CheckBooks2Download() { bool added = false; List <Book> bookList = BooksOnDeviceAccessor.GetBooks(); if (bookList != null) { foreach (Book book in bookList) { if (book.Status == Book.BookStatus.DOWNLOADING || book.Status == Book.BookStatus.PENDING2DOWNLOAD) { if (Books2Download == null) { Books2Download = new List <Book>(); } // Do not add if Books2Download already has it if (!Books2Download.Contains(book)) { added = true; Books2Download.Add(book); } } } } if (added) { if (NewBookAddedEvent != null) { NewBookAddedEvent(); } } }
public static void DownloadFinished() { InProgress = false; if (Books2Download != null) { Books2Download.Clear(); Books2Download = null; } }
public static void Dequeue(String bookID) { if (Books2Download != null && Books2Download.Count > 0) { var index = Books2Download.IndexOf(Books2Download.Where(i => i.ID == bookID).FirstOrDefault()); if (index >= 0) { Books2Download.RemoveAt(index); } } }
public static void Enqueue(List <Book> bookList) { if (Books2Download == null) { Books2Download = new List <Book>(); } if (bookList != null) { foreach (Book book in bookList) { Books2Download.Add(book); } } }
private static void SortBooks() { if (Settings.SortBy == StringRef.ByName) { if (Settings.SortAscending) { Books2Download.Sort((x, y) => x.Title.CompareTo(y.Title)); } else { Books2Download.Sort((x, y) => y.Title.CompareTo(x.Title)); } } else if (Settings.SortBy == StringRef.ByDateAdded) { if (Settings.SortAscending) { Books2Download.Sort((x, y) => x.ServerAddedDate.CompareTo(y.ServerAddedDate)); } else { Books2Download.Sort((x, y) => y.ServerAddedDate.CompareTo(x.ServerAddedDate)); } } else { if (Settings.SortAscending) { Books2Download.Sort((x, y) => x.ServerModifiedDate.CompareTo(y.ServerModifiedDate)); } else { Books2Download.Sort((x, y) => y.ServerModifiedDate.CompareTo(x.ServerModifiedDate)); } } }