/// <summary> /// Load stylesheet data from the given source.<br/> /// The source can be local file or web URI.<br/> /// First raise <see cref="HtmlStylesheetLoadEventArgs"/> event to allow the client to overwrite the stylesheet loading.<br/> /// If the stylesheet is downloaded from URI we will try to correct local URIs to absolute.<br/> /// </summary> /// <param name="htmlContainer">the container of the html to handle load stylesheet for</param> /// <param name="src">the source of the element to load the stylesheet by</param> /// <param name="attributes">the attributes of the link element</param> /// <param name="stylesheet">return the stylesheet string that has been loaded (null if failed or <paramref name="stylesheetData"/> is given)</param> /// <param name="stylesheetData">return stylesheet data object that was provided by overwrite (null if failed or <paramref name="stylesheet"/> is given)</param> public static void LoadStylesheet(HtmlContainerInt htmlContainer, string src, Dictionary<string, string> attributes, out string stylesheet, out CssData stylesheetData) { ArgChecker.AssertArgNotNull(htmlContainer, "htmlContainer"); stylesheet = null; stylesheetData = null; try { var args = new HtmlStylesheetLoadEventArgs(src, attributes); htmlContainer.RaiseHtmlStylesheetLoadEvent(args); if (!string.IsNullOrEmpty(args.SetStyleSheet)) { stylesheet = args.SetStyleSheet; } else if (args.SetStyleSheetData != null) { stylesheetData = args.SetStyleSheetData; } else if (args.SetSrc != null) { stylesheet = LoadStylesheet(htmlContainer, args.SetSrc); } else { stylesheet = LoadStylesheet(htmlContainer, src); } } catch (Exception ex) { htmlContainer.ReportError(HtmlRenderErrorType.CssParsing, "Exception in handling stylesheet source", ex); } }
protected override void OnStylesheetLoad(HtmlStylesheetLoadEventArgs e) { string styleSheetContent; if (ChapterContent.StyleSheets.TryGetValue(e.Src, out styleSheetContent)) e.SetStyleSheet = styleSheetContent; base.OnStylesheetLoad(e); }
private void OnStylesheetLoad(object sender, HtmlStylesheetLoadEventArgs e) { OnStylesheetLoad(e); }
/// <summary> /// Propagate the stylesheet load event from root container. /// </summary> protected virtual void OnStylesheetLoad(HtmlStylesheetLoadEventArgs e) { var handler = StylesheetLoad; if (handler != null) handler(this, e); }
/// <summary> /// Raise the stylesheet load event with the given event args. /// </summary> /// <param name="args">the event args</param> internal void RaiseHtmlStylesheetLoadEvent(HtmlStylesheetLoadEventArgs args) { try { EventHandler<HtmlStylesheetLoadEventArgs> handler = StylesheetLoad; if (handler != null) handler(this, args); } catch (Exception ex) { ReportError(HtmlRenderErrorType.CssParsing, "Failed stylesheet load event", ex); } }
private void OnStylesheetLoad(object sender, HtmlStylesheetLoadEventArgs e) { if (CheckAccess()) OnStylesheetLoad(e); else Dispatcher.Invoke(new Action<HtmlStylesheetLoadEventArgs>(OnStylesheetLoad), e); }
/// <summary> /// Propagate the stylesheet load event from root container. /// </summary> protected virtual void OnStylesheetLoad(HtmlStylesheetLoadEventArgs e) { RoutedEventArgs newEventArgs = new RoutedEvenArgs<HtmlStylesheetLoadEventArgs>(StylesheetLoadEvent, this, e); RaiseEvent(newEventArgs); }
/// <summary> /// Raise the stylesheet load event with the given event args. /// </summary> /// <param name="args">the event args</param> internal void RaiseHtmlStylesheetLoadEvent(HtmlStylesheetLoadEventArgs args) { try { if (StylesheetLoad != null) { StylesheetLoad(this, args); } } catch (Exception ex) { ReportError(HtmlRenderErrorType.CssParsing, "Failed stylesheet load event", ex); } }
/// <summary> /// Handle stylesheet resolve. /// </summary> public static void OnStylesheetLoad(object sender, HtmlStylesheetLoadEventArgs e) { var stylesheet = GetStylesheet(e.Src); if (stylesheet != null) e.SetStyleSheet = stylesheet; }