internal async static void Generate(this IHtmlView htmlView) { var html = htmlView.Html; var itemsControl = (ItemsControl)htmlView; if (string.IsNullOrEmpty(html)) itemsControl.Items.Clear(); htmlView.SizeDependentControls.Clear(); var scrollableHtmlView = htmlView as ScrollableHtmlView; if (scrollableHtmlView != null) scrollableHtmlView.UpdateHeader(); if (string.IsNullOrEmpty(html)) { if (scrollableHtmlView != null) scrollableHtmlView.UpdateFooter(); if (htmlView is ScrollableHtmlView) ((ScrollableHtmlView)htmlView).OnHtmlLoaded(); else ((HtmlView)htmlView).OnHtmlLoaded(); return; } HtmlNode node = null; #if WP7 await Task.Factory.StartNew(() => #else await Task.Run(() => #endif { try { var parser = new HtmlParser(); node = parser.Parse(html); } catch { } }); if (html == htmlView.Html) { if (node != null) { try { itemsControl.Items.Clear(); if (scrollableHtmlView != null) scrollableHtmlView.UpdateHeader(); foreach (var control in node.GetControls(htmlView)) { if (scrollableHtmlView != null && scrollableHtmlView.InnerMaxWidth != 0) ((FrameworkElement)control).MaxWidth = scrollableHtmlView.InnerMaxWidth; itemsControl.Items.Add(control); } if (scrollableHtmlView != null) scrollableHtmlView.UpdateFooter(); } catch { } } if (htmlView is ScrollableHtmlView) ((ScrollableHtmlView)htmlView).OnHtmlLoaded(); else ((HtmlView)htmlView).OnHtmlLoaded(); } }
internal static async void Generate(this IHtmlView htmlView) { var html = htmlView.Html; var itemsControl = (ItemsControl) htmlView; if (string.IsNullOrEmpty(html)) itemsControl.Items.Clear(); htmlView.SizeDependentControls.Clear(); var scrollableHtmlView = htmlView as HtmlControl; if (scrollableHtmlView != null) scrollableHtmlView.UpdateHeader(); if (string.IsNullOrEmpty(html)) { if (scrollableHtmlView != null) scrollableHtmlView.UpdateFooter(); if (htmlView is HtmlControl) ((HtmlControl) htmlView).OnHtmlLoaded(); // ((HtmlView)htmlView).OnHtmlLoaded(); return; } HtmlNode node = null; await Task.Run(() => { try { var parser = new HtmlParser(); node = parser.Parse(html); } catch { } }); if (html == htmlView.Html) { if (node != null) { try { itemsControl.Items.Clear(); if (scrollableHtmlView != null) scrollableHtmlView.UpdateHeader(); var listcontrols = node.GetControls(htmlView).ToList(); foreach (var control in listcontrols) { if (scrollableHtmlView != null && scrollableHtmlView.InnerMaxWidth != 0) ((FrameworkElement) control).MaxWidth = scrollableHtmlView.InnerMaxWidth; itemsControl.Items.Add(control); } if (scrollableHtmlView != null) scrollableHtmlView.UpdateFooter(); } catch { } if (htmlView is HtmlControl) ((HtmlControl) htmlView).OnHtmlLoaded(); if (scrollableHtmlView.Background != null) { scrollableHtmlView.ScrollViewer.Background = scrollableHtmlView.Background; } //((HtmlView)htmlView).OnHtmlLoaded(); } } }