Browse Source

Resolved the command error.

pull/11858/head
Mike James 3 years ago
parent
commit
f1bb1d0b09
  1. 7
      src/Avalonia.Dialogs/AboutAvaloniaDialog.xaml
  2. 43
      src/Avalonia.Dialogs/AboutAvaloniaDialog.xaml.cs

7
src/Avalonia.Dialogs/AboutAvaloniaDialog.xaml

@ -44,7 +44,6 @@
<TextBlock Text="v11"
FontWeight="Regular"
Foreground="#5B5B5B"
HorizontalAlignment="Center"
FontSize="14"
Grid.Row="2"/>
@ -57,9 +56,8 @@
TextWrapping="Wrap"/>
<TextBlock Grid.Row="1"
Text="Avalonia is made possible by the generous support if it's contributors and community"
Text="Avalonia is made possible by the generous support if it's contributors and community."
TextWrapping="Wrap"
Foreground="#5B5B5B"
Margin="0,15,0,0"/>
<Button Grid.Row="2" Background="#8B44AC"
@ -67,12 +65,11 @@
VerticalAlignment="Center"
Padding="12"
Content="Learn more about Avalonia"
Command="{Binding LearnMore}"
Click="Button_OnClick"
HorizontalAlignment="Center"/>
<TextBlock Grid.Row="4" VerticalAlignment="Bottom"
Text="{Binding Copyright}"
Foreground="#5B5B5B"
HorizontalAlignment="Center"/>
</Grid>
</Grid>

43
src/Avalonia.Dialogs/AboutAvaloniaDialog.xaml.cs

@ -3,6 +3,7 @@ using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace Avalonia.Dialogs
@ -23,26 +24,7 @@ namespace Avalonia.Dialogs
DataContext = this;
}
public static void LearnMore()
{
var url = "https://www.avaloniaui.net/";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
// If no associated application/json MimeType is found xdg-open opens retrun error
// but it tries to open it anyway using the console editor (nano, vim, other..)
ShellExec($"xdg-open {url}", waitForExit: false);
}
else
{
using Process process = Process.Start(new ProcessStartInfo
{
FileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? url : "open",
Arguments = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? $"{url}" : "",
CreateNoWindow = true,
UseShellExecute = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
});
}
}
private static void ShellExec(string cmd, bool waitForExit = true)
{
@ -67,5 +49,26 @@ namespace Avalonia.Dialogs
}
}
}
private void Button_OnClick(object sender, RoutedEventArgs e)
{
var url = "https://www.avaloniaui.net/";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
// If no associated application/json MimeType is found xdg-open opens retrun error
// but it tries to open it anyway using the console editor (nano, vim, other..)
ShellExec($"xdg-open {url}", waitForExit: false);
}
else
{
using Process process = Process.Start(new ProcessStartInfo
{
FileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? url : "open",
Arguments = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? $"{url}" : "",
CreateNoWindow = true,
UseShellExecute = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
});
}
}
}
}

Loading…
Cancel
Save