private void WikiBrowser_Loaded(object sender, RoutedEventArgs e) { if (Model != null && Model.WikiHtml != null) { WikiBrowser.NavigateToString(Model.WikiHtml); } }
void wikiService_GetArticleCompleted(object sender, WikiService.GetArticleCompletedEventArgs e) { if (e.Error != null) { Dispatcher.BeginInvoke(() => { ChangeLoadState(false); ShowPopupMessage("Connection error"); }); } else { var article = e.Result; Dispatcher.BeginInvoke(() => { WikiBrowser.Opacity = 0.0; Model.WikiUrl = article.Url; Model.WikiTitle = article.Title; var wikiStyles = "<meta content=\"text/html; charset=UTF-8\" http-equiv=\"Content-Type\"><style>\n"; wikiStyles += "a, a:hover, a:visited { text-decoration: none; color:" + ConvertColorToHex(accentBrush.Color) + "; }\n"; wikiStyles += "img { border: 0; }\n"; wikiStyles += "body { font-family: Segoe UI Light; margin:0; padding:0; background-color:" + ConvertColorToHex(phoneBackgroundBrush.Color) + "; color:" + ConvertColorToHex(phoneForegroundBrush.Color) + ";}\n"; wikiStyles += "</style>"; Model.WikiHtml = ConvertExtendedASCII(string.Format("<html><head>{1}</head><body bgcolor=\"" + ConvertColorToHex(phoneBackgroundBrush.Color) + "\"><p>{0}</p></body></html>", article.Body, wikiStyles)); WikiBrowser.NavigateToString(Model.WikiHtml); //WikiBrowser.NavigateToString(GetWikiHtml(html)); //WikiListBox.UpdateLayout(); //WikiListBox.ScrollIntoView(WikiListBox.Items.First()); ChangeLoadState(false); }); } }
/// <summary> /// Initializes a new instance of the <see cref="Launcher"/> class. /// </summary> public Launcher() { InitializeComponent(); if (!Program.NetworkConnected) { TumblrBrowser.Hide(); WikiBrowser.Hide(); ForumBrowser.Hide(); TabBox.Enabled = false; } else { NoConnectionLabel.Hide(); } }
private void LoadWikiArticle(string url, bool storeInStack) { if (Model.WikiUrl != null && storeInStack) { Model.WikiUrls.Add(Model.WikiUrl); } ChangeLoadState(true); var request = HttpWebRequest.Create(url) as HttpWebRequest; request.BeginGetResponse((result) => { WebResponse response = null; try { response = request.EndGetResponse(result); } catch { Dispatcher.BeginInvoke(() => { ChangeLoadState(false); ShowPopupMessage("Connection error"); }); } if (response != null) { var sr = new StreamReader(response.GetResponseStream()); var html = sr.ReadToEnd(); sr.Close(); response.Close(); html = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(html), 0, html.Length); Dispatcher.BeginInvoke(() => { WikiBrowser.Opacity = 0.0; Model.WikiUrl = response.ResponseUri.ToString(); Model.WikiTitle = GetWikiTitle(html); //WikiText.Text = GetWikiText(html); var wikiStyles = "<meta content=\"text/html; charset=UTF-8\" http-equiv=\"Content-Type\"><style>\n"; wikiStyles += "a, a:hover, a:visited { text-decoration: none; color:" + ConvertColorToHex(accentBrush.Color) + "; }\n"; wikiStyles += "img { border: 0; }\n"; wikiStyles += "body { font-family: Segoe UI Light; margin:0; padding:0; background-color:" + ConvertColorToHex(phoneBackgroundBrush.Color) + "; color:" + ConvertColorToHex(phoneForegroundBrush.Color) + ";}\n"; wikiStyles += "</style>"; Model.WikiHtml = ConvertExtendedASCII(string.Format("<html><head>{1}</head><body bgcolor=\"" + ConvertColorToHex(phoneBackgroundBrush.Color) + "\"><p>{0}</p></body></html>", GetWikiText(html), wikiStyles)); WikiBrowser.NavigateToString(Model.WikiHtml); //WikiBrowser.NavigateToString(GetWikiHtml(html)); //WikiListBox.UpdateLayout(); //WikiListBox.ScrollIntoView(WikiListBox.Items.First()); ChangeLoadState(false); }); } }, request); }