Example #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();
                }
            }
        }
Example #2
0
        private static List <Page> Pages2Download(String bookID, List <Page> serverPageList)
        {
            // Compare pages on server and device and download only that are different
            List <Page> differentPageList = new List <Page>();
            List <Page> devicePageList    = BooksOnDeviceAccessor.GetPages(bookID);

            if (devicePageList == null || devicePageList.Count == 0)
            {
                differentPageList = serverPageList;
            }
            else
            {
                foreach (Page serverPage in serverPageList)
                {
                    var item = devicePageList.Where(i => i.ID == serverPage.ID).FirstOrDefault();
                    if (item != null)
                    {
                        if (item.Version != serverPage.Version)
                        {
                            differentPageList.Add(serverPage);
                        }
                    }
                    else
                    {
                        differentPageList.Add(serverPage);
                    }
                }
                RemovePages(serverPageList, devicePageList);
            }

            return(differentPageList);
        }
Example #3
0
        private static void PushNotesWork(Book book)
        {
            List <Note> noteList = BooksOnDeviceAccessor.GetAllNotes(book.ID);

            if (noteList != null && noteList.Count > 0)
            {
                if (String.IsNullOrEmpty(URL.MultipleNoteURL))
                {
                    foreach (var note in noteList)
                    {
                        SaveMyStuff.SetMyNote(note);

                        // Remove note marked as Removed
                        if (note.Removed)
                        {
                            BooksOnDeviceAccessor.RemoveNote(note.BookID, note.PageID);
                        }
                    }
                }
                else
                {
                    SaveMyStuff.SetMyNotes(noteList);

                    // Remove notes that are marked as Removed
                    foreach (var note in noteList)
                    {
                        if (note.Removed)
                        {
                            BooksOnDeviceAccessor.RemoveNote(note.BookID, note.NoteID);
                        }
                    }
                }
            }
        }
Example #4
0
        private static void PullAnnotationsWork(Book book)
        {
            List <Annotation> sAnnotations = SaveMyStuff.GetMyAnnotations(book.ID);

            if (sAnnotations != null && sAnnotations.Count > 0)
            {
                foreach (var sAnn in sAnnotations)
                {
                    Annotation dAnn = BooksOnDeviceAccessor.GetAnnotation(book.ID, sAnn.PageID);
                    if (dAnn == null)
                    {
                        // This is a new note from the server
                        BooksOnDeviceAccessor.AddAnnotation(sAnn);
                    }
                    else
                    {
                        if (dAnn.ModifiedUtc <= sAnn.ModifiedUtc)
                        {
                            if (sAnn.Removed)
                            {
                                // Remove annotation if the annotation on the cloud has 'Removed' checked
                                BooksOnDeviceAccessor.RemoveAnnotation(dAnn.BookID, dAnn.PageID);
                            }
                            else
                            {
                                BooksOnDeviceAccessor.UpdateAnnotation(sAnn);
                            }
                        }
                    }
                }
            }
        }
        private void UpdateBookStatus()
        {
            // Update new status
            book.New = false;

            BooksOnDeviceAccessor.UpdateBook(book);
        }
Example #6
0
        private void ShowNoteCollections()
        {
            try
            {
                List <Page> pageList = new List <Page>();

                List <Note> noteList = BooksOnDeviceAccessor.GetNotes(book.ID);
                if (noteList != null)
                {
                    pageList = new List <Page>();

                    foreach (Note note in noteList)
                    {
                        Page page = BooksOnDeviceAccessor.GetPage(note.BookID, note.PageID);
                        pageList.Add(page);
                    }
                }

                ShowCollectionView(new NSString("NoteCell"), pageList);
            }
            catch (Exception ex)
            {
                Logger.WriteLineDebugging("PageViewController - ShowNoteCollections: {0}", ex.ToString());
            }
        }
        public void RetrieveBooks()
        {
            List <Book> bookList = BooksOnDeviceAccessor.GetBooks();

            if (bookList == null || bookList.Count == 0)
            {
                if (BookUpdater.Books2Download == null)
                {
                    UpdateStatusLabel();
                }
                else
                {
                    ShowHideStatusLabel(false);

                    LoadCollectionView(bookList);
                }
            }
            else
            {
                bookList.RemoveAll(x => String.IsNullOrEmpty(x.Title) && x.PageCount == 0 && String.IsNullOrEmpty(x.Description) && x.ChapterCount == 0);

                // Hide statusLabel
                ShowHideStatusLabel(false);

                // Load collectionView
                LoadCollectionView(bookList);
            }
        }
Example #8
0
        void HandleDidRenderPageViewEvent(PSPDFPageView pageView)
        {
            Page page = BooksOnDeviceAccessor.GetPage(book.ID, (int)pageView.Page + 1);

            if (page != null)
            {
                // Set current page id for Dashboard menu button action
                Settings.CurrentPageID = page.ID;

                // Clear the pageview
                foreach (UIView subview in pageView)
                {
                    if (subview.Tag == -1)
                    {
                        subview.RemoveFromSuperview();
                        break;
                    }
                }

                // bookmark
                Bookmark bookmark = BooksOnDeviceAccessor.GetBookmark(book.ID, page.ID);

                // bookmarkButton
                UIButton bookmarkButton = GenerateBookmarkButton(pageView, page, bookmark);
                bookmarkButton.Tag = -1;
                pageView.AddSubview(bookmarkButton);

                UpdateBookmarkLocation(bookmarkButton);
            }
        }
        private void RemovePendingBooks()
        {
            // Remove pending books
            List <Book> removeList = null;
            List <Book> bookList   = BooksOnDeviceAccessor.GetBooks();

            if (bookList != null)
            {
                foreach (Book b in bookList)
                {
                    if (b.Status == Book.BookStatus.PENDING2DOWNLOAD || b.Status == Book.BookStatus.PENDING2UPDATE)
                    {
                        if (removeList == null)
                        {
                            removeList = new List <Book>();
                        }

                        removeList.Add(b);
                    }
                }

                if (removeList != null)
                {
                    foreach (Book b in removeList)
                    {
                        BooksOnDeviceAccessor.RemoveBook(b.ID);
                    }
                }
            }
        }
Example #10
0
        private void ShowAnnotationCollections()
        {
            try
            {
                List <Page> pageList = new List <Page>();

                for (int i = 0; i < (int)this.Document.PageCount; i++)
                {
                    Page page = BooksOnDeviceAccessor.GetPage(book.ID, (nint)i + 1);
                    if (page != null)
                    {
                        Annotation annotation = AnnotationsDataAccessor.GetAnnotation(book.ID, page.ID);
                        if (annotation != null)
                        {
                            pageList.Add(page);
                        }
                    }
                }

                ShowCollectionView(new NSString("AnnotationCell"), pageList);
            }
            catch (Exception ex)
            {
                Logger.WriteLineDebugging("PageViewController - ShowAnnotationCollections: {0}", ex.ToString());
            }
        }
Example #11
0
        private void ShowTOCCollections()
        {
            try
            {
                List <Page> pageList = new List <Page>();

                List <Chapter> chapterList = BooksOnDeviceAccessor.GetChapters(book.ID);
                if (chapterList != null)
                {
                    pageList = new List <Page>();

                    foreach (Chapter chapter in chapterList)
                    {
                        Page page = BooksOnDeviceAccessor.GetPage(book.ID, chapter.FirstPageID);
                        if (page != null)
                        {
                            pageList.Add(page);
                        }
                    }
                }

                ShowCollectionView(new NSString("TOCCell"), pageList);
            }
            catch (Exception ex)
            {
                Logger.WriteLineDebugging("PageViewController - ShowTOCCollections: {0}", ex.ToString());
            }
        }
Example #12
0
        public NoteDataSource(Book book, UICollectionView collectionView, String cellID)
        {
            this.cellID         = new NSString(cellID);
            this.bookID         = book.ID;
            this.collectionView = collectionView;

            // dictionary
            dictionary = new Dictionary <Chapter, List <Note> > ();

            List <Page> pageList = BooksOnDeviceAccessor.GetPages(bookID);

            if (pageList != null)
            {
                foreach (var page in pageList)
                {
                    List <Note> notesOnPage = BooksOnDeviceAccessor.GetNotes(bookID, page.ID);
                    if (notesOnPage != null && notesOnPage.Count > 0)
                    {
                        // chapter
                        Chapter chapter = BooksOnDeviceAccessor.GetChapter(bookID, page.ChapterID);
                        if (chapter != null)
                        {
                            if (!dictionary.ContainsKey(chapter))
                            {
                                dictionary.Add(chapter, new List <Note> ());
                            }
                        }
                    }
                }
            }
        }
Example #13
0
        private static void PullBookmarksWork(Book book)
        {
            List <Bookmark> sBookmarks = SaveMyStuff.GetMyBookmarks(book.ID);

            if (sBookmarks != null && sBookmarks.Count > 0)
            {
                foreach (var sBookmark in sBookmarks)
                {
                    Bookmark dBookmark = BooksOnDeviceAccessor.GetBookmark(book.ID, sBookmark.PageID);
                    if (dBookmark == null)
                    {
                        // This is a new bookmark from the server
                        BooksOnDeviceAccessor.AddBookmark(sBookmark);
                    }
                    else
                    {
                        if (dBookmark.ModifiedUtc <= sBookmark.ModifiedUtc)
                        {
                            if (sBookmark.Removed)
                            {
                                // Remove bookmark if the bookmark on the cloud has 'Removed' checked
                                BooksOnDeviceAccessor.RemoveBookmark(dBookmark.BookID, dBookmark.PageID);
                            }
                            else
                            {
                                BooksOnDeviceAccessor.UpdateBookmark(sBookmark);
                            }
                        }
                    }
                }
            }
        }
Example #14
0
        void HandleUpdateAvailableBadgeEvent(object sender, EventArgs e)
        {
            try
            {
                List <Book> sBooks = BooksOnServerAccessor.GetBooks();
                List <Book> dBooks = BooksOnDeviceAccessor.GetBooks();

                int count = 0;
                if (sBooks != null && dBooks != null)
                {
                    HashSet <String> dIDs = new HashSet <String>(dBooks.Select(d => d.ID));
                    var results           = sBooks.Where(s => !dIDs.Contains(s.ID)).Where(s => !s.Viewed).ToList();
                    if (results != null)
                    {
                        count = results.Count;
                    }
                }
                else if (sBooks != null)
                {
                    count = sBooks.Where(s => !s.Viewed).ToList().Count;
                }

                UpdateBadge(3, count);
            }
            catch (Exception ex)
            {
                Logger.WriteLineDebugging("eBriefingViewController - HandleUpdateAvailableBadgeEvent: {0}", ex.ToString());
            }
        }
Example #15
0
        public static void SaveBookmark(Book book, String pageID, String text)
        {
            Bookmark bookmark = BooksOnDeviceAccessor.GetBookmark(book.ID, pageID);

            if (bookmark == null)
            {
                if (!String.IsNullOrEmpty(text))
                {
                    bookmark = GenerateBookmarkObj(book, pageID, text);
                    Add(bookmark);
                }
            }
            else
            {
                if (String.IsNullOrEmpty(text))
                {
                    Remove(book.ID, pageID);
                }
                else
                {
                    bookmark = GenerateBookmarkObj(book, pageID, text);
                    Update(bookmark);
                }
            }

            BooksOnDeviceAccessor.UpdateUserModifiedDate(book);
        }
Example #16
0
        public static void RemoveBookInCache(Book book)
        {
            // Remove page images from the file system
            List <Page> pageList = BooksOnDeviceAccessor.GetPages(book.ID);

            if (pageList != null)
            {
                foreach (Page page in pageList)
                {
                    DownloadedFilesCache.RemoveFile(page.URL);
                }
            }

            // Remove chapter images from the file system
            List <Chapter> chapterList = BooksOnDeviceAccessor.GetChapters(book.ID);

            if (chapterList != null)
            {
                foreach (Chapter chapter in chapterList)
                {
                    DownloadedFilesCache.RemoveFile(chapter.SmallImageURL);
                    DownloadedFilesCache.RemoveFile(chapter.LargeImageURL);
                }
            }

            // Remove book images from the file system
            DownloadedFilesCache.RemoveFile(book.SmallImageURL);
            DownloadedFilesCache.RemoveFile(book.LargeImageURL);
        }
            public BookSearchDisplayDelegate(PopoverSearchController parent)
            {
                this.parent = parent;

                myBooks        = BooksOnDeviceAccessor.GetBooks();
                availableBooks = BooksOnServerAccessor.GetBooks();
            }
Example #18
0
 public void AddAnnotations()
 {
     try
     {
         for (nint i = 0; i < (nint)this.Document.PageCount; i++)
         {
             Page page = BooksOnDeviceAccessor.GetPage(book.ID, i + 1);
             if (page != null)
             {
                 Annotation annotation = BooksOnDeviceAccessor.GetAnnotation(book.ID, page.ID);
                 if (annotation != null)
                 {
                     Dictionary <String, PSPDFInkAnnotation> dictionary = AnnotationsDataAccessor.GenerateAnnDictionary((nuint)i, annotation);
                     if (dictionary != null)
                     {
                         List <PSPDFAnnotation> annList = new List <PSPDFAnnotation>();
                         foreach (KeyValuePair <String, PSPDFInkAnnotation> item in dictionary)
                         {
                             annList.Add(item.Value);
                         }
                         this.Document.AddAnnotations(annList.ToArray());
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Logger.WriteLineDebugging("CustomPSPDFViewController - AddAnnotations: {0}", ex.ToString());
     }
 }
Example #19
0
        private void SaveAnnotation(nuint pageNumber)
        {
            Page page = BooksOnDeviceAccessor.GetPage(book.ID, (nint)pageNumber + 1);

            if (page != null)
            {
                List <AnnotationItem> inkItems = GenerateParseItem(pageNumber, PSPDFAnnotationType.Ink);
                if (inkItems != null && inkItems.Count > 0)
                {
                    Annotation annotation = new Annotation();
                    annotation.BookID      = book.ID;
                    annotation.BookVersion = book.Version;
                    annotation.PageID      = page.ID;
                    annotation.ModifiedUtc = DateTime.UtcNow;
                    annotation.Items       = inkItems;

                    BooksOnDeviceAccessor.AddAnnotation(annotation);
                    BooksOnDeviceAccessor.UpdateUserModifiedDate(book);
                }
                else
                {
                    BooksOnDeviceAccessor.RemoveAnnotation(book.ID, page.ID);
                    BooksOnDeviceAccessor.UpdateUserModifiedDate(book);
                }
            }
        }
Example #20
0
        private static void SendMyNotes(List <Book> bookList)
        {
            if (cancelled)
            {
                SetSent(true);

                CheckSentDone();
            }
            else
            {
                if (Reachability.IsDefaultNetworkAvailable())
                {
                    SaveMyStuff.SetMyNoteEvent += HandleSetMyNoteEvent;

                    foreach (Book book in bookList)
                    {
                        List <Note> noteList = BooksOnDeviceAccessor.GetAllNotes(book.ID);
                        if (noteList != null && noteList.Count > 0)
                        {
                            for (Int32 i = 0; i < noteList.Count; i++)
                            {
                                bool lastItem = false;
                                if (i == noteList.Count - 1)
                                {
                                    lastItem = true;
                                }

                                if (noteList[i].Removed)
                                {
                                    SaveMyStuff.RemoveMyNote(noteList[i], lastItem);
                                }
                                else
                                {
                                    SaveMyStuff.SetMyNote(noteList[i], lastItem);
                                }
                            }
                        }
                        else
                        {
                            sentNotes = true;
                        }
                    }

                    // Remove notes that are marked as removed
                    foreach (Book book in bookList)
                    {
                        List <Note> noteList = BooksOnDeviceAccessor.GetRemovedNotes(book.ID);
                        if (noteList != null && noteList.Count > 0)
                        {
                            foreach (Note note in noteList)
                            {
                                BooksOnDeviceAccessor.RemoveNote(note.BookID, note.PageID);
                            }
                        }
                    }
                }
            }
        }
Example #21
0
        private static void SendMyAnnotations(List <Book> bookList)
        {
            if (cancelled)
            {
                SetSent(true);

                CheckSentDone();
            }
            else
            {
                if (Reachability.IsDefaultNetworkAvailable())
                {
                    SaveMyStuff.SetMyAnnotationEvent += HandleSetMyAnnotationEvent;

                    foreach (Book book in bookList)
                    {
                        List <Annotation> annotationList = BooksOnDeviceAccessor.GetAllAnnotations(book.ID);
                        if (annotationList != null && annotationList.Count > 0)
                        {
                            for (Int32 i = 0; i < annotationList.Count; i++)
                            {
                                bool lastItem = false;
                                if (i == annotationList.Count - 1)
                                {
                                    lastItem = true;
                                }

                                if (annotationList[i].Removed)
                                {
                                    SaveMyStuff.RemoveMyAnnotation(annotationList[i], lastItem);
                                }
                                else
                                {
                                    SaveMyStuff.SetMyAnnotation(annotationList[i], lastItem);
                                }
                            }
                        }
                        else
                        {
                            sentAnnotations = true;
                        }
                    }

                    // Remove annotation that are marked as removed
                    foreach (Book book in bookList)
                    {
                        List <Annotation> annotationList = BooksOnDeviceAccessor.GetRemovedAnnotations(book.ID);
                        if (annotationList != null && annotationList.Count > 0)
                        {
                            foreach (Annotation annotation in annotationList)
                            {
                                BooksOnDeviceAccessor.RemoveAnnotation(annotation.BookID, annotation.PageID);
                            }
                        }
                    }
                }
            }
        }
        void HandleGoToFirstEvent()
        {
            List <Page> pageList = BooksOnDeviceAccessor.GetPages(book.ID);

            if (pageList != null)
            {
                LoadPageViewController(pageList[0].ID);
            }
        }
Example #23
0
        private static List <Chapter> DownloadChaptersWork(String bookID, List <String> fileUrlsToDownload)
        {
            // If chapters are not downloaded yet or expired, download them again
            List <Chapter> chapterList = null;

            if (!BooksOnServerAccessor.HasChapters(bookID) || CurrentBook.Status == Book.BookStatus.UPDATING)
            {
                chapterList = eBriefingService.StartDownloadChapters(bookID);
                if (chapterList != null)
                {
                    BooksOnServerAccessor.SaveChapters(bookID, chapterList);
                }
            }
            else
            {
                // Or get them from the cache
                chapterList = BooksOnServerAccessor.GetChapters(bookID);
            }

            // Queue up cover images for the chapter only if the image version is different
            if (chapterList != null)
            {
                foreach (Chapter serverCh in chapterList)
                {
                    // Remove cover image if this is an update
                    bool download = false;
                    if (CurrentBook.Status == Book.BookStatus.UPDATING)
                    {
                        Chapter deviceCh = BooksOnDeviceAccessor.GetChapter(CurrentBook.ID, serverCh.ID);
                        if (deviceCh == null)
                        {
                            download = true;
                        }
                        else if (serverCh.ImageVersion != deviceCh.ImageVersion)
                        {
                            DownloadedFilesCache.RemoveFile(deviceCh.LargeImageURL);
                            DownloadedFilesCache.RemoveFile(deviceCh.SmallImageURL);

                            download = true;
                        }
                    }
                    else
                    {
                        download = true;
                    }

                    if (download)
                    {
                        fileUrlsToDownload.Add(serverCh.LargeImageURL);
                        fileUrlsToDownload.Add(serverCh.SmallImageURL);
                    }
                }
            }

            return(chapterList);
        }
Example #24
0
        async public static void Check4Update()
        {
            if (BooksOnDeviceAccessor.GetBooks() != null)
            {
                List <Book> bookList = await eBriefingService.Run(() => eBriefingService.StartDownloadBooks());

                if (bookList != null)
                {
                    BookUpdater.DoesBooksNeedUpdate(bookList);
                }
            }
        }
Example #25
0
        protected void HandleLongPress(UIGestureRecognizer sender)
        {
            if (sender.State == UIGestureRecognizerState.Began && !updateMenu)
            {
                bool isFavorite = BooksOnDeviceAccessor.IsFavorite(BookshelfBook.ID);

                if (ShowMenuEvent != null)
                {
                    ShowMenuEvent(this, isFavorite);
                }
            }
        }
        private void UpdateCollectionView(LibraryBookView bookView)
        {
            if (dataSource != null && dataSource.BookList != null && dataSource.BookList.Count > 0)
            {
                try
                {
                    bookView.RemoveFromSuperview();

                    Book book = bookView.LibraryBook.Copy();
                    book.Status = Book.BookStatus.PENDING2DOWNLOAD;

                    // Add the book to the device
                    BooksOnDeviceAccessor.AddBook(book);

                    // Start the download
                    BookUpdater.CheckBooks2Download();

                    // Update available badge
                    UpdateAvailableBadge();

                    // Remove from the list
                    List <Book> newBookList = new List <Book>(dataSource.BookList);
                    int         removeIdx   = dataSource.GetBookIndex(book.ID);
                    newBookList.RemoveAt(removeIdx);

                    collectionView.PerformBatchUpdates(delegate
                    {
                        foreach (Book b in dataSource.BookList)
                        {
                            if (b.ID != book.ID)
                            {
                                NSIndexPath fromIndexPath = dataSource.GetIndexPath(b.ID);
                                int toRow = newBookList.IndexOf(b);
                                if (fromIndexPath != null && fromIndexPath.Row >= 0 && toRow >= 0)
                                {
                                    NSIndexPath toIndexPath = NSIndexPath.FromRowSection(toRow, 0);
                                    collectionView.MoveItem(fromIndexPath, toIndexPath);
                                }
                            }
                        }
                    }, delegate
                    {
                        downloadAnimation = false;

                        RefreshTable();
                    });
                }
                catch (Exception ex)
                {
                    Logger.WriteLineDebugging("LibraryViewController - UpdateCollectionView: {0}", ex.ToString());
                }
            }
        }
Example #27
0
 void HandleDidShowPageViewEvent()
 {
     if (notePanel != null)
     {
         // Update notePanel
         Page page = BooksOnDeviceAccessor.GetPage(book.ID, (int)this.Page + 1);
         if (page != null)
         {
             notePanel.LoadNoteListView(page.ID);
         }
     }
 }
        async private void LoadPageViewController(String pageID)
        {
            try
            {
                LoadingView.Show("Loading", "Please wait while we're loading " + book.Title + "...", false);

                int           pageNumber = BooksOnDeviceAccessor.GetPage(book.ID, pageID).PageNumber;
                PSPDFDocument document   = await eBriefingService.Run(() => GenerateDocument());

                if (document == null)
                {
                    LoadingView.Hide();

                    AlertView.Show(StringRef.alert, "We're sorry, but we could not open the document.", StringRef.ok);
                }
                else
                {
                    PSPDFConfiguration configuration = PSPDFConfiguration.FromConfigurationBuilder(delegate(PSPDFConfigurationBuilder builder)
                    {
                        builder.CreateAnnotationMenuEnabled = builder.ShouldHideStatusBar = builder.ShouldCacheThumbnails = false;
                        builder.ShouldHideStatusBarWithHUD  = builder.AlwaysBouncePages = builder.SmartZoomEnabled = builder.DoublePageModeOnFirstPage
                                                                                                                         = builder.ShouldHideHUDOnPageChange = builder.ShouldHideNavigationBarWithHUD = true;
                        builder.HUDViewMode      = PSPDFHUDViewMode.Automatic;
                        builder.HUDViewAnimation = PSPDFHUDViewAnimation.Fade;
                        builder.ThumbnailBarMode = PSPDFThumbnailBarMode.None;
                        builder.RenderingMode    = PSPDFPageRenderingMode.Render;
                        builder.PageTransition   = PSPDFPageTransition.Curl;
                        builder.ShouldAskForAnnotationUsername = false;
                        builder.AllowBackgroundSaving          = false;
                        builder.OverrideClass(new Class(typeof(PSPDFHUDView)), new Class(typeof(CustomPSPDFHUDView)));
                        builder.OverrideClass(new Class(typeof(PSPDFViewControllerDelegate)), new Class(typeof(CustomPSPDFViewControllerDelegate)));
                        builder.OverrideClass(new Class(typeof(PSPDFBarButtonItem)), new Class(typeof(CustomPSPDFBarButtonItem)));
                    });

                    PageViewController pvc = new PageViewController(book, document, configuration);
                    pvc.Delegate = new CustomPSPDFViewControllerDelegate();
                    pvc.Page     = (nuint)pageNumber - 1;

                    pvc.AddAnnotations();

                    LoadingView.Hide();
                    this.NavigationController.PushViewController(pvc, true);
                }
            }
            catch (Exception ex)
            {
                LoadingView.Hide();

                Logger.WriteLineDebugging("DashboardViewController - LoadPageViewController: {0}", ex.ToString());
            }
        }
Example #29
0
        public static void RemoveBookFromDevice(Book book)
        {
            if (book != null)
            {
                if (book.Status == Book.BookStatus.DOWNLOADING || book.Status == Book.BookStatus.PENDING2DOWNLOAD)
                {
                    if (book.Status == Book.BookStatus.DOWNLOADING)
                    {
                        // Remove page images from the file system
                        List <Page> pageList = BooksOnServerAccessor.GetPages(book.ID);
                        if (pageList != null)
                        {
                            foreach (Page page in pageList)
                            {
                                DownloadedFilesCache.RemoveFile(page.URL);
                            }
                        }
                        BooksOnServerAccessor.RemovePages(book.ID);

                        // Remove chapter images from the file system
                        List <Chapter> chapterList = BooksOnServerAccessor.GetChapters(book.ID);
                        if (chapterList != null)
                        {
                            foreach (Chapter chapter in chapterList)
                            {
                                DownloadedFilesCache.RemoveFile(chapter.SmallImageURL);
                                DownloadedFilesCache.RemoveFile(chapter.LargeImageURL);
                            }
                        }
                        BooksOnServerAccessor.RemoveChapters(book.ID);
                    }

                    // Remove book images from the file system
                    DownloadedFilesCache.RemoveFile(book.SmallImageURL);
                    DownloadedFilesCache.RemoveFile(book.LargeImageURL);

                    BooksOnDeviceAccessor.RemoveBook(book.ID);

                    // Initialize CurrentBook
                    InitializeFailedURLs();
                }
                else if (book.Status == Book.BookStatus.PENDING2UPDATE || book.Status == Book.BookStatus.UPDATING)
                {
                    RemoveBookFromBooks2Update(book.ID);

                    BooksOnServerAccessor.RemovePages(book.ID);
                    BooksOnServerAccessor.RemoveChapters(book.ID);
                }
            }
        }
Example #30
0
 private static void RemoveBooks(String url, String id)
 {
     if (!String.IsNullOrEmpty(URL.ServerURL))
     {
         if (url != URL.ServerURL || id != Settings.UserID)
         {
             List <Book> bookList = BooksOnDeviceAccessor.GetBooks();
             if (bookList != null)
             {
                 BookRemover.RemoveBooks(bookList);
             }
         }
     }
 }