Exemplo n.º 1
0
        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();
                }
            }
        }
Exemplo n.º 2
0
        public static void DownloadFinished()
        {
            InProgress = false;

            if (Books2Download != null)
            {
                Books2Download.Clear();
                Books2Download = null;
            }
        }
Exemplo n.º 3
0
 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);
         }
     }
 }
Exemplo n.º 4
0
        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);
                }
            }
        }
Exemplo n.º 5
0
 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));
         }
     }
 }