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


C# Book.HtmlDom类代码示例

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


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

示例1: CopyImageMetadataToWholeBook

        public static void CopyImageMetadataToWholeBook(string folderPath, HtmlDom dom, Metadata metadata, IProgress progress)
        {
            progress.WriteStatus("Starting...");

            //First update the images themselves

            int completed = 0;
            var imgElements = GetImagePaths(folderPath);
            foreach (string path in imgElements)
            {
                progress.ProgressIndicator.PercentCompleted = (int)(100.0 * (float)completed / imgElements.Count());
                progress.WriteStatus("Copying to " + Path.GetFileName(path));

                try
                {
                    metadata.WriteIntellectualPropertyOnly(path);
                }
                catch (TagLib.CorruptFileException e)
                {
                    NonFatalProblem.Report(ModalIf.Beta, PassiveIf.All,"Image metadata problem", "Bloom had a problem accessing the metadata portion of this image " + path+ "  ref(BL-3214)", e);
                }

                ++completed;
            }

            //Now update the html attributes which echo some of it, and is used by javascript to overlay displays related to
            //whether the info is there or missing or whatever.

            foreach (XmlElement img in dom.SafeSelectNodes("//img"))
            {
                UpdateImgMetdataAttributesToMatchImage(folderPath, img, progress, metadata);
            }
        }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:33,代码来源:ImageUpdater.cs

示例2: SetBaseForRelativePaths_NoExistingBase_Adds

 public void SetBaseForRelativePaths_NoExistingBase_Adds()
 {
     var dom = new HtmlDom(
                   @"<html><head/></html>");
     dom.SetBaseForRelativePaths("theBase");
     AssertThatXmlIn.Dom(dom.RawDom).HasSpecifiedNumberOfMatchesForXpath("html/head/base[@href='theBase']", 1);
 }
开发者ID:JohnThomson,项目名称:testBloom,代码行数:7,代码来源:HtmlDomTests.cs

示例3: AppendToolboxPanel

 /// <summary>Loads the requested panel into the toolbox</summary>
 public static void AppendToolboxPanel(HtmlDom domForToolbox, string fileName)
 {
     var toolbox = domForToolbox.Body.SelectSingleNode("//div[@id='toolbox']");
     var toolDom = new HtmlDom(XmlHtmlConverter.GetXmlDomFromHtmlFile(fileName));
     AddToolDependencies(toolDom);
     AppendAllChildren(toolDom.Body, toolbox);
 }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:8,代码来源:ToolboxView.cs

示例4: CopyImageMetadataToWholeBook

        public static void CopyImageMetadataToWholeBook(string folderPath, HtmlDom dom, Metadata metadata, IProgress progress)
        {
            progress.WriteStatus("Starting...");

            //First update the images themselves

            int completed = 0;
            var imgElements = GetImagePaths(folderPath);
            foreach (string path in imgElements)
            {
                progress.ProgressIndicator.PercentCompleted = (int)(100.0 * (float)completed / imgElements.Count());
                progress.WriteStatus("Copying to " + Path.GetFileName(path));
                using (var image = PalasoImage.FromFile(path))
                {
                    image.Metadata = metadata;
                    image.SaveUpdatedMetadataIfItMakesSense();
                }
                ++completed;
            }

            //Now update the html attributes which echo some of it, and is used by javascript to overlay displays related to
            //whether the info is there or missing or whatever.

            foreach (XmlElement img in dom.SafeSelectNodes("//img"))
            {
                UpdateImgMetdataAttributesToMatchImage(folderPath, img, progress, metadata);
            }
        }
开发者ID:JohnThomson,项目名称:testBloom,代码行数:28,代码来源:ImageUpdater.cs

示例5: BaseForRelativePaths_NoHead_NoLongerThrows

 public void BaseForRelativePaths_NoHead_NoLongerThrows()
 {
     var dom = new HtmlDom(
                   @"<html></html>");
     dom.BaseForRelativePaths = "theBase";
     Assert.AreEqual("theBase", dom.BaseForRelativePaths);
 }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:7,代码来源:HtmlDomTests.cs

示例6: AddUIDictionaryToDom

        public static void AddUIDictionaryToDom(HtmlDom pageDom, CollectionSettings collectionSettings)
        {
            XmlElement dictionaryScriptElement = pageDom.RawDom.SelectSingleNode("//script[@id='ui-dictionary']") as XmlElement;
            if (dictionaryScriptElement != null)
                dictionaryScriptElement.ParentNode.RemoveChild(dictionaryScriptElement);

            dictionaryScriptElement = pageDom.RawDom.CreateElement("script");
            dictionaryScriptElement.SetAttribute("type", "text/javascript");
            dictionaryScriptElement.SetAttribute("id", "ui-dictionary");
            var d = new Dictionary<string, string>();

            d.Add(collectionSettings.Language1Iso639Code, collectionSettings.Language1Name);
            if (!String.IsNullOrEmpty(collectionSettings.Language2Iso639Code) && !d.ContainsKey(collectionSettings.Language2Iso639Code))
                d.Add(collectionSettings.Language2Iso639Code, collectionSettings.GetLanguage2Name(collectionSettings.Language2Iso639Code));
            if (!String.IsNullOrEmpty(collectionSettings.Language3Iso639Code) && !d.ContainsKey(collectionSettings.Language3Iso639Code))
                d.Add(collectionSettings.Language3Iso639Code, collectionSettings.GetLanguage3Name(collectionSettings.Language3Iso639Code));

            d.Add("vernacularLang", collectionSettings.Language1Iso639Code);//use for making the vernacular the first tab
            d.Add("{V}", collectionSettings.Language1Name);
            d.Add("{N1}", collectionSettings.GetLanguage2Name(collectionSettings.Language2Iso639Code));
            d.Add("{N2}", collectionSettings.GetLanguage3Name(collectionSettings.Language3Iso639Code));

            AddLocalizedHintContentsToDictionary(pageDom, d, collectionSettings);

            dictionaryScriptElement.InnerText = String.Format("function GetDictionary() {{ return {0};}}", JsonConvert.SerializeObject(d));

            pageDom.Head.InsertAfter(dictionaryScriptElement, pageDom.Head.LastChild);
        }
开发者ID:JohnThomson,项目名称:testBloom,代码行数:28,代码来源:RuntimeInformationInjector.cs

示例7: BaseForRelativePaths_NullPath_SetsToEmpty

 public void BaseForRelativePaths_NullPath_SetsToEmpty()
 {
     var dom = new HtmlDom(
                   @"<html><head><base href='original'/></head></html>");
     dom.BaseForRelativePaths = null;
     AssertThatXmlIn.Dom(dom.RawDom).HasSpecifiedNumberOfMatchesForXpath("html/head/base", 0);
     Assert.AreEqual(string.Empty, dom.BaseForRelativePaths);
 }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:8,代码来源:HtmlDomTests.cs

示例8: BringBookUpToDate_DomHas2ContentLanguages_PulledIntoBookProperties

 public void BringBookUpToDate_DomHas2ContentLanguages_PulledIntoBookProperties()
 {
     _bookDom = new HtmlDom(@"<html><head><div id='bloomDataDiv'><div data-book='contentLanguage2'>okm</div><div data-book='contentLanguage3'>kbt</div></div></head><body></body></html>");
     var book = CreateBook();
     book.BringBookUpToDate(new NullProgress());
     Assert.AreEqual("okm", book.MultilingualContentLanguage2);
     Assert.AreEqual("kbt", book.MultilingualContentLanguage3);
 }
开发者ID:JohnThomson,项目名称:testBloom,代码行数:8,代码来源:BookTests.cs

示例9: BaseForRelativePaths_HasExistingBase_Removes

 public void BaseForRelativePaths_HasExistingBase_Removes()
 {
     var dom = new HtmlDom(
                   @"<html><head><base href='original'/></head></html>");
     AssertThatXmlIn.Dom(dom.RawDom).HasSpecifiedNumberOfMatchesForXpath("html/head/base[@href='original']", 1);
     dom.BaseForRelativePaths = "new";
     AssertThatXmlIn.Dom(dom.RawDom).HasSpecifiedNumberOfMatchesForXpath("html/head/base", 0);
     Assert.AreEqual("new", dom.BaseForRelativePaths);
 }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:9,代码来源:HtmlDomTests.cs

示例10: SetBaseForRelativePaths_HasExistingBase_Replaces

 public void SetBaseForRelativePaths_HasExistingBase_Replaces()
 {
     var dom = new HtmlDom(
                   @"<html><head><base href='original'/></head></html>");
     AssertThatXmlIn.Dom(dom.RawDom).HasSpecifiedNumberOfMatchesForXpath("html/head/base[@href='original']", 1);
     dom.SetBaseForRelativePaths("new");
     AssertThatXmlIn.Dom(dom.RawDom).HasSpecifiedNumberOfMatchesForXpath("html/head/base[@href='original']", 0);
     AssertThatXmlIn.Dom(dom.RawDom).HasSpecifiedNumberOfMatchesForXpath("html/head/base[@href='new']", 1);
 }
开发者ID:JohnThomson,项目名称:testBloom,代码行数:9,代码来源:HtmlDomTests.cs

示例11: RemoveMetaValue_IsThere_RemovesIt

 public void RemoveMetaValue_IsThere_RemovesIt()
 {
     var dom = new HtmlDom(
                   @"<html><head>
         <meta name='one' content='1'/>
         </head></html>");
     dom.RemoveMetaElement("one");
     AssertThatXmlIn.Dom(dom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//meta[@name='one']", 0);
 }
开发者ID:JohnThomson,项目名称:testBloom,代码行数:9,代码来源:HtmlDomTests.cs

示例12: BookData

 /// <param name="dom">Set this parameter to, say, a page that the user just edited, to limit reading to it, so its values don't get overriden by previous pages.
 ///   Supply the whole dom if nothing has priority (which will mean the data-div will win, because it is first)</param>
 /// <param name="collectionSettings"> </param>
 /// <param name="updateImgNodeCallback">This is a callback so as not to introduce dependencies on ImageUpdater & the current folder path</param>
 public BookData(HtmlDom dom, CollectionSettings collectionSettings, Action<XmlElement> updateImgNodeCallback)
 {
     _dom = dom;
     _updateImgNode = updateImgNodeCallback;
     _collectionSettings = collectionSettings;
     GetOrCreateDataDiv();
     _dataset = GatherDataItemsFromCollectionSettings(_collectionSettings);
     GatherDataItemsFromXElement(_dataset,_dom.RawDom);
 }
开发者ID:jorik041,项目名称:BloomDesktop,代码行数:13,代码来源:BookData.cs

示例13: LoadPanelIntoToolbox

 public static void LoadPanelIntoToolbox(HtmlDom domForToolbox, ToolboxTool tool, List<string> checkedBoxes, string toolboxFolder)
 {
     // For all the toolbox tools, the tool name is used as the name of both the folder where the
     // assets for that tool are kept, and the name of the main htm file that represents the tool.
     var fileName = tool.ToolId + "ToolboxPanel.html";
     var path = BloomFileLocator.sTheMostRecentBloomFileLocator.LocateFile(fileName);
     Debug.Assert(!string.IsNullOrEmpty(path));
     AppendToolboxPanel(domForToolbox, path);
     checkedBoxes.Add(tool.ToolId + "Check");
 }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:10,代码来源:ToolboxView.cs

示例14: Constructor_CollectionSettingsHasCountrProvinceDistrict_LanguageLocationFilledIn

 public void Constructor_CollectionSettingsHasCountrProvinceDistrict_LanguageLocationFilledIn()
 {
     //            var dom = new HtmlDom(@"<html><head><div id='bloomDataDiv'>
     //                    <div data-book='country'>the country</div>
     //                    <div data-book='province'>the province</div>
     //                    <div data-book='district'>the district</div>
     //            </div></head><body></body></html>");
     var dom = new HtmlDom();
     var data = new BookData(dom, new CollectionSettings(){Country="the country", Province = "the province", District= "the district"}, null);
     Assert.AreEqual("the district, the province<br/>the country", data.GetVariableOrNull("languageLocation", "*"));
 }
开发者ID:JohnThomson,项目名称:testBloom,代码行数:11,代码来源:BookDataTests.cs

示例15: AddUIDictionaryToDom

        public static void AddUIDictionaryToDom(HtmlDom pageDom, CollectionSettings collectionSettings)
        {
            CheckDynamicStrings();

            // add dictionary script to the page
            XmlElement dictionaryScriptElement = pageDom.RawDom.SelectSingleNode("//script[@id='ui-dictionary']") as XmlElement;
            if (dictionaryScriptElement != null)
                dictionaryScriptElement.ParentNode.RemoveChild(dictionaryScriptElement);

            dictionaryScriptElement = pageDom.RawDom.CreateElement("script");
            dictionaryScriptElement.SetAttribute("type", "text/javascript");
            dictionaryScriptElement.SetAttribute("id", "ui-dictionary");
            var d = new Dictionary<string, string>();

            d.Add(collectionSettings.Language1Iso639Code, collectionSettings.Language1Name);
            if (!String.IsNullOrEmpty(collectionSettings.Language2Iso639Code))
                SafelyAddLanguage(d, collectionSettings.Language2Iso639Code,
                    collectionSettings.GetLanguage2Name(collectionSettings.Language2Iso639Code));
            if (!String.IsNullOrEmpty(collectionSettings.Language3Iso639Code))
                SafelyAddLanguage(d, collectionSettings.Language3Iso639Code,
                    collectionSettings.GetLanguage3Name(collectionSettings.Language3Iso639Code));

            SafelyAddLanguage(d, "vernacularLang", collectionSettings.Language1Iso639Code);//use for making the vernacular the first tab
            SafelyAddLanguage(d, "{V}", collectionSettings.Language1Name);
            SafelyAddLanguage(d, "{N1}", collectionSettings.GetLanguage2Name(collectionSettings.Language2Iso639Code));
            SafelyAddLanguage(d, "{N2}", collectionSettings.GetLanguage3Name(collectionSettings.Language3Iso639Code));

            // TODO: Eventually we need to look through all .bloom-translationGroup elements on the current page to determine
            // whether there is text in a language not yet added to the dictionary.
            // For now, we just add a few we know we need
            AddSomeCommonNationalLanguages(d);

            MakePageLabelLocalizable(pageDom, d);

            // Hard-coded localizations for 2.0
            AddHtmlUiStrings(d);

            // Do this last, on the off-chance that the page contains a localizable string that matches
            // a language code.
            AddLanguagesUsedInPage(pageDom.RawDom, d);

            dictionaryScriptElement.InnerText = String.Format("function GetInlineDictionary() {{ return {0};}}", JsonConvert.SerializeObject(d));

            // add i18n initialization script to the page
            //AddLocalizationTriggerToDom(pageDom);

            pageDom.Head.InsertAfter(dictionaryScriptElement, pageDom.Head.LastChild);

            _collectDynamicStrings = false;
        }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:50,代码来源:RuntimeInformationInjector.cs


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