Tuesday, July 7, 2009

WPF Book Reader

Introduction

Why this project? There are so many e-book readers already available… but none of them suited my requirements. They unzip pages on the disk, or hang between pages, or do not manage the library, etc.

Background

I decided to use this project to experiment more on WPF, and its graphic capacity fits the needs and helps fulfill the missing functionalities. It's more an experiment than anything else; the solution is clean but not perfect.

Functionalities

The application (in my opinion) has to fulfill the following:

  • Manage the book library, by parsing a specified folder, displaying the cover pages.
  • Reading a book, placing the bookmark on a current page, and restoring it.
  • Saving all for further reading.
  • Being quick because of zipped content access, implement image cache management.
  • Once a book is open, display the pages inside and the folder structure.

BookReader1.jpg

Example: The main interface

BookReader2.jpg

Example: The options dialog

The Code

This project is very simple. As you can see in the class diagram below, it contains three forms and a few classes.

The Class Diagram

Click to enlarge image

The main class is Catalog. It holds a collection of IBooks (mapped to RarBook) which contains an IBookItem (mapped to RarPage). The catalog is in charge of parsing the book directory for all cbz or cbr files, and load/save itself (book name, bookmark, cover) in two separate binary files.

The loading algorithm is the following, and the main point is the usage of a thread to load the covers and parse the folder. The first load will be a bit long, but the generation of the covers will be threaded too. We will see the details later.


See full detail: http://www.codeproject.com/KB/WPF/Wpf_Book_Reader.aspx

No comments: