当前位置: 首页>>代码示例>>C#>>正文


C# HtmlDom.SortStyleSheetLinks方法代码示例

本文整理汇总了C#中Bloom.Book.HtmlDom.SortStyleSheetLinks方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlDom.SortStyleSheetLinks方法的具体用法?C# HtmlDom.SortStyleSheetLinks怎么用?C# HtmlDom.SortStyleSheetLinks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bloom.Book.HtmlDom的用法示例。


在下文中一共展示了HtmlDom.SortStyleSheetLinks方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SortStyleSheetLinks_LeavesOverridesAtEndAndSpecialFilesInMiddle

        public void SortStyleSheetLinks_LeavesOverridesAtEndAndSpecialFilesInMiddle()
        {
            var content =
               @"<html><head>
                <link rel='stylesheet' href='my special b.css' type='text/css' />
                <link rel='stylesheet' href='Factory-Xmatter.css' type='text/css' />
                <link rel='stylesheet' href='my special a.css' type='text/css' />
                <link rel='stylesheet' href='../settingsCollectionStyles.css' type='text/css' />
                <link rel='stylesheet' href='my special c.css' type='text/css' />
                <link rel='stylesheet' href='Basic book.css' type='text/css' />
                <link rel='stylesheet' href='../customCollectionStyles.css' type='text/css' />
                <link rel='stylesheet' href='customBookStyles.css' type='text/css' />
                <link rel='stylesheet' href='basePage.css' type='text/css' />
                <link rel='stylesheet' href='languageDisplay.css' type='text/css' />
                <link rel='stylesheet' href='../../editMode.css' type='text/css' />

                </head></html>";

            var bookdom = new HtmlDom(content);

            bookdom.SortStyleSheetLinks();
            var dom = bookdom.RawDom;

            AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//head/link[1][@href='basePage.css']", 1);
            AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//head/link[2][@href='../../editMode.css']", 1);
            AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//head/link[3][@href='Basic book.css']", 1);
            AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//head/link[4][@href='Factory-Xmatter.css']", 1);
            AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//head/link[5][@href='my special a.css']", 1);
            AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//head/link[6][@href='my special b.css']", 1);
            AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//head/link[7][@href='my special c.css']", 1);

            //NB: I (JH) don't for sure know yet what the order of this should be. I think it should be last-ish.
            AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//head/link[8][@href='languageDisplay.css']", 1);

            AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//head/link[9][@href='../settingsCollectionStyles.css']", 1);
            AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//head/link[10][@href='../customCollectionStyles.css']", 1);
            AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//head/link[11][@href='customBookStyles.css']", 1);
        }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:38,代码来源:HtmlDomTests.cs

示例2: SortStyleSheetLinks_LeavesBasePageBeforePreviewMode

        public void SortStyleSheetLinks_LeavesBasePageBeforePreviewMode()
        {
            var dom = new HtmlDom(
               @"<html><head>
                <link rel='stylesheet' href='../../previewMode.css' type='text/css' />
                <link rel='stylesheet' href='basePage.css' type='text/css' />
                </head></html>");

            dom.SortStyleSheetLinks();

            AssertThatXmlIn.Dom(dom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//head/link[1][@href='basePage.css']", 1);
            AssertThatXmlIn.Dom(dom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//head/link[2][@href='../../previewMode.css']", 1);
        }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:13,代码来源:HtmlDomTests.cs

示例3: MakeCssLinksAppropriateForEpub

 private static void MakeCssLinksAppropriateForEpub(HtmlDom dom)
 {
     dom.RemoveModeStyleSheets();
     dom.SortStyleSheetLinks();
     dom.RemoveFileProtocolFromStyleSheetLinks();
     dom.RemoveDirectorySpecificationFromStyleSheetLinks();
 }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:7,代码来源:EpubMaker.cs

示例4: MakeCssLinksAppropriateForStoredFile

 //while in Bloom, we could have and edit style sheet or (someday) other modes. But when stored,
 //we want to make sure it's ready to be opened in a browser.
 private void MakeCssLinksAppropriateForStoredFile(HtmlDom dom)
 {
     dom.RemoveModeStyleSheets();
     dom.AddStyleSheet("previewMode.css");
     dom.AddStyleSheet("basePage.css");
     EnsureHasLinksToStylesheets(dom);
     dom.SortStyleSheetLinks();
     dom.RemoveFileProtocolFromStyleSheetLinks();
 }
开发者ID:JohnThomson,项目名称:testBloom,代码行数:11,代码来源:BookStorage.cs

示例5: 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);

                //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));

                    }
                }
            }
        }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:49,代码来源:Book.cs

示例6: 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);
                }
            }
        }
开发者ID:jorik041,项目名称:BloomDesktop,代码行数:41,代码来源:Book.cs


注:本文中的Bloom.Book.HtmlDom.SortStyleSheetLinks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。