本文整理汇总了C#中Bloom.Book.HtmlDom.AddStyleSheetIfMissing方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlDom.AddStyleSheetIfMissing方法的具体用法?C# HtmlDom.AddStyleSheetIfMissing怎么用?C# HtmlDom.AddStyleSheetIfMissing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bloom.Book.HtmlDom
的用法示例。
在下文中一共展示了HtmlDom.AddStyleSheetIfMissing方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddStylesheetFromAnotherBook
public static void AddStylesheetFromAnotherBook(HtmlDom sourceBookDom, HtmlDom targetBookDom)
{
var addedModifiedStyleSheets = new List<string>();
//This was refactored from book, where there was these notes:
// NB: at this point this code can't handle the "userModifiedStyles" from children, it'll ignore them (they would conflict with each other)
// NB: at this point custom styles (e.g. larger/smaller font rules) from children will be lost.
//At this point, this addedModifiedStyleSheets is just used as a place to track which stylesheets we already have
foreach(string sheetName in sourceBookDom.GetTemplateStyleSheets())
{
if(!addedModifiedStyleSheets.Contains(sheetName))
//nb: if two books have stylesheets with the same name, we'll only be grabbing the 1st one.
{
addedModifiedStyleSheets.Add(sheetName);
targetBookDom.AddStyleSheetIfMissing(sheetName);
}
}
}
示例2: AddChildBookContentsToFolio
/// <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);
}
}
}