mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 13:28:33 +00:00
Merge branch 'development'
This commit is contained in:
commit
524296e4e9
2
.github/workflows/docfx.yml
vendored
2
.github/workflows/docfx.yml
vendored
@ -33,4 +33,4 @@ jobs:
|
||||
username: ${{ secrets.FTP_USER }}
|
||||
password: ${{ secrets.FTP_PASSWORD }}
|
||||
local-dir: docfx/docfx_project/_site/
|
||||
server-dir: /httpdocs/docs/
|
||||
server-dir: /docs/
|
||||
|
||||
@ -158,7 +158,16 @@ public class DataModelPath : IStorageModel, IDisposable
|
||||
if (_disposed)
|
||||
throw new ObjectDisposedException("DataModelPath");
|
||||
|
||||
return Segments.LastOrDefault()?.GetPropertyType();
|
||||
// Prefer the actual type from the segments
|
||||
Type? segmentType = Segments.LastOrDefault()?.GetPropertyType();
|
||||
if (segmentType != null)
|
||||
return segmentType;
|
||||
|
||||
// Fall back to stored type
|
||||
if (!string.IsNullOrWhiteSpace(Entity.Type))
|
||||
return Type.GetType(Entity.Type);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -358,9 +367,14 @@ public class DataModelPath : IStorageModel, IDisposable
|
||||
// Do not save an invalid state
|
||||
if (!IsValid)
|
||||
return;
|
||||
|
||||
|
||||
Entity.Path = Path;
|
||||
Entity.DataModelId = DataModelId;
|
||||
|
||||
// Store the type name but only if available
|
||||
Type? pathType = Segments.LastOrDefault()?.GetPropertyType();
|
||||
if (pathType != null)
|
||||
Entity.Type = pathType.FullName;
|
||||
}
|
||||
|
||||
#region Equality members
|
||||
|
||||
150
src/Artemis.Core/Utilities/StringUtilities.cs
Normal file
150
src/Artemis.Core/Utilities/StringUtilities.cs
Normal file
@ -0,0 +1,150 @@
|
||||
using System.Text;
|
||||
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Provides some random string utilities.
|
||||
/// </summary>
|
||||
public static class StringUtilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Produces optional, URL-friendly version of a title, "like-this-one".
|
||||
/// hand-tuned for speed, reflects performance refactoring contributed
|
||||
/// by John Gietzen (user otac0n)
|
||||
/// </summary>
|
||||
/// <remarks>Source: https://stackoverflow.com/a/25486</remarks>
|
||||
public static string UrlFriendly(string? title)
|
||||
{
|
||||
if (title == null) return "";
|
||||
|
||||
const int maxlen = 80;
|
||||
int len = title.Length;
|
||||
bool prevdash = false;
|
||||
StringBuilder sb = new(len);
|
||||
char c;
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
c = title[i];
|
||||
if ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'))
|
||||
{
|
||||
sb.Append(c);
|
||||
prevdash = false;
|
||||
}
|
||||
else if (c >= 'A' && c <= 'Z')
|
||||
{
|
||||
// tricky way to convert to lowercase
|
||||
sb.Append((char) (c | 32));
|
||||
prevdash = false;
|
||||
}
|
||||
else if (c == ' ' || c == ',' || c == '.' || c == '/' ||
|
||||
c == '\\' || c == '-' || c == '_' || c == '=')
|
||||
{
|
||||
if (!prevdash && sb.Length > 0)
|
||||
{
|
||||
sb.Append('-');
|
||||
prevdash = true;
|
||||
}
|
||||
}
|
||||
else if (c >= 128)
|
||||
{
|
||||
int prevlen = sb.Length;
|
||||
sb.Append(RemapInternationalCharToAscii(c));
|
||||
if (prevlen != sb.Length) prevdash = false;
|
||||
}
|
||||
|
||||
if (i == maxlen) break;
|
||||
}
|
||||
|
||||
if (prevdash)
|
||||
return sb.ToString().Substring(0, sb.Length - 1);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remaps internation characters to their ASCII equivalent.
|
||||
/// <remarks>Source: https://meta.stackexchange.com/a/7696</remarks>
|
||||
/// </summary>
|
||||
/// <param name="c">The character to remap</param>
|
||||
/// <returns>The ASCII equivalent.</returns>
|
||||
public static string RemapInternationalCharToAscii(char c)
|
||||
{
|
||||
string s = c.ToString().ToLowerInvariant();
|
||||
if ("àåáâäãåą".Contains(s))
|
||||
{
|
||||
return "a";
|
||||
}
|
||||
else if ("èéêëę".Contains(s))
|
||||
{
|
||||
return "e";
|
||||
}
|
||||
else if ("ìíîïı".Contains(s))
|
||||
{
|
||||
return "i";
|
||||
}
|
||||
else if ("òóôõöøőð".Contains(s))
|
||||
{
|
||||
return "o";
|
||||
}
|
||||
else if ("ùúûüŭů".Contains(s))
|
||||
{
|
||||
return "u";
|
||||
}
|
||||
else if ("çćčĉ".Contains(s))
|
||||
{
|
||||
return "c";
|
||||
}
|
||||
else if ("żźž".Contains(s))
|
||||
{
|
||||
return "z";
|
||||
}
|
||||
else if ("śşšŝ".Contains(s))
|
||||
{
|
||||
return "s";
|
||||
}
|
||||
else if ("ñń".Contains(s))
|
||||
{
|
||||
return "n";
|
||||
}
|
||||
else if ("ýÿ".Contains(s))
|
||||
{
|
||||
return "y";
|
||||
}
|
||||
else if ("ğĝ".Contains(s))
|
||||
{
|
||||
return "g";
|
||||
}
|
||||
else if (c == 'ř')
|
||||
{
|
||||
return "r";
|
||||
}
|
||||
else if (c == 'ł')
|
||||
{
|
||||
return "l";
|
||||
}
|
||||
else if (c == 'đ')
|
||||
{
|
||||
return "d";
|
||||
}
|
||||
else if (c == 'ß')
|
||||
{
|
||||
return "ss";
|
||||
}
|
||||
else if (c == 'Þ')
|
||||
{
|
||||
return "th";
|
||||
}
|
||||
else if (c == 'ĥ')
|
||||
{
|
||||
return "h";
|
||||
}
|
||||
else if (c == 'ĵ')
|
||||
{
|
||||
return "j";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,4 +4,5 @@ public class DataModelPathEntity
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public string DataModelId { get; set; }
|
||||
public string Type { get; set; }
|
||||
}
|
||||
21
src/Artemis.UI.Shared/Providers/IProtocolProvider.cs
Normal file
21
src/Artemis.UI.Shared/Providers/IProtocolProvider.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Artemis.UI.Shared.Providers;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a provider associating with a custom protocol, e.g. artemis://
|
||||
/// </summary>
|
||||
public interface IProtocolProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Associate Artemis with the provided custom protocol.
|
||||
/// </summary>
|
||||
/// <param name="protocol">The protocol to associate Artemis with.</param>
|
||||
Task AssociateWithProtocol(string protocol);
|
||||
|
||||
/// <summary>
|
||||
/// Disassociate Artemis with the provided custom protocol.
|
||||
/// </summary>
|
||||
/// <param name="protocol">The protocol to disassociate Artemis with.</param>
|
||||
Task DisassociateWithProtocol(string protocol);
|
||||
}
|
||||
@ -72,6 +72,7 @@ internal class Router : CorePropertyChanged, IRouter, IDisposable
|
||||
/// <inheritdoc />
|
||||
public async Task Navigate(string path, RouterNavigationOptions? options = null)
|
||||
{
|
||||
path = path.ToLower().Trim(' ', '/', '\\');
|
||||
options ??= new RouterNavigationOptions();
|
||||
|
||||
// Routing takes place on the UI thread with processing heavy tasks offloaded by the router itself
|
||||
|
||||
@ -74,6 +74,9 @@ public class App : Application
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
string? route = (ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.Args?.FirstOrDefault(a => a.Contains("route"));
|
||||
route = route?.Split("artemis://")[1];
|
||||
string url = File.ReadAllText(Path.Combine(Constants.DataFolder, "webserver.txt"));
|
||||
using HttpClient client = new();
|
||||
try
|
||||
@ -81,7 +84,7 @@ public class App : Application
|
||||
CancellationTokenSource cts = new();
|
||||
cts.CancelAfter(2000);
|
||||
|
||||
HttpResponseMessage httpResponseMessage = client.Send(new HttpRequestMessage(HttpMethod.Post, url + "remote/bring-to-foreground"), cts.Token);
|
||||
HttpResponseMessage httpResponseMessage = client.Send(new HttpRequestMessage(HttpMethod.Post, url + "remote/bring-to-foreground") {Content = new StringContent(route ?? "")}, cts.Token);
|
||||
httpResponseMessage.EnsureSuccessStatusCode();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -24,5 +24,6 @@ public static class UIContainerExtensions
|
||||
container.Register<IAutoRunProvider, AutoRunProvider>();
|
||||
container.Register<InputProvider, WindowsInputProvider>(serviceKey: WindowsInputProvider.Id);
|
||||
container.Register<IUpdateNotificationProvider, WindowsUpdateNotificationProvider>();
|
||||
container.Register<IProtocolProvider, ProtocolProvider>();
|
||||
}
|
||||
}
|
||||
34
src/Artemis.UI.Windows/Providers/ProtocolProvider.cs
Normal file
34
src/Artemis.UI.Windows/Providers/ProtocolProvider.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Providers;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Artemis.UI.Windows.Providers;
|
||||
|
||||
public class ProtocolProvider : IProtocolProvider
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public async Task AssociateWithProtocol(string protocol)
|
||||
{
|
||||
string key = $"HKEY_CURRENT_USER\\Software\\Classes\\{protocol}";
|
||||
Registry.SetValue($"{key}", null, "URL:artemis protocol");
|
||||
Registry.SetValue($"{key}", "URL Protocol", "");
|
||||
Registry.SetValue($"{key}\\DefaultIcon", null, $"\"{Constants.ExecutablePath}\",1");
|
||||
Registry.SetValue($"{key}\\shell\\open\\command", null, $"\"{Constants.ExecutablePath}\", \"--route=%1\"");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task DisassociateWithProtocol(string protocol)
|
||||
{
|
||||
try
|
||||
{
|
||||
string key = $"HKEY_CURRENT_USER\\Software\\Classes\\{protocol}";
|
||||
Registry.CurrentUser.DeleteSubKeyTree(key);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
// Ignore errors (which means that the protocol wasn't associated before)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.UI.Shared.Services.MainWindow;
|
||||
using Avalonia.Threading;
|
||||
using EmbedIO;
|
||||
@ -13,11 +15,13 @@ public class RemoteController : WebApiController
|
||||
{
|
||||
private readonly ICoreService _coreService;
|
||||
private readonly IMainWindowService _mainWindowService;
|
||||
private readonly IRouter _router;
|
||||
|
||||
public RemoteController(ICoreService coreService, IMainWindowService mainWindowService)
|
||||
public RemoteController(ICoreService coreService, IMainWindowService mainWindowService, IRouter router)
|
||||
{
|
||||
_coreService = coreService;
|
||||
_mainWindowService = mainWindowService;
|
||||
_router = router;
|
||||
}
|
||||
|
||||
[Route(HttpVerbs.Any, "/status")]
|
||||
@ -29,7 +33,15 @@ public class RemoteController : WebApiController
|
||||
[Route(HttpVerbs.Post, "/remote/bring-to-foreground")]
|
||||
public void PostBringToForeground()
|
||||
{
|
||||
Dispatcher.UIThread.Post(() => _mainWindowService.OpenMainWindow());
|
||||
using StreamReader reader = new(Request.InputStream);
|
||||
string route = reader.ReadToEnd();
|
||||
|
||||
Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(route))
|
||||
await _router.Navigate(route);
|
||||
_mainWindowService.OpenMainWindow();
|
||||
});
|
||||
}
|
||||
|
||||
[Route(HttpVerbs.Post, "/remote/restart")]
|
||||
|
||||
@ -14,6 +14,7 @@ using Artemis.UI.Shared.Routing;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.MainWindow;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Threading;
|
||||
using ReactiveUI;
|
||||
@ -181,6 +182,9 @@ public class RootViewModel : RoutableHostScreen<RoutableScreen>, IMainWindowProv
|
||||
}
|
||||
|
||||
_lifeTime.MainWindow.Activate();
|
||||
if (_lifeTime.MainWindow.WindowState == WindowState.Minimized)
|
||||
_lifeTime.MainWindow.WindowState = WindowState.Normal;
|
||||
|
||||
OnMainWindowOpened();
|
||||
}
|
||||
|
||||
|
||||
@ -45,6 +45,19 @@
|
||||
</Grid>
|
||||
<Border Classes="card-separator" />
|
||||
|
||||
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock>Associate with Artemis links</TextBlock>
|
||||
<TextBlock Classes="subtitle" TextWrapping="Wrap">
|
||||
Open Artemis when navigating to artemis:// links, allows opening workshop entries from your browser.
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<ToggleSwitch IsChecked="{CompiledBinding UIUseProtocol.Value}" OnContent="Yes" OffContent="No" MinWidth="0" Margin="0 -10" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Border Classes="card-separator"/>
|
||||
|
||||
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto" IsVisible="{CompiledBinding IsWindows11}">
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock>Enable Mica effect</TextBlock>
|
||||
@ -57,7 +70,7 @@
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Border Classes="card-separator" IsVisible="{CompiledBinding IsWindows11}"/>
|
||||
|
||||
|
||||
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock>Startup delay</TextBlock>
|
||||
|
||||
@ -29,6 +29,7 @@ namespace Artemis.UI.Screens.Settings;
|
||||
public class GeneralTabViewModel : RoutableScreen
|
||||
{
|
||||
private readonly IAutoRunProvider? _autoRunProvider;
|
||||
private readonly IProtocolProvider? _protocolProvider;
|
||||
private readonly IDebugService _debugService;
|
||||
private readonly PluginSetting<LayerBrushReference> _defaultLayerBrushDescriptor;
|
||||
private readonly INotificationService _notificationService;
|
||||
@ -52,6 +53,7 @@ public class GeneralTabViewModel : RoutableScreen
|
||||
_updateService = updateService;
|
||||
_notificationService = notificationService;
|
||||
_autoRunProvider = container.Resolve<IAutoRunProvider>(IfUnresolved.ReturnDefault);
|
||||
_protocolProvider = container.Resolve<IProtocolProvider>(IfUnresolved.ReturnDefault);
|
||||
|
||||
List<LayerBrushProvider> layerBrushProviders = pluginManagementService.GetFeaturesOfType<LayerBrushProvider>();
|
||||
List<IGraphicsContextProvider> graphicsContextProviders = container.Resolve<List<IGraphicsContextProvider>>();
|
||||
@ -74,13 +76,16 @@ public class GeneralTabViewModel : RoutableScreen
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
UIAutoRun.SettingChanged += UIAutoRunOnSettingChanged;
|
||||
UIUseProtocol.SettingChanged += UIUseProtocolOnSettingChanged;
|
||||
UIAutoRunDelay.SettingChanged += UIAutoRunDelayOnSettingChanged;
|
||||
EnableMica.SettingChanged += EnableMicaOnSettingChanged;
|
||||
|
||||
Dispatcher.UIThread.InvokeAsync(ApplyAutoRun);
|
||||
Dispatcher.UIThread.Invoke(ApplyProtocolAssociation);
|
||||
Disposable.Create(() =>
|
||||
{
|
||||
UIAutoRun.SettingChanged -= UIAutoRunOnSettingChanged;
|
||||
UIUseProtocol.SettingChanged -= UIUseProtocolOnSettingChanged;
|
||||
UIAutoRunDelay.SettingChanged -= UIAutoRunDelayOnSettingChanged;
|
||||
EnableMica.SettingChanged -= EnableMicaOnSettingChanged;
|
||||
|
||||
@ -148,6 +153,7 @@ public class GeneralTabViewModel : RoutableScreen
|
||||
}
|
||||
|
||||
public PluginSetting<bool> UIAutoRun => _settingsService.GetSetting("UI.AutoRun", false);
|
||||
public PluginSetting<bool> UIUseProtocol => _settingsService.GetSetting("UI.UseProtocol", true);
|
||||
public PluginSetting<int> UIAutoRunDelay => _settingsService.GetSetting("UI.AutoRunDelay", 15);
|
||||
public PluginSetting<bool> UIShowOnStartup => _settingsService.GetSetting("UI.ShowOnStartup", true);
|
||||
public PluginSetting<bool> EnableMica => _settingsService.GetSetting("UI.EnableMica", true);
|
||||
@ -223,11 +229,34 @@ public class GeneralTabViewModel : RoutableScreen
|
||||
_windowService.ShowExceptionDialog("Failed to apply auto-run", exception);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyProtocolAssociation()
|
||||
{
|
||||
if (_protocolProvider == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
if (UIUseProtocol.Value)
|
||||
_protocolProvider.AssociateWithProtocol("artemis");
|
||||
else
|
||||
_protocolProvider.DisassociateWithProtocol("artemis");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
_windowService.ShowExceptionDialog("Failed to apply protocol association", exception);
|
||||
}
|
||||
}
|
||||
|
||||
private async void UIAutoRunOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
await ApplyAutoRun();
|
||||
}
|
||||
|
||||
private void UIUseProtocolOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
ApplyProtocolAssociation();
|
||||
}
|
||||
|
||||
private async void UIAutoRunDelayOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
@ -20,6 +20,7 @@ namespace Artemis.UI.Screens.StartupWizard;
|
||||
public class StartupWizardViewModel : DialogViewModelBase<bool>
|
||||
{
|
||||
private readonly IAutoRunProvider? _autoRunProvider;
|
||||
private readonly IProtocolProvider? _protocolProvider;
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IWindowService _windowService;
|
||||
@ -39,6 +40,7 @@ public class StartupWizardViewModel : DialogViewModelBase<bool>
|
||||
_rgbService = rgbService;
|
||||
_windowService = windowService;
|
||||
_autoRunProvider = container.Resolve<IAutoRunProvider>(IfUnresolved.ReturnDefault);
|
||||
_protocolProvider = container.Resolve<IProtocolProvider>(IfUnresolved.ReturnDefault);
|
||||
|
||||
Continue = ReactiveCommand.Create(ExecuteContinue);
|
||||
GoBack = ReactiveCommand.Create(ExecuteGoBack);
|
||||
@ -58,11 +60,13 @@ public class StartupWizardViewModel : DialogViewModelBase<bool>
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
UIAutoRun.SettingChanged += UIAutoRunOnSettingChanged;
|
||||
UIUseProtocol.SettingChanged += UIUseProtocolOnSettingChanged;
|
||||
UIAutoRunDelay.SettingChanged += UIAutoRunDelayOnSettingChanged;
|
||||
|
||||
Disposable.Create(() =>
|
||||
{
|
||||
UIAutoRun.SettingChanged -= UIAutoRunOnSettingChanged;
|
||||
UIUseProtocol.SettingChanged -= UIUseProtocolOnSettingChanged;
|
||||
UIAutoRunDelay.SettingChanged -= UIAutoRunDelayOnSettingChanged;
|
||||
|
||||
_settingsService.SaveAllSettings();
|
||||
@ -81,6 +85,7 @@ public class StartupWizardViewModel : DialogViewModelBase<bool>
|
||||
public bool IsAutoRunSupported => _autoRunProvider != null;
|
||||
|
||||
public PluginSetting<bool> UIAutoRun => _settingsService.GetSetting("UI.AutoRun", false);
|
||||
public PluginSetting<bool> UIUseProtocol => _settingsService.GetSetting("UI.UseProtocol", true);
|
||||
public PluginSetting<int> UIAutoRunDelay => _settingsService.GetSetting("UI.AutoRunDelay", 15);
|
||||
public PluginSetting<bool> UIShowOnStartup => _settingsService.GetSetting("UI.ShowOnStartup", true);
|
||||
public PluginSetting<bool> UICheckForUpdates => _settingsService.GetSetting("UI.Updating.AutoCheck", true);
|
||||
@ -177,11 +182,34 @@ public class StartupWizardViewModel : DialogViewModelBase<bool>
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyProtocolAssociation()
|
||||
{
|
||||
if (_protocolProvider == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
if (UIUseProtocol.Value)
|
||||
_protocolProvider.AssociateWithProtocol("artemis");
|
||||
else
|
||||
_protocolProvider.DisassociateWithProtocol("artemis");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
_windowService.ShowExceptionDialog("Failed to apply protocol association", exception);
|
||||
}
|
||||
}
|
||||
|
||||
private async void UIAutoRunOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
await ApplyAutoRun();
|
||||
}
|
||||
|
||||
private void UIUseProtocolOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
ApplyProtocolAssociation();
|
||||
}
|
||||
|
||||
private async void UIAutoRunDelayOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (_autoRunProvider == null || !UIAutoRun.Value)
|
||||
|
||||
@ -42,6 +42,19 @@
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Border Classes="card-separator" />
|
||||
|
||||
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock>Associate with Artemis links</TextBlock>
|
||||
<TextBlock Classes="subtitle" TextWrapping="Wrap">
|
||||
Open Artemis when navigating to artemis:// links, allows opening workshop entries from your browser.
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<ToggleSwitch IsChecked="{CompiledBinding UIUseProtocol.Value}" OnContent="Yes" OffContent="No" MinWidth="0" Margin="0 -10" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Border Classes="card-separator"/>
|
||||
|
||||
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
|
||||
<StackPanel Grid.Column="0">
|
||||
|
||||
@ -22,14 +22,24 @@
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Margin="0 0 10 0" Spacing="10">
|
||||
<Border Classes="card" VerticalAlignment="Top">
|
||||
<StackPanel>
|
||||
<Border CornerRadius="6"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="0 0 10 0"
|
||||
Width="80"
|
||||
Height="80"
|
||||
ClipToBounds="True">
|
||||
<Image Stretch="UniformToFill" il:ImageLoader.Source="{CompiledBinding Entry.Id, Converter={StaticResource EntryIconUriConverter}, Mode=OneWay}" />
|
||||
</Border>
|
||||
<Panel>
|
||||
<Border CornerRadius="6"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="0 0 10 0"
|
||||
Width="80"
|
||||
Height="80"
|
||||
ClipToBounds="True">
|
||||
<Image Stretch="UniformToFill" il:ImageLoader.Source="{CompiledBinding Entry.Id, Converter={StaticResource EntryIconUriConverter}, Mode=OneWay}" />
|
||||
</Border>
|
||||
<Button Classes="icon-button"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Right"
|
||||
Command="{CompiledBinding CopyShareLink}"
|
||||
ToolTip.Tip="Copy share link">
|
||||
<avalonia:MaterialIcon Kind="ShareVariant"/>
|
||||
</Button>
|
||||
</Panel>
|
||||
|
||||
|
||||
<TextBlock Theme="{StaticResource TitleTextBlockStyle}"
|
||||
MaxLines="3"
|
||||
|
||||
@ -3,6 +3,7 @@ using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Screens.Workshop.Parameters;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.UI.Shared.Services;
|
||||
@ -21,8 +22,8 @@ public class ProfileDetailsViewModel : RoutableScreen<WorkshopDetailParameters>
|
||||
private readonly IWorkshopClient _client;
|
||||
private readonly ProfileEntryInstallationHandler _installationHandler;
|
||||
private readonly INotificationService _notificationService;
|
||||
private readonly IWindowService _windowService;
|
||||
private readonly ObservableAsPropertyHelper<DateTimeOffset?> _updatedAt;
|
||||
private readonly IWindowService _windowService;
|
||||
private IGetEntryById_Entry? _entry;
|
||||
|
||||
public ProfileDetailsViewModel(IWorkshopClient client, ProfileEntryInstallationHandler installationHandler, INotificationService notificationService, IWindowService windowService)
|
||||
@ -34,8 +35,11 @@ public class ProfileDetailsViewModel : RoutableScreen<WorkshopDetailParameters>
|
||||
_updatedAt = this.WhenAnyValue(vm => vm.Entry).Select(e => e?.LatestRelease?.CreatedAt ?? e?.CreatedAt).ToProperty(this, vm => vm.UpdatedAt);
|
||||
|
||||
DownloadLatestRelease = ReactiveCommand.CreateFromTask(ExecuteDownloadLatestRelease);
|
||||
CopyShareLink = ReactiveCommand.CreateFromTask(ExecuteCopyShareLink);
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> CopyShareLink { get; set; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> DownloadLatestRelease { get; }
|
||||
|
||||
public DateTimeOffset? UpdatedAt => _updatedAt.Value;
|
||||
@ -75,4 +79,13 @@ public class ProfileDetailsViewModel : RoutableScreen<WorkshopDetailParameters>
|
||||
else
|
||||
_notificationService.CreateNotification().WithTitle("Failed to install profile").WithMessage(result.Message).WithSeverity(NotificationSeverity.Error).Show();
|
||||
}
|
||||
|
||||
private async Task ExecuteCopyShareLink(CancellationToken arg)
|
||||
{
|
||||
if (Entry == null)
|
||||
return;
|
||||
|
||||
await Shared.UI.Clipboard.SetTextAsync($"{WorkshopConstants.WORKSHOP_URL}/entries/{Entry.Id}/{StringUtilities.UrlFriendly(Entry.Name)}");
|
||||
_notificationService.CreateNotification().WithTitle("Copied share link to clipboard.").Show();
|
||||
}
|
||||
}
|
||||
@ -38,9 +38,9 @@ public class BooleanBranchNode : Node
|
||||
|
||||
private void InputPinConnected(object? sender, SingleValueEventArgs<IPin> e)
|
||||
{
|
||||
if (TrueInput.ConnectedTo.Any() && !FalseInput.ConnectedTo.Any())
|
||||
if (TrueInput.ConnectedTo.Any())
|
||||
ChangeType(TrueInput.ConnectedTo.First().Type);
|
||||
if (FalseInput.ConnectedTo.Any() && !TrueInput.ConnectedTo.Any())
|
||||
else if (FalseInput.ConnectedTo.Any())
|
||||
ChangeType(FalseInput.ConnectedTo.First().Type);
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ public class DataModelEventCycleNodeCustomViewModel : CustomNodeViewModel
|
||||
|
||||
// Subscribe to node changes
|
||||
_cycleNode.WhenAnyValue(n => n.Storage).Subscribe(UpdateDataModelPath).DisposeWith(d);
|
||||
this.WhenAnyValue(vm => vm.DataModelPath).Subscribe(ApplyDataModelPath).DisposeWith(d);
|
||||
this.WhenAnyValue(vm => vm.DataModelPath).WhereNotNull().Subscribe(ApplyDataModelPath).DisposeWith(d);
|
||||
|
||||
Disposable.Create(() =>
|
||||
{
|
||||
@ -82,18 +82,18 @@ public class DataModelEventCycleNodeCustomViewModel : CustomNodeViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyDataModelPath(DataModelPath? path)
|
||||
private void ApplyDataModelPath(DataModelPath path)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_updating)
|
||||
return;
|
||||
if (path?.Path == _cycleNode.Storage?.Path)
|
||||
if (path.Path == _cycleNode.Storage?.Path)
|
||||
return;
|
||||
|
||||
_updating = true;
|
||||
|
||||
path?.Save();
|
||||
path.Save();
|
||||
_nodeEditorService.ExecuteCommand(Script, new UpdateStorage<DataModelPathEntity>(_cycleNode, path?.Entity, "event"));
|
||||
}
|
||||
finally
|
||||
|
||||
@ -44,7 +44,7 @@ public class DataModelEventNodeCustomViewModel : CustomNodeViewModel
|
||||
|
||||
// Subscribe to node changes
|
||||
_node.WhenAnyValue(n => n.Storage).Subscribe(UpdateDataModelPath).DisposeWith(d);
|
||||
this.WhenAnyValue(vm => vm.DataModelPath).Subscribe(ApplyDataModelPath).DisposeWith(d);
|
||||
this.WhenAnyValue(vm => vm.DataModelPath).WhereNotNull().Subscribe(ApplyDataModelPath).DisposeWith(d);
|
||||
|
||||
Disposable.Create(() =>
|
||||
{
|
||||
@ -89,18 +89,18 @@ public class DataModelEventNodeCustomViewModel : CustomNodeViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyDataModelPath(DataModelPath? path)
|
||||
private void ApplyDataModelPath(DataModelPath path)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_updating)
|
||||
return;
|
||||
if (path?.Path == _node.Storage?.Path)
|
||||
if (path.Path == _node.Storage?.Path)
|
||||
return;
|
||||
|
||||
_updating = true;
|
||||
|
||||
path?.Save();
|
||||
path.Save();
|
||||
_nodeEditorService.ExecuteCommand(Script, new UpdateStorage<DataModelPathEntity>(_node, path?.Entity, "event"));
|
||||
}
|
||||
finally
|
||||
|
||||
@ -41,7 +41,7 @@ public class DataModelNodeCustomViewModel : CustomNodeViewModel
|
||||
|
||||
// Subscribe to node changes
|
||||
_node.WhenAnyValue(n => n.Storage).Subscribe(UpdateDataModelPath).DisposeWith(d);
|
||||
this.WhenAnyValue(vm => vm.DataModelPath).Subscribe(ApplyDataModelPath).DisposeWith(d);
|
||||
this.WhenAnyValue(vm => vm.DataModelPath).WhereNotNull().Subscribe(ApplyDataModelPath).DisposeWith(d);
|
||||
|
||||
Disposable.Create(() =>
|
||||
{
|
||||
@ -86,18 +86,18 @@ public class DataModelNodeCustomViewModel : CustomNodeViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyDataModelPath(DataModelPath? path)
|
||||
private void ApplyDataModelPath(DataModelPath path)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_updating)
|
||||
return;
|
||||
if (path?.Path == _node.Storage?.Path)
|
||||
if (path.Path == _node.Storage?.Path)
|
||||
return;
|
||||
|
||||
_updating = true;
|
||||
|
||||
path?.Save();
|
||||
path.Save();
|
||||
_nodeEditorService.ExecuteCommand(Script, new UpdateStorage<DataModelPathEntity>(_node, path?.Entity, "path"));
|
||||
}
|
||||
finally
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user