2017-12-26 17:54:13 +01:00
|
|
|
|
using System;
|
|
|
|
|
using Windows.UI.Xaml;
|
2020-04-22 16:21:47 +02:00
|
|
|
|
using GalaSoft.MvvmLight.Views;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2017-12-26 17:54:13 +01:00
|
|
|
|
using Microsoft.Xaml.Interactivity;
|
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.Actions
|
|
|
|
|
{
|
|
|
|
|
public class NavigateToUrlAction : DependencyObject, IAction
|
|
|
|
|
{
|
|
|
|
|
public string Url
|
|
|
|
|
{
|
|
|
|
|
get { return (string)GetValue(UrlProperty); }
|
|
|
|
|
set { SetValue(UrlProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty UrlProperty =
|
|
|
|
|
DependencyProperty.Register("Url", typeof(string), typeof(NavigateToUrlAction), new PropertyMetadata(string.Empty));
|
|
|
|
|
|
|
|
|
|
public object Execute(object sender, object parameter)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var uri = new Uri(Url);
|
|
|
|
|
return Windows.System.Launcher.LaunchUriAsync(uri).GetAwaiter().GetResult();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2020-04-22 16:21:47 +02:00
|
|
|
|
var dialogService = App.Services.GetRequiredService<IDialogService>();
|
|
|
|
|
dialogService.ShowError(ex, ex.Message, null, () => {}).Wait();
|
2017-12-26 17:54:13 +01:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|