public void NavigateToLink(PostItemViewModel item, Hyperlink link)
{
Uri uri = link.GetValue(HyperlinkProperties.UriProperty) as Uri;
if (this._dvachUriParser.IsDvachUri(uri))
{
uri = this._urlBuilder.FixRelativeUri(uri);
var uriModel = this._dvachUriParser.ParseUri(uri);
if (uriModel == null)
{
this.NavigateToBrowser(uri);
return;
}
// if uri navigates to the current thread
if (uriModel.BoardName == this.BoardName && uriModel.ThreadNumber == this.ThreadNumber)
{
// don't do anything if the uri has no fragment
if (!string.IsNullOrEmpty(uri.Fragment))
{
string fragment = uri.Fragment.Substring(1);
var post = this.Posts.FirstOrDefault(p => p.Number.ToString() == fragment);
this._popupDisplayer.ShowPost(post, this._popupPlaceholder);
}
}
else
{
// if uri navigates to another thread, open the necessary page
this._pageNavigationService.NavigateToPostListPage(uriModel.BoardName, uriModel.ThreadNumber);
}
}
else if (uri != null)
{
this.NavigateToBrowser(uri);
}
}