internal StyleSheetList(CssXmlDocument document) { _cssXmlDoc = document; XmlNodeList pis = document.SelectNodes("/processing-instruction()"); _styleSheets = new List <StyleSheet>(); foreach (XmlProcessingInstruction pi in pis) { if (Regex.IsMatch(pi.Data, "type=[\"']text\\/css[\"']")) { _styleSheets.Add(new CssStyleSheet(pi, CssStyleSheetType.Author)); } else { _styleSheets.Add(new StyleSheet(pi)); } } XmlNodeList styleNodes; foreach (string[] name in document._styleElements) { styleNodes = document.SelectNodes("//*[local-name()='" + name[1] + "' and namespace-uri()='" + name[0] + "'][@type='text/css' or not(@type)]"); foreach (XmlElement elm in styleNodes) { _styleSheets.Add(new CssStyleSheet(elm, CssStyleSheetType.Author)); } } }
public virtual void SetupStyleSheets(WpfDrawingSettings drawingSettings) { if (drawingSettings == null) { return; } CssXmlDocument cssDocument = this.Document as CssXmlDocument; if (cssDocument == null) { return; } string userCssFilePath = drawingSettings.UserCssFilePath; if (!string.IsNullOrWhiteSpace(userCssFilePath) && File.Exists(userCssFilePath)) { cssDocument.SetUserStyleSheet(userCssFilePath); } string userAgentCssFilePath = drawingSettings.UserAgentCssFilePath; if (!string.IsNullOrWhiteSpace(userAgentCssFilePath) && File.Exists(userAgentCssFilePath)) { cssDocument.SetUserAgentStyleSheet(userAgentCssFilePath); } }
public virtual void TestTypeFromCreateElement() { CssXmlDocument doc = new CssXmlDocument(); XmlElement elm = doc.CreateElement("", "dummy", ""); Assert.AreEqual(elm.GetType(), elmType); }
public virtual void TestTypeFromDocument() { CssXmlDocument doc = new CssXmlDocument(); doc.LoadXml("<dummy />"); XmlElement elm = doc.DocumentElement; Assert.AreEqual(elmType, elm.GetType()); }
internal StyleSheetList(CssXmlDocument document) { _cssXmlDoc = document; XmlNodeList pis = document.SelectNodes("/processing-instruction()"); _styleSheets = new List <StyleSheet>(); foreach (XmlProcessingInstruction pi in pis) { if (Regex.IsMatch(pi.Data, "type=[\"']text\\/css[\"']")) { _styleSheets.Add(new CssStyleSheet(pi, CssStyleSheetType.Author)); } else { _styleSheets.Add(new StyleSheet(pi)); } } XmlNodeList styleNodes; foreach (string[] name in document._styleElements) { //TODO: Fixed style finding - yavor87 committed on Sep 17, 2016 //styleNodes = document.SelectNodes("//*[local-name()='" + name[1] // + "' and namespace-uri()='" + name[0] + "'][@type='text/css' or not(@type)]"); styleNodes = document.SelectNodes( "//*[local-name()='" + name[1] + "' and namespace-uri()='" + name[0] + "']"); if (styleNodes == null) { continue; } foreach (XmlElement elm in styleNodes) { var styleType = elm.GetAttribute("type"); // Check for valid 'type' attribute of the style element if (string.IsNullOrWhiteSpace(styleType) || string.Equals(styleType, "text/css", StringComparison.OrdinalIgnoreCase)) { _styleSheets.Add(new CssStyleSheet(elm, CssStyleSheetType.Author)); } } } }
/// <summary> /// Loads the default user and agent stylesheets into the current SvgDocument /// </summary> protected virtual void SetupStyleSheets() { CssXmlDocument cssDocument = (CssXmlDocument)window.Document; string appRootPath = SvgApplicationContext.ExecutableDirectory.FullName; FileInfo userAgentCssPath = new FileInfo(appRootPath + "\\" + UserAgentCssFileName); FileInfo userCssPath = new FileInfo(appRootPath + "\\" + UserCssFileName); if (userAgentCssPath.Exists) { cssDocument.SetUserAgentStyleSheet((new Uri("file:/" + userAgentCssPath.FullName)).AbsoluteUri); } if (userCssPath.Exists) { cssDocument.SetUserStyleSheet((new Uri("file:/" + userCssPath.FullName)).AbsoluteUri); } }