Browse Source

add hyper links.

pull/3220/head
Dan Walmsley 7 years ago
parent
commit
868b125848
  1. 12
      src/Avalonia.Dialogs/AboutAvaloniaDialog.xaml
  2. 55
      src/Avalonia.Dialogs/AboutAvaloniaDialog.xaml.cs

12
src/Avalonia.Dialogs/AboutAvaloniaDialog.xaml

@ -73,6 +73,14 @@
<TextBlock Text="Development Build" Margin="0,-10,0,0" FontSize="15" Foreground="White" />
</StackPanel>
</StackPanel>
<TextBlock Text="" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="5" FontSize="15" />
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Center" Spacing="20" Margin="0 60 0 0">
<TextBlock Text="This product is built with the Avalonia cross platform UI Framework." TextWrapping="Wrap" HorizontalAlignment="Center" />
<Button Cursor="Hand" Background="Transparent" BorderThickness="0" Foreground="#419df2" Command="{Binding OpenGithub}" Content="https://github.com/AvaloniaUI/Avalonia" HorizontalAlignment="Center" />
<Button Cursor="Hand" Background="Transparent" BorderThickness="0" Foreground="#419df2" Command="{Binding OpenWebsite}" Content="https://www.avaloniaui.net/" HorizontalAlignment="Center" />
</StackPanel>
<StackPanel VerticalAlignment="Bottom">
<TextBlock Text="© 2019 AvaloniaUI OÜ (14839404)" TextWrapping="Wrap" HorizontalAlignment="Center" />
<TextBlock Text="" HorizontalAlignment="Right" Margin="5" FontSize="15" />
</StackPanel>
</Grid>
</Window>
</Window>

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

@ -1,6 +1,8 @@
// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Diagnostics;
using System.Runtime.InteropServices;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
@ -11,6 +13,59 @@ namespace Avalonia.Dialogs
public AboutAvaloniaDialog()
{
AvaloniaXamlLoader.Load(this);
DataContext = this;
}
public void OpenGithub ()
{
OpenBrowser("https://github.com/AvaloniaUI/Avalonia/");
}
public void OpenWebsite ()
{
OpenBrowser("https://avaloniaui.net/");
}
private static void OpenBrowser(string url)
{
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) ? $"-e {url}" : "",
CreateNoWindow = true,
UseShellExecute = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
});
}
}
private static void ShellExec(string cmd, bool waitForExit = true)
{
var escapedArgs = cmd.Replace("\"", "\\\"");
using var process = Process.Start(
new ProcessStartInfo
{
FileName = "/bin/sh",
Arguments = $"-c \"{escapedArgs}\"",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden
}
);
if (waitForExit)
{
process.WaitForExit();
}
}
}
}

Loading…
Cancel
Save