Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/GitHub.InlineReviews/Views/CommentView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
</ResourceDictionary>
</FrameworkElement.Resources>

<FrameworkElement.CommandBindings>
<CommandBinding Command="{x:Static markdig:Commands.Hyperlink}" Executed="OpenHyperlink" />
</FrameworkElement.CommandBindings>

<Grid>
<!-- Displays an existing comment-->
<StackPanel Orientation="Vertical" Margin="4">
Expand Down
21 changes: 18 additions & 3 deletions src/GitHub.InlineReviews/Views/CommentView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
using GitHub.InlineReviews.ViewModels;
using GitHub.Services;
Expand All @@ -23,11 +24,15 @@ public CommentView()
});
}

void DoOpenOnGitHub()
IVisualStudioBrowser GetBrowser()
{
var serviceProvider = (IGitHubServiceProvider)Package.GetGlobalService(typeof(IGitHubServiceProvider));
var browser = serviceProvider.GetService<IVisualStudioBrowser>();
browser.OpenUrl(ViewModel.Thread.GetCommentUrl(ViewModel.Id));
return serviceProvider.GetService<IVisualStudioBrowser>();
}

void DoOpenOnGitHub()
{
GetBrowser().OpenUrl(ViewModel.Thread.GetCommentUrl(ViewModel.Id));
}

private void CommentView_Loaded(object sender, System.Windows.RoutedEventArgs e)
Expand Down Expand Up @@ -56,5 +61,15 @@ private void buttonPanel_IsVisibleChanged(object sender, System.Windows.Dependen
BringIntoView();
}
}

void OpenHyperlink(object sender, ExecutedRoutedEventArgs e)
{
Uri uri;

if (Uri.TryCreate(e.Parameter?.ToString(), UriKind.Absolute, out uri))
{
GetBrowser().OpenUrl(uri);
}
}
}
}