mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Devices - Added option to disable default layouts
This commit is contained in:
1 parent
fb3f7e0cc1
commit
cef37677f2
6 files changed
+117
-10
No files matched your search
@@ -0,0 +1,41 @@
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Navigation;
|
||||
using Artemis.Core;
|
||||
using Microsoft.Xaml.Behaviors;
|
||||
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a behavior that opens the URI of the hyperlink in the browser when requested
|
||||
/// </summary>
|
||||
public class OpenInBrowser : Behavior<Hyperlink>
|
||||
{
|
||||
private Hyperlink? _hyperLink;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnAttached()
|
||||
{
|
||||
base.OnAttached();
|
||||
|
||||
_hyperLink = AssociatedObject;
|
||||
if (_hyperLink == null)
|
||||
return;
|
||||
|
||||
_hyperLink.RequestNavigate += HyperLinkOnRequestNavigate;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnDetaching()
|
||||
{
|
||||
if (_hyperLink == null) return;
|
||||
_hyperLink.RequestNavigate -= HyperLinkOnRequestNavigate;
|
||||
|
||||
base.OnDetaching();
|
||||
}
|
||||
|
||||
private void HyperLinkOnRequestNavigate(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
Utilities.OpenUrl(e.Uri.AbsoluteUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user