Пример #1
0
    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;
    }
Пример #2
0
    // Create a book from the filename to the ebook.
    private IEnumerator loadBookInternal(string bookFileName, BookPropertySet props)
    {
        setInformation("Loading");
        yield return(null);

        initializeTextures();

        setInformation("Loading.");
        yield return(null);

        // Try to load the book in a separate thread.
        loadingName = bookFileName;
        rx          = directRenderTexture.width;
        ry          = directRenderTexture.height;
        loading     = true;
        Thread t = new Thread(new ThreadStart(doLoading));

        t.Start();
        while (loading)
        {
            yield return(new WaitForSeconds(0.1f));

            print("Waiting");
        }

        setInformation("Loading..");
        yield return(null);

        // Retrieve the title and author settings.
        string title  = Marshal.PtrToStringAnsi(bookEngine.BEIGetTitle(bookHandle));;
        string author = Marshal.PtrToStringAnsi(bookEngine.BEIGetAuthors(bookHandle));

        Debug.Log("Author " + author + " title: " + title);

        // Retrieve the cover image. This involves render operations so
        // cannot take place in its own thread.
        retrieveCoverMaterial(frontCover);

        setInformation("Loading...");
        yield return(null);

        GetComponent <BookProperties> ().props = props;
        //bookProperties = props;
        // Change page to force initial page drawing.
        currentPage = props.currentPage;
//    changePage (currentPage);
//    pageTurnComplete ();

        fontSize = props.fontSize;
        yield return(updateFont());

        fontSize = bookEngine.BEIGetFontSize(bookHandle);

        bookLoaded = true;

        setInformation("");

        stateChanged();
    }
Пример #3
0
    IntPtr BookEngineInterface.BEIGetTitle(IntPtr handle)
    {
        IntPtr result = IntPtr.Zero;

        switch (format)
        {
        case BookFormat.coolreader:
            result = cri.BEIGetTitle(handle);
            break;

        case BookFormat.poppler:
            result = pop.BEIGetTitle(handle);
            break;
        }
        return(result);
    }