public static WebPad.UserControls.SnippetDocumentControl Parse(string filePath) { WebPad.UserControls.SnippetDocumentControl snippet = new UserControls.SnippetDocumentControl(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.Load(filePath); snippet.References = GetReferences(doc); snippet.Javascript = GetJavaScript(doc); snippet.CSS = GetStyleSheets(doc); snippet.SaveFilePath = filePath; snippet.Html = GetBodyHTML(doc); return(snippet); }
public async Task Render(UserControls.SnippetDocumentControl snippetDocControl) { // load the document text into the internet explorer browser if (_myBrowser != null) { try { // see info on how to navigate here: https://stackoverflow.com/questions/63116740/why-my-corewebview2-which-is-object-of-webview2-is-null await _myBrowser.EnsureCoreWebView2Async(); await SetupDocumentInteraction(); string url = snippetDocControl.EnsureServer(); _myBrowser.CoreWebView2.Navigate(url); } catch (Exception ex) { System.Windows.MessageBox.Show(string.Format("Problem with IE browser loading html. Exception: {0}", ex), "IE HTML Load Exception", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } } }
public static string GetDocumentText(UserControls.SnippetDocumentControl snippetDocControl) { string baseHref = snippetDocControl.BaseHref; if (!string.IsNullOrWhiteSpace(snippetDocControl.SaveFilePath)) { baseHref = "/"; // root, because we are going to dynamically determine where the files should come from } return(_basePageHtml.AsTemplated(new { //References = snippetDocControl.References.GetHtml(), jsRefs = References.GetHtml(snippetDocControl.References.Where(i => i.Type == ReferenceTypes.Javascript) ), cssRefs = References.GetHtml(snippetDocControl.References.Where(i => i.Type == ReferenceTypes.Css) ), Javascript = snippetDocControl.Javascript, Html = HtmlInjectLineNumberAnchors.Inject(snippetDocControl.Html), CSS = snippetDocControl.CSS, PageTitle = snippetDocControl.SaveFileName, BaseHref = baseHref, javascriptStartupCode = _javascriptStartupcode })); }
public WebPadServerManager(UserControls.SnippetDocumentControl _ctrl) { this.control = _ctrl; }