private void WebBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
if (e.Url.AbsoluteUri != "about:blank")
{
e.Cancel = true;
if (e.Url.AbsoluteUri.StartsWith("http://twitter.com/search?q=%23") ||
e.Url.AbsoluteUri.StartsWith("https://twitter.com/search?q=%23"))
{
//ハッシュタグの場合は、タブで開く
string urlStr = HttpUtility.UrlDecode(e.Url.AbsoluteUri);
string hash = urlStr.Substring(urlStr.IndexOf("#"));
MyOwner.HashSupl.AddItem(hash);
MyOwner.HashMgr.AddHashToHistory(hash.Trim(), false);
MyOwner.AddNewTabForSearch(hash);
return;
}
else
{
Match m = Regex.Match(e.Url.AbsoluteUri, @"^https?://twitter.com/(#!/)?(?<ScreenName>[a-zA-Z0-9_]+)$");
if (AppendSettingDialog.Instance.OpenUserTimeline && m.Success && MyOwner.IsTwitterId(m.Result("${ScreenName}")))
{
MyOwner.AddNewTabForUserTimeline(m.Result("${ScreenName}"));
}
else
{
MyOwner.OpenUriAsync(e.Url.OriginalString);
}
}
}
}