HashCalculator.GUI/ShellLink.cs
2020-03-22 19:56:16 +01:00

30 lines
791 B
C#

using System.Diagnostics;
using System.Windows.Documents;
using System.Windows.Navigation;
using System.Diagnostics.CodeAnalysis;
namespace HashCalculator.GUI
{
/// <summary>
/// Opens <see cref="Hyperlink.NavigateUri"/> in a default system browser
/// </summary>
[SuppressMessage("Microsoft.Performance", "CA1812")]
internal sealed class ShellLink : Hyperlink
{
public ShellLink()
{
RequestNavigate += OnRequestNavigate;
}
private void OnRequestNavigate(object sender, RequestNavigateEventArgs e)
{
Process.Start(new ProcessStartInfo
{
FileName = e.Uri.AbsoluteUri,
UseShellExecute = true
});
e.Handled = true;
}
}
}