private void doLoading(object obp) { BookPropertySet bp = (BookPropertySet)obp; int rx = 1; int ry = 1; Debug.Log("Try to open : " + bp.filename); bookHandle = bookEngine.BEIDocViewCreate(bp.filename); bookEngine.BEILoadDocument(bookHandle, bp.filename, rx, ry); bp.title = Marshal.PtrToStringAnsi(bookEngine.BEIGetTitle(bookHandle)); if (bp.title == null) { bp.title = ""; } bp.author = Marshal.PtrToStringAnsi(bookEngine.BEIGetAuthors(bookHandle)); if (bp.author == null) { bp.author = "No author"; } if (bp.title == "") { bp.title = Path.GetFileNameWithoutExtension(bp.filename); } Debug.Log("Found book " + bp.title + " " + bp.author + " " + bp.filename); loading = false; // Each book is given a colour to distinguish it. Similar books (same author) get similar colours. bp.colour[0] = 0.75f + 0.25f * (float)bp.filename.GetHashCode() / Int32.MaxValue; bp.colour[1] = 0.75f + 0.25f * (float)bp.title.GetHashCode() / Int32.MaxValue; bp.colour[2] = 0.75f + 0.25f * (float)bp.author.GetHashCode() / Int32.MaxValue; }
private void doLoading() { bookHandle = bookEngine.BEIDocViewCreate(loadingName); Debug.Log("Book Handle" + bookHandle); bookEngine.BEILoadDocument(bookHandle, loadingName, rx, ry); bookEngine.BEIPrepareCover(bookHandle, rx, ry); loading = false; }
IntPtr BookEngineInterface.BEIDocViewCreate(string fname) { BookFormat newFormat = getFormatFromName(fname); if ((newFormat != format) || (handle == IntPtr.Zero)) { if (handle != IntPtr.Zero) { switch (format) { // TODO case BookFormat.coolreader: // cri.BEIReleaseHandle (handle); break; case BookFormat.poppler: // pop.BEIReleaseHandle (handle); break; } } switch (newFormat) { case BookFormat.coolreader: // Create a book with a default font size. handle = cri.BEIDocViewCreate(fname); Debug.Log("CRI Handle " + handle); break; case BookFormat.poppler: // Create a book with a default font size. handle = pop.BEIDocViewCreate(fname); Debug.Log("Poppler Handle " + handle); break; } format = newFormat; } return(handle); }