Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 51b09af

Browse files
committed
open urls in WhatsNew page with external browser
1 parent 3ac8b51 commit 51b09af

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

adrilight/View/SettingsWindowComponents/WhatsNew.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</UserControl.Resources>
2121
<Grid>
2222
<materialDesign:Card Margin="4 4 4 4" Width="900" VerticalAlignment="Stretch" Height="auto">
23-
<WebBrowser x:Name="browser"></WebBrowser>
23+
<WebBrowser x:Name="browser" Navigating="Browser_Navigating"></WebBrowser>
2424
</materialDesign:Card>
2525
</Grid>
2626
</UserControl>

adrilight/View/SettingsWindowComponents/WhatsNew.xaml.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using adrilight.ViewModel;
22
using System;
33
using System.Collections.Generic;
4+
using System.Diagnostics;
45
using System.Linq;
56
using System.Text;
67
using System.Threading.Tasks;
@@ -21,10 +22,13 @@ namespace adrilight.View.SettingsWindowComponents
2122
/// </summary>
2223
public partial class WhatsNew : UserControl
2324
{
25+
public SettingsViewModel SettingsViewModel { get; }
26+
2427
public WhatsNew(SettingsViewModel settingsViewModel)
2528
{
2629
InitializeComponent();
27-
browser.Source = settingsViewModel.WhatsNewUrl;
30+
SettingsViewModel = settingsViewModel ?? throw new ArgumentNullException(nameof(settingsViewModel));
31+
browser.Source = SettingsViewModel.WhatsNewUrl;
2832
}
2933

3034

@@ -44,5 +48,16 @@ public WhatsNewSetupSelectableViewPart(Lazy<WhatsNew> lazyContent)
4448

4549
public object Content => lazyContent.Value;
4650
}
51+
52+
private void Browser_Navigating(object sender, NavigatingCancelEventArgs e)
53+
{
54+
var isWhatsNewUrl = e.Uri == SettingsViewModel.WhatsNewUrl;
55+
56+
if (!isWhatsNewUrl)
57+
{
58+
e.Cancel = true;
59+
Process.Start(e.Uri.AbsoluteUri);
60+
}
61+
}
4762
}
4863
}

0 commit comments

Comments
 (0)