예제 #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //there seems to be a bug in the NavigateToAction
            //because the parameter is not set or if it is,
            //it doesn't take bindings very nicely.
            //This is the workaround.
            Book = (e.Parameter as ItemClickEventArgs).ClickedItem as EReaderDocument;
            tocList.ItemsSource = Book.Chapters ?? null;

            //construct URI
            var uri = Book.Document.ConstructApplicationUriFromStorageFile();

            //set the datacontext before we load the book.
            BookInfoPanel.DataContext = Book;

            //make a new uri for loading into webview
            var newUri = DocumentViewer.BuildLocalStreamUri(Book.Title, uri.AbsolutePath);

            DocumentViewer.NavigateToLocalStreamUri(newUri, new EReader.Common.StreamUriResolver());

            //register events.
            DocumentViewer.NavigationStarting += DocumentViewer_NavigationStarting;
            DocumentViewer.LoadCompleted      += DocumentViewer_LoadCompleted;
            DocumentViewer.ScriptNotify       += DocumentViewer_ScriptNotify;

            //register timer
            saveReadingProgress = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(2)
            };
            saveReadingProgress.Tick += SaveReadingProgress_Tick;

            //initiate library service
            LibraryService = new EBookLibraryService(new KeyValueStoreDatabaseService());
            base.OnNavigatedTo(e);
        }
예제 #2
0
 public async Task UpdateBook(EReaderDocument book)
 {
     await DatabaseService.UpdateRecordAsync("Ebooks", book.Title + book.Author, book);
 }
예제 #3
0
 public async Task InsertBook(EReaderDocument document)
 {
     await DatabaseService.InsertRecord("Ebooks", document.Title + document.Author, document);
 }