コード例 #1
0
        private async void InitData()
        {
            EReaderDocuments = new ObservableCollection <EReaderDocument>();
            EBookLibrary     = new EBookLibraryService(new KeyValueStoreDatabaseService());
            foreach (var file in await EBookLibrary.RetrieveBooks())
            {
                file.Document = await StorageFile.GetFileFromPathAsync(file.FilePath);

                EReaderDocuments.Add(file);
            }
        }
コード例 #2
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);
        }