GetBookInfos() public method

public GetBookInfos ( ) : IEnumerable
return IEnumerable
 /// <summary>
 ///
 /// </summary>
 /// <returns>True if the collection should be shown</returns>
 private bool LoadOneCollection(BookCollection collection, FlowLayoutPanel flowLayoutPanel)
 {
     collection.CollectionChanged += OnCollectionChanged;
     bool loadedAtLeastOneBook = false;
     foreach (var bookInfo in collection.GetBookInfos())
     {
         try
         {
             if (!bookInfo.IsExperimental || Settings.Default.ShowExperimentalBooks)
             {
                 loadedAtLeastOneBook = true;
                 AddOneBook(bookInfo, flowLayoutPanel, collection);
             }
         }
         catch (Exception error)
         {
             ErrorReport.NotifyUserOfProblem(error, "Could not load the book at " + bookInfo.FolderPath);
         }
     }
     if (collection.ContainsDownloadedBooks)
     {
         _downloadedBookCollection = collection;
         collection.FolderContentChanged += DownLoadedBooksChanged;
         collection.WatchDirectory(); // In case another instance downloads a book.
         var bloomLibrayLink = new LinkLabel()
         {
             Text =
                 LocalizationManager.GetString("CollectionTab.BloomLibraryLinkLabel",
                                                         "Get more source books at BloomLibrary.org",
                                                         "Shown at the bottom of the list of books. User can click on it and it will attempt to open a browser to show the Bloom Library"),
             Width = 400,
             Margin = new Padding(17, 0, 0, 0),
             LinkColor = Palette.TextAgainstDarkBackground
         };
         bloomLibrayLink.Click += new EventHandler(OnBloomLibrary_Click);
         flowLayoutPanel.Controls.Add(bloomLibrayLink);
         return true;
     }
     return loadedAtLeastOneBook;
 }
Example #2
0
        /// <summary>
        /// used when this book is a "master"/"folio" book that is used to bring together a number of other books in the collection
        /// </summary>
        /// <param name="printingDom"></param>
        /// <param name="currentBookCollection"></param>
        /// <param name="bookServer"></param>
        private void AddChildBookContentsToFolio(HtmlDom printingDom, BookCollection currentBookCollection, BookServer bookServer)
        {
            XmlNode currentLastContentPage = GetLastPageForInsertingNewContent(printingDom);

            //currently we have no way of filtering them, we just take them all
            foreach (var bookInfo in currentBookCollection.GetBookInfos())
            {
                if (bookInfo.IsFolio)
                    continue;
                var childBook =bookServer.GetBookFromBookInfo(bookInfo);

                //this will set the class bloom-content1 on the correct language
                //this happens anyhow if the page was ever looked at in the Edti Tab
                //But if we are testing a collection's folio pdf'ing ability on a newly-generated
                //SHRP collection, and we don't do this, we see lots of sample text because every
                //bloom-editable has "bloom-content1", even the "Z" language ones.
                childBook.UpdateEditableAreasOfElement(childBook.OurHtmlDom);

                //add links to the template css needed by the children.

                HtmlDom.AddStylesheetFromAnotherBook(childBook.OurHtmlDom, printingDom);
                printingDom.SortStyleSheetLinks();

                foreach (XmlElement pageDiv in childBook.OurHtmlDom.RawDom.SafeSelectNodes("/html/body//div[contains(@class, 'bloom-page') and not(contains(@class,'bloom-frontMatter')) and not(contains(@class,'bloom-backMatter'))]"))
                {
                    XmlElement importedPage = (XmlElement) printingDom.RawDom.ImportNode(pageDiv, true);
                    currentLastContentPage.ParentNode.InsertAfter(importedPage, currentLastContentPage);
                    currentLastContentPage = importedPage;

                    foreach(XmlElement img in HtmlDom.SelectChildImgAndBackgroundImageElements(importedPage))
                    {
                        var bookFolderName = Path.GetFileName(bookInfo.FolderPath);
                        var path = HtmlDom.GetImageElementUrl(img);
                        var pathRelativeToFolioFolder = ".../" + bookFolderName + "/" + path.NotEncoded;
                        //NB: URLEncode would replace spaces with '+', which is ok in the parameter section, but not the URL
                        //So we are using UrlPathEncode

                        HtmlDom.SetImageElementUrl(new ElementProxy(img), UrlPathString.CreateFromUnencodedString(pathRelativeToFolioFolder));

                    }
                }
            }
        }
Example #3
0
        private bool LoadOneCollection(BookCollection collection, FlowLayoutPanel flowLayoutPanel)
        {
            collection.CollectionChanged += OnCollectionChanged;
            bool loadedAtLeastOneBook = false;
            foreach (Book.BookInfo bookInfo in collection.GetBookInfos())
            {
                try
                {
                    var isSuitableSourceForThisEditableCollection = (_model.IsShellProject && bookInfo.IsSuitableForMakingShells) ||
                              (!_model.IsShellProject && bookInfo.IsSuitableForVernacularLibrary);

                    if (isSuitableSourceForThisEditableCollection || collection.Type == BookCollection.CollectionType.TheOneEditableCollection)
                    {
                        if (!bookInfo.IsExperimental || Settings.Default.ShowExperimentalBooks)
                        {
                            loadedAtLeastOneBook = true;
                            AddOneBook(bookInfo, flowLayoutPanel);
                        }
                    }
                }
                catch (Exception error)
                {
                    Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error,"Could not load the book at "+bookInfo.FolderPath);
                }
            }
            return loadedAtLeastOneBook;
        }
Example #4
0
        /// <summary>
        /// used when this book is a "master"/"folio" book that is used to bring together a number of other books in the collection
        /// </summary>
        /// <param name="printingDom"></param>
        /// <param name="currentBookCollection"></param>
        /// <param name="bookServer"></param>
        private void AddChildBookContentsToFolio(HtmlDom printingDom, BookCollection currentBookCollection, BookServer bookServer)
        {
            XmlNode currentLastContentPage = GetLastPageForInsertingNewContent(printingDom);

            //currently we have no way of filtering them, we just take them all
            foreach (var bookInfo in currentBookCollection.GetBookInfos())
            {
                if (bookInfo.IsFolio)
                    continue;
                var childBook =bookServer.GetBookFromBookInfo(bookInfo);

                //add links to the template css needed by the children.
                //NB: at this point this code can't hand the "customBookStyles" from children, it'll ignore them (they woul conflict with each other)
                //NB: at this point custom styles (e.g. larger/smaller font rules) from children will be lost.
                var customStyleSheets = new List<string>();
                foreach (string sheetName in childBook.OurHtmlDom.GetTemplateStyleSheets())
                {
                    if (!customStyleSheets.Contains(sheetName)) //nb: if two books have stylesheets with the same name, we'll only be grabbing the 1st one.
                    {
                        customStyleSheets.Add(sheetName);
                        printingDom.AddStyleSheetIfMissing("file://"+Path.Combine(childBook.FolderPath,sheetName));
                    }
                }
                printingDom.SortStyleSheetLinks();

                foreach (XmlElement pageDiv in childBook.OurHtmlDom.RawDom.SafeSelectNodes("/html/body/div[contains(@class, 'bloom-page') and not(contains(@class,'bloom-frontMatter')) and not(contains(@class,'bloom-backMatter'))]"))
                {
                    XmlElement importedPage = (XmlElement) printingDom.RawDom.ImportNode(pageDiv, true);
                    currentLastContentPage.ParentNode.InsertAfter(importedPage, currentLastContentPage);
                    currentLastContentPage = importedPage;

                    ImageUpdater.MakeImagePathsOfImportedPagePointToOriginalLocations(importedPage, bookInfo.FolderPath);
                }
            }
        }