public static async void OpenBrowser(Frame frame, Uri uri) { var setting = new StoreSettings(); var usingInAppBrowser = setting.TryGetValueWithDefault("UseInAppBrowser", true); if (usingInAppBrowser) { frame.Navigate(typeof(Pages.EasyWebViewerPage), uri); } else { bool success = await Windows.System.Launcher.LaunchUriAsync(uri); if (!success) { var message = new MessageDialog("ブラウザの起動に失敗しました。", "おや? なにかがおかしいようです。"); await message.ShowAsync(); } } }
private static AdvancedTweet FormatTweet(AdvancedTweet tweet) { //まずはTweetがRetweetなのか、などの振り分け。 if (tweet.tweet.retweeted_status != null) { tweet.message = "@" + tweet.tweet.user.screen_name + " retweeted"; tweet.source = tweet.tweet; tweet.tweet = tweet.tweet.retweeted_status; tweet.state = AdvancedTweet.States.Retweeted; tweet.subImage = "Assets/TwitterIcons/retweet.png"; } else { tweet.state = AdvancedTweet.States.Tweet; } if (tweet.tweet.entities.urls != null) { foreach (Url url in tweet.tweet.entities.urls) { tweet.tweet.text = tweet.tweet.text.Replace(url.url, url.display_url); } } if (tweet.tweet.entities.media != null) { foreach (Media url in tweet.tweet.entities.media) { tweet.tweet.text = tweet.tweet.text.Replace(url.url, url.display_url); } } //mentionに自分がいたらツイートの色を変える foreach (var mention in tweet.tweet.entities.user_mentions) { if (mention.screen_name == tweet.accessToken.screenName) { tweet.ButtonColor = new SolidColorBrush(Windows.UI.Colors.Azure); } } //textのフォントサイズ指定(できれば毎回StoreSettingsを呼び出したくないぞ...) var settings = new StoreSettings(); var index = settings.TryGetValueWithDefault("TextFontSize", 1); switch (index) { case 0: tweet.tweet.text_font_size = 17; break; case 1: tweet.tweet.text_font_size = 12; break; case 2: tweet.tweet.text_font_size = 7; break; default: break; } Regex rx = new Regex("<a href=\"(?<url>.*?)\".*?>(?<text>.*?)</a>"); var mc = rx.Match(tweet.tweet.source); if (mc.Success) { tweet.tweet.source = mc.Groups["text"].Value; } tweet.createdAtDatetime = DateTime.ParseExact(tweet.tweet.created_at, "ddd MMM dd HH:mm:ss zzz yyyy", CultureInfo.InvariantCulture); tweet.tweet.created_at_time = tweet.createdAtDatetime.ToString("HH:mm"); tweet.tweet.created_at_datetime = tweet.createdAtDatetime.ToString("yyyy/MM/dd HH:mm:ss"); tweet.tweet.text = WebUtility.HtmlDecode(tweet.tweet.text); return(tweet); }