mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Added artemis:// protocol support
This commit is contained in:
1 parent
9bf38f54a8
commit
0a5cc6955e
12 files changed
+162
-5
No files matched your search
@@ -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)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user