|
|
|
@ -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(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|