mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Merge pull request #484 from Artemis-RGB/issue-479
Core - Added utility for opening URLs in the default browser
This commit is contained in:
commit
3bbb04dd17
@ -17,7 +17,7 @@ namespace Artemis.Core
|
||||
/// <summary>
|
||||
/// The full path to the Artemis executable
|
||||
/// </summary>
|
||||
public static readonly string ExecutablePath = ApplicationUtilities.GetCurrentLocation();
|
||||
public static readonly string ExecutablePath = Utilities.GetCurrentLocation();
|
||||
|
||||
/// <summary>
|
||||
/// The full path to the Artemis data folder
|
||||
|
||||
@ -5,9 +5,9 @@ using Stylet;
|
||||
namespace Artemis.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides utilities to manage the application
|
||||
/// Provides a few general utilities for ease of use
|
||||
/// </summary>
|
||||
public static class ApplicationUtilities
|
||||
public static class Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Attempts to gracefully shut down the application with a delayed kill to ensure the application shut down
|
||||
@ -39,6 +39,21 @@ namespace Artemis.Core
|
||||
Execute.OnUIThread(() => Application.Current.Shutdown());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens the provided URL in the default web browser
|
||||
/// </summary>
|
||||
/// <param name="url">The URL to open</param>
|
||||
/// <returns>The process created to open the URL</returns>
|
||||
public static Process OpenUrl(string url)
|
||||
{
|
||||
ProcessStartInfo processInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = url,
|
||||
UseShellExecute = true
|
||||
};
|
||||
return Process.Start(processInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current application location
|
||||
/// </summary>
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Stylet;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Home
|
||||
{
|
||||
@ -13,12 +11,7 @@ namespace Artemis.UI.Screens.Home
|
||||
|
||||
public void OpenUrl(string url)
|
||||
{
|
||||
// Don't open anything but valid URIs
|
||||
if (Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute))
|
||||
{
|
||||
url = url.Replace("&", "^&");
|
||||
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") {CreateNoWindow = true});
|
||||
}
|
||||
Core.Utilities.OpenUrl(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,7 +131,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
|
||||
// Give the logger a chance to write, might not always be enough but oh well
|
||||
await Task.Delay(500);
|
||||
ApplicationUtilities.Shutdown(2, true);
|
||||
Core.Utilities.Shutdown(2, true);
|
||||
}
|
||||
|
||||
private PackIconKind GetIconKind()
|
||||
@ -227,7 +227,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
|
||||
// Give the logger a chance to write, might not always be enough but oh well
|
||||
await Task.Delay(500);
|
||||
ApplicationUtilities.Shutdown(2, true);
|
||||
Core.Utilities.Shutdown(2, true);
|
||||
}
|
||||
|
||||
NotifyOfPropertyChange(nameof(IsEnabled));
|
||||
|
||||
@ -68,7 +68,7 @@ namespace Artemis.UI.Screens
|
||||
|
||||
public void TrayExit()
|
||||
{
|
||||
ApplicationUtilities.Shutdown(2, false);
|
||||
Core.Utilities.Shutdown(2, false);
|
||||
}
|
||||
|
||||
public void TrayOpenDebugger()
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Navigation;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.LayerEffects;
|
||||
|
||||
namespace Artemis.Plugins.LayerEffects.Filter.ViewModels
|
||||
@ -12,12 +13,9 @@ namespace Artemis.Plugins.LayerEffects.Filter.ViewModels
|
||||
|
||||
public ColorMatrixEffectProperties Properties { get; set; }
|
||||
|
||||
public void OpenGuide()
|
||||
public void OpenHyperlink(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
Process.Start(new ProcessStartInfo("cmd", "/c start https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/effects/color-filters")
|
||||
{
|
||||
CreateNoWindow = true
|
||||
});
|
||||
Utilities.OpenUrl(e.Uri.AbsoluteUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -16,7 +16,7 @@
|
||||
<TextBlock TextWrapping="Wrap" Margin="0 25">
|
||||
If you are still not deterred,
|
||||
<Hyperlink NavigateUri="https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/effects/color-filters"
|
||||
RequestNavigate="{s:Action OpenGuide}">
|
||||
RequestNavigate="{s:Action OpenHyperlink}">
|
||||
click here
|
||||
</Hyperlink>
|
||||
for a full explanation of color transforms in SkiaSharp, the rendering library Artemis uses.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user