mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Merge branch 'development'
This commit is contained in:
commit
ea8972a415
@ -178,12 +178,15 @@ namespace Artemis.Core
|
|||||||
{
|
{
|
||||||
foreach (PluginFeature feature in Features)
|
foreach (PluginFeature feature in Features)
|
||||||
feature.Dispose();
|
feature.Dispose();
|
||||||
|
SetEnabled(false);
|
||||||
|
|
||||||
Kernel?.Dispose();
|
Kernel?.Dispose();
|
||||||
PluginLoader?.Dispose();
|
PluginLoader?.Dispose();
|
||||||
|
|
||||||
|
GC.Collect();
|
||||||
|
GC.WaitForPendingFinalizers();
|
||||||
|
|
||||||
_features.Clear();
|
_features.Clear();
|
||||||
SetEnabled(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,6 +70,12 @@ namespace Artemis.Core.Services
|
|||||||
/// <returns>The resulting plugin</returns>
|
/// <returns>The resulting plugin</returns>
|
||||||
Plugin ImportPlugin(string fileName);
|
Plugin ImportPlugin(string fileName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unloads and permanently removes the provided plugin
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plugin">The plugin to remove</param>
|
||||||
|
void RemovePlugin(Plugin plugin);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enables the provided plugin feature
|
/// Enables the provided plugin feature
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -5,6 +5,7 @@ using System.IO;
|
|||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Runtime.Loader;
|
||||||
using Artemis.Core.DeviceProviders;
|
using Artemis.Core.DeviceProviders;
|
||||||
using Artemis.Core.Ninject;
|
using Artemis.Core.Ninject;
|
||||||
using Artemis.Storage.Entities.Plugins;
|
using Artemis.Storage.Entities.Plugins;
|
||||||
@ -275,6 +276,7 @@ namespace Artemis.Core.Services
|
|||||||
plugin.PluginLoader = PluginLoader.CreateFromAssemblyFile(mainFile!, configure =>
|
plugin.PluginLoader = PluginLoader.CreateFromAssemblyFile(mainFile!, configure =>
|
||||||
{
|
{
|
||||||
configure.IsUnloadable = true;
|
configure.IsUnloadable = true;
|
||||||
|
configure.LoadInMemory = true;
|
||||||
configure.PreferSharedTypes = true;
|
configure.PreferSharedTypes = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -430,7 +432,6 @@ namespace Artemis.Core.Services
|
|||||||
OnPluginDisabled(new PluginEventArgs(plugin));
|
OnPluginDisabled(new PluginEventArgs(plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public Plugin ImportPlugin(string fileName)
|
public Plugin ImportPlugin(string fileName)
|
||||||
{
|
{
|
||||||
DirectoryInfo pluginDirectory = new(Path.Combine(Constants.DataFolder, "plugins"));
|
DirectoryInfo pluginDirectory = new(Path.Combine(Constants.DataFolder, "plugins"));
|
||||||
@ -449,7 +450,16 @@ namespace Artemis.Core.Services
|
|||||||
|
|
||||||
Plugin? existing = _plugins.FirstOrDefault(p => p.Guid == pluginInfo.Guid);
|
Plugin? existing = _plugins.FirstOrDefault(p => p.Guid == pluginInfo.Guid);
|
||||||
if (existing != null)
|
if (existing != null)
|
||||||
throw new ArtemisPluginException($"A plugin with the same GUID is already loaded: {existing.Info}");
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RemovePlugin(existing);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new ArtemisPluginException("A plugin with the same GUID is already loaded, failed to remove old version", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
string targetDirectory = pluginInfo.Main.Split(".dll")[0].Replace("/", "").Replace("\\", "");
|
string targetDirectory = pluginInfo.Main.Split(".dll")[0].Replace("/", "").Replace("\\", "");
|
||||||
string uniqueTargetDirectory = targetDirectory;
|
string uniqueTargetDirectory = targetDirectory;
|
||||||
@ -464,19 +474,38 @@ namespace Artemis.Core.Services
|
|||||||
|
|
||||||
// Extract everything in the same archive directory to the unique plugin directory
|
// Extract everything in the same archive directory to the unique plugin directory
|
||||||
DirectoryInfo directoryInfo = new(Path.Combine(pluginDirectory.FullName, uniqueTargetDirectory));
|
DirectoryInfo directoryInfo = new(Path.Combine(pluginDirectory.FullName, uniqueTargetDirectory));
|
||||||
Directory.CreateDirectory(directoryInfo.FullName);
|
Utilities.CreateAccessibleDirectory(directoryInfo.FullName);
|
||||||
string metaDataDirectory = metaDataFileEntry.FullName.Replace(metaDataFileEntry.Name, "");
|
string metaDataDirectory = metaDataFileEntry.FullName.Replace(metaDataFileEntry.Name, "");
|
||||||
foreach (ZipArchiveEntry zipArchiveEntry in archive.Entries)
|
foreach (ZipArchiveEntry zipArchiveEntry in archive.Entries)
|
||||||
|
{
|
||||||
if (zipArchiveEntry.FullName.StartsWith(metaDataDirectory))
|
if (zipArchiveEntry.FullName.StartsWith(metaDataDirectory))
|
||||||
{
|
{
|
||||||
string target = Path.Combine(directoryInfo.FullName, zipArchiveEntry.FullName.Remove(0, metaDataDirectory.Length));
|
string target = Path.Combine(directoryInfo.FullName, zipArchiveEntry.FullName.Remove(0, metaDataDirectory.Length));
|
||||||
zipArchiveEntry.ExtractToFile(target);
|
// Create folders
|
||||||
|
if (zipArchiveEntry.FullName.EndsWith("/"))
|
||||||
|
Utilities.CreateAccessibleDirectory(Path.GetDirectoryName(target)!);
|
||||||
|
// Extract files
|
||||||
|
else
|
||||||
|
zipArchiveEntry.ExtractToFile(target);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Load the newly extracted plugin and return the result
|
// Load the newly extracted plugin and return the result
|
||||||
return LoadPlugin(directoryInfo);
|
return LoadPlugin(directoryInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RemovePlugin(Plugin plugin)
|
||||||
|
{
|
||||||
|
DirectoryInfo directory = plugin.Directory;
|
||||||
|
lock (_plugins)
|
||||||
|
{
|
||||||
|
if (_plugins.Contains(plugin))
|
||||||
|
UnloadPlugin(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
directory.Delete(true);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Features
|
#region Features
|
||||||
|
|||||||
@ -74,7 +74,7 @@ namespace Artemis.Core.Services
|
|||||||
_modifyingProviders = true;
|
_modifyingProviders = true;
|
||||||
|
|
||||||
List<ArtemisDevice> toRemove = _devices.Where(a => deviceProvider.Devices.Any(d => a.RgbDevice == d)).ToList();
|
List<ArtemisDevice> toRemove = _devices.Where(a => deviceProvider.Devices.Any(d => a.RgbDevice == d)).ToList();
|
||||||
Surface.Detach(deviceProvider.Devices);
|
Surface.Detach(toRemove.Select(d => d.RgbDevice));
|
||||||
foreach (ArtemisDevice device in toRemove)
|
foreach (ArtemisDevice device in toRemove)
|
||||||
RemoveDevice(device);
|
RemoveDevice(device);
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ namespace Artemis.Core.Services
|
|||||||
_modifyingProviders = true;
|
_modifyingProviders = true;
|
||||||
|
|
||||||
List<ArtemisDevice> toRemove = _devices.Where(a => deviceProvider.Devices.Any(d => a.RgbDevice == d)).ToList();
|
List<ArtemisDevice> toRemove = _devices.Where(a => deviceProvider.Devices.Any(d => a.RgbDevice == d)).ToList();
|
||||||
Surface.Detach(deviceProvider.Devices);
|
Surface.Detach(toRemove.Select(d => d.RgbDevice));
|
||||||
foreach (ArtemisDevice device in toRemove)
|
foreach (ArtemisDevice device in toRemove)
|
||||||
RemoveDevice(device);
|
RemoveDevice(device);
|
||||||
|
|
||||||
|
|||||||
@ -79,6 +79,11 @@ namespace Artemis.Core.Services.Models
|
|||||||
public void Arrange(List<ArtemisDevice> devices)
|
public void Arrange(List<ArtemisDevice> devices)
|
||||||
{
|
{
|
||||||
ArrangedDevices.Clear();
|
ArrangedDevices.Clear();
|
||||||
|
|
||||||
|
// Not much to do here
|
||||||
|
if (!devices.Any())
|
||||||
|
return;
|
||||||
|
|
||||||
foreach (ArtemisDevice surfaceDevice in devices)
|
foreach (ArtemisDevice surfaceDevice in devices)
|
||||||
{
|
{
|
||||||
surfaceDevice.X = 0;
|
surfaceDevice.X = 0;
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Artemis.Core.Services
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides data about endpoint exception related events
|
||||||
|
/// </summary>
|
||||||
|
public class EndpointExceptionEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
internal EndpointExceptionEventArgs(Exception exception)
|
||||||
|
{
|
||||||
|
Exception = exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the exception that occurred
|
||||||
|
/// </summary>
|
||||||
|
public Exception Exception { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -52,15 +52,37 @@ namespace Artemis.Core.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? Returns { get; protected set; }
|
public string? Returns { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs whenever a request threw an unhandled exception
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler<EndpointExceptionEventArgs>? RequestException;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called whenever the end point has to process a request
|
/// Called whenever the end point has to process a request
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The HTTP context of the request</param>
|
/// <param name="context">The HTTP context of the request</param>
|
||||||
protected abstract Task ProcessRequest(IHttpContext context);
|
protected abstract Task ProcessRequest(IHttpContext context);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invokes the <see cref="RequestException" /> event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">The exception that occurred during the request</param>
|
||||||
|
protected virtual void OnRequestException(Exception e)
|
||||||
|
{
|
||||||
|
RequestException?.Invoke(this, new EndpointExceptionEventArgs(e));
|
||||||
|
}
|
||||||
|
|
||||||
internal async Task InternalProcessRequest(IHttpContext context)
|
internal async Task InternalProcessRequest(IHttpContext context)
|
||||||
{
|
{
|
||||||
await ProcessRequest(context);
|
try
|
||||||
|
{
|
||||||
|
await ProcessRequest(context);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
OnRequestException(e);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDisabled(object? sender, EventArgs e)
|
private void OnDisabled(object? sender, EventArgs e)
|
||||||
|
|||||||
@ -1,10 +1,7 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using EmbedIO;
|
using EmbedIO;
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Artemis.Core.Services
|
namespace Artemis.Core.Services
|
||||||
{
|
{
|
||||||
@ -67,6 +64,12 @@ namespace Artemis.Core.Services
|
|||||||
if (!endPoints.TryGetValue(pathParts[1], out PluginEndPoint? endPoint))
|
if (!endPoints.TryGetValue(pathParts[1], out PluginEndPoint? endPoint))
|
||||||
throw HttpException.NotFound($"Found no endpoint called {pathParts[1]} for plugin with ID {pathParts[0]}.");
|
throw HttpException.NotFound($"Found no endpoint called {pathParts[1]} for plugin with ID {pathParts[0]}.");
|
||||||
|
|
||||||
|
// If Accept-Charset contains a wildcard, remove the header so we default to UTF8
|
||||||
|
// This is a workaround for an EmbedIO ehh issue
|
||||||
|
string? acceptCharset = context.Request.Headers["Accept-Charset"];
|
||||||
|
if (acceptCharset != null && acceptCharset.Contains("*"))
|
||||||
|
context.Request.Headers.Remove("Accept-Charset");
|
||||||
|
|
||||||
// It is up to the registration how the request is eventually handled, it might even set a response here
|
// It is up to the registration how the request is eventually handled, it might even set a response here
|
||||||
await endPoint.InternalProcessRequest(context);
|
await endPoint.InternalProcessRequest(context);
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,6 @@ namespace Artemis.Core.Services
|
|||||||
_webServerPortSetting.SettingChanged += WebServerPortSettingOnSettingChanged;
|
_webServerPortSetting.SettingChanged += WebServerPortSettingOnSettingChanged;
|
||||||
|
|
||||||
PluginsModule = new PluginsModule("/plugins");
|
PluginsModule = new PluginsModule("/plugins");
|
||||||
|
|
||||||
StartWebServer();
|
StartWebServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +41,7 @@ namespace Artemis.Core.Services
|
|||||||
Server?.Dispose();
|
Server?.Dispose();
|
||||||
Server = null;
|
Server = null;
|
||||||
|
|
||||||
string url = $"http://localhost:{_webServerPortSetting.Value}/";
|
string url = $"http://*:{_webServerPortSetting.Value}/";
|
||||||
WebApiModule apiModule = new("/api/", JsonNetSerializer);
|
WebApiModule apiModule = new("/api/", JsonNetSerializer);
|
||||||
PluginsModule.ServerUrl = url;
|
PluginsModule.ServerUrl = url;
|
||||||
WebServer server = new WebServer(o => o.WithUrlPrefix(url).WithMode(HttpListenerMode.EmbedIO))
|
WebServer server = new WebServer(o => o.WithUrlPrefix(url).WithMode(HttpListenerMode.EmbedIO))
|
||||||
|
|||||||
@ -138,7 +138,7 @@
|
|||||||
<PackageReference Include="FluentValidation" Version="9.3.0" />
|
<PackageReference Include="FluentValidation" Version="9.3.0" />
|
||||||
<PackageReference Include="Flurl.Http" Version="3.0.1" />
|
<PackageReference Include="Flurl.Http" Version="3.0.1" />
|
||||||
<PackageReference Include="gong-wpf-dragdrop" Version="2.3.2" />
|
<PackageReference Include="gong-wpf-dragdrop" Version="2.3.2" />
|
||||||
<PackageReference Include="Hardcodet.NotifyIcon.Wpf.NetCore" Version="1.0.14" />
|
<PackageReference Include="Hardcodet.NotifyIcon.Wpf.NetCore" Version="1.0.18" />
|
||||||
<PackageReference Include="Humanizer.Core" Version="2.8.26" />
|
<PackageReference Include="Humanizer.Core" Version="2.8.26" />
|
||||||
<PackageReference Include="MaterialDesignExtensions" Version="3.3.0-a01" />
|
<PackageReference Include="MaterialDesignExtensions" Version="3.3.0-a01" />
|
||||||
<PackageReference Include="MaterialDesignThemes" Version="3.2.0" />
|
<PackageReference Include="MaterialDesignThemes" Version="3.2.0" />
|
||||||
|
|||||||
@ -59,12 +59,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
|||||||
{
|
{
|
||||||
Items.Clear();
|
Items.Clear();
|
||||||
await Task.Delay(200);
|
await Task.Delay(200);
|
||||||
_instances = _pluginManagementService.GetAllPlugins()
|
GetPluginInstances();
|
||||||
.Select(p => _settingsVmFactory.CreatePluginSettingsViewModel(p))
|
|
||||||
.OrderBy(i => i.Plugin.Info.Name)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
UpdatePluginSearch();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
base.OnActivate();
|
base.OnActivate();
|
||||||
@ -80,14 +75,21 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
|||||||
{
|
{
|
||||||
Plugin plugin = _pluginManagementService.ImportPlugin(dialog.FileName);
|
Plugin plugin = _pluginManagementService.ImportPlugin(dialog.FileName);
|
||||||
|
|
||||||
_instances = _pluginManagementService.GetAllPlugins()
|
GetPluginInstances();
|
||||||
.Select(p => _settingsVmFactory.CreatePluginSettingsViewModel(p))
|
|
||||||
.OrderBy(i => i.Plugin.Info.Name)
|
|
||||||
.ToList();
|
|
||||||
SearchPluginInput = plugin.Info.Name;
|
SearchPluginInput = plugin.Info.Name;
|
||||||
|
|
||||||
_messageService.ShowMessage($"Imported plugin: {plugin.Info.Name}");
|
_messageService.ShowMessage($"Imported plugin: {plugin.Info.Name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void GetPluginInstances()
|
||||||
|
{
|
||||||
|
_instances = _pluginManagementService.GetAllPlugins()
|
||||||
|
.Select(p => _settingsVmFactory.CreatePluginSettingsViewModel(p))
|
||||||
|
.OrderBy(i => i.Plugin.Info.Name)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
UpdatePluginSearch();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,15 +53,28 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
<Button Grid.Row="1"
|
<StackPanel Grid.Row="1"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<Button
|
||||||
VerticalAlignment="Bottom"
|
VerticalAlignment="Bottom"
|
||||||
Style="{StaticResource MaterialDesignOutlinedButton}"
|
Style="{StaticResource MaterialDesignOutlinedButton}"
|
||||||
ToolTip="Open the plugins settings window"
|
ToolTip="Open the plugins settings window"
|
||||||
Margin="4"
|
Margin="4"
|
||||||
Command="{s:Action OpenSettings}">
|
Command="{s:Action OpenSettings}">
|
||||||
SETTINGS
|
SETTINGS
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Style="{StaticResource MaterialDesignOutlinedButton}"
|
||||||
|
ToolTip="Remove plugin"
|
||||||
|
Margin="4"
|
||||||
|
Command="{s:Action Remove}">
|
||||||
|
<materialDesign:PackIcon Kind="DeleteForever" />
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
<CheckBox Grid.Row="1"
|
<CheckBox Grid.Row="1"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
@ -70,7 +83,13 @@
|
|||||||
Margin="8"
|
Margin="8"
|
||||||
Visibility="{Binding Enabling, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}"
|
Visibility="{Binding Enabling, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}"
|
||||||
Style="{StaticResource MaterialDesignCheckBox}" IsChecked="{Binding IsEnabled}">
|
Style="{StaticResource MaterialDesignCheckBox}" IsChecked="{Binding IsEnabled}">
|
||||||
Plugin enabled
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock>Plugin enabled</TextBlock>
|
||||||
|
<materialDesign:PackIcon Kind="ShieldHalfFull"
|
||||||
|
Margin="5 0 0 0"
|
||||||
|
ToolTip="Plugin requires admin rights"
|
||||||
|
Visibility="{Binding Plugin.Info.RequiresAdmin, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"/>
|
||||||
|
</StackPanel>
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
|
|
||||||
<ProgressBar Grid.Row="1"
|
<ProgressBar Grid.Row="1"
|
||||||
|
|||||||
@ -19,6 +19,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
|||||||
private readonly IDialogService _dialogService;
|
private readonly IDialogService _dialogService;
|
||||||
private readonly IPluginManagementService _pluginManagementService;
|
private readonly IPluginManagementService _pluginManagementService;
|
||||||
private readonly ISettingsVmFactory _settingsVmFactory;
|
private readonly ISettingsVmFactory _settingsVmFactory;
|
||||||
|
private readonly ICoreService _coreService;
|
||||||
private readonly IMessageService _messageService;
|
private readonly IMessageService _messageService;
|
||||||
private readonly IWindowManager _windowManager;
|
private readonly IWindowManager _windowManager;
|
||||||
private bool _enabling;
|
private bool _enabling;
|
||||||
@ -26,6 +27,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
|||||||
|
|
||||||
public PluginSettingsViewModel(Plugin plugin,
|
public PluginSettingsViewModel(Plugin plugin,
|
||||||
ISettingsVmFactory settingsVmFactory,
|
ISettingsVmFactory settingsVmFactory,
|
||||||
|
ICoreService coreService,
|
||||||
IWindowManager windowManager,
|
IWindowManager windowManager,
|
||||||
IDialogService dialogService,
|
IDialogService dialogService,
|
||||||
IPluginManagementService pluginManagementService,
|
IPluginManagementService pluginManagementService,
|
||||||
@ -34,6 +36,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
|||||||
Plugin = plugin;
|
Plugin = plugin;
|
||||||
|
|
||||||
_settingsVmFactory = settingsVmFactory;
|
_settingsVmFactory = settingsVmFactory;
|
||||||
|
_coreService = coreService;
|
||||||
_windowManager = windowManager;
|
_windowManager = windowManager;
|
||||||
_dialogService = dialogService;
|
_dialogService = dialogService;
|
||||||
_pluginManagementService = pluginManagementService;
|
_pluginManagementService = pluginManagementService;
|
||||||
@ -82,6 +85,24 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task Remove()
|
||||||
|
{
|
||||||
|
bool confirmed = await _dialogService.ShowConfirmDialog("Delete plugin", "Are you sure you want to delete this plugin?");
|
||||||
|
if (!confirmed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_pluginManagementService.RemovePlugin(Plugin);
|
||||||
|
((PluginSettingsTabViewModel) Parent).GetPluginInstances();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_dialogService.ShowExceptionDialog("Failed to remove plugin", e);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ShowLogsFolder()
|
public void ShowLogsFolder()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -124,6 +145,18 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
|||||||
{
|
{
|
||||||
Enabling = true;
|
Enabling = true;
|
||||||
|
|
||||||
|
if (Plugin.Info.RequiresAdmin && !_coreService.IsElevated)
|
||||||
|
{
|
||||||
|
bool confirmed = await _dialogService.ShowConfirmDialog("Enable plugin", "This plugin requires admin rights, are you sure you want to enable it?");
|
||||||
|
if (!confirmed)
|
||||||
|
{
|
||||||
|
Enabling = false;
|
||||||
|
NotifyOfPropertyChange(nameof(IsEnabled));
|
||||||
|
NotifyOfPropertyChange(nameof(CanOpenSettings));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await Task.Run(() => _pluginManagementService.EnablePlugin(Plugin, true));
|
await Task.Run(() => _pluginManagementService.EnablePlugin(Plugin, true));
|
||||||
|
|||||||
@ -1,24 +1,25 @@
|
|||||||
<controls:MaterialWindow x:Class="Artemis.UI.Screens.TrayView"
|
<Window x:Class="Artemis.UI.Screens.TrayView"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||||
xmlns:s="https://github.com/canton7/Stylet"
|
xmlns:s="https://github.com/canton7/Stylet"
|
||||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
xmlns:controls="clr-namespace:MaterialDesignExtensions.Controls;assembly=MaterialDesignExtensions"
|
mc:Ignorable="d">
|
||||||
mc:Ignorable="d"
|
<tb:TaskbarIcon IconSource="/Resources/Images/Logo/logo-512.ico"
|
||||||
Title="Artemis"
|
|
||||||
Height="1"
|
|
||||||
Width="1"
|
|
||||||
Visibility="Hidden">
|
|
||||||
<tb:TaskbarIcon x:Name="TrayIcon"
|
|
||||||
IconSource="/Resources/Images/Logo/logo-512.ico"
|
|
||||||
MenuActivation="LeftOrRightClick"
|
MenuActivation="LeftOrRightClick"
|
||||||
PopupActivation="DoubleClick"
|
PopupActivation="DoubleClick"
|
||||||
ToolTipText="Artemis"
|
|
||||||
DoubleClickCommand="{s:Action TrayBringToForeground}"
|
DoubleClickCommand="{s:Action TrayBringToForeground}"
|
||||||
TrayBalloonTipClicked="{s:Action OnTrayBalloonTipClicked}">
|
TrayBalloonTipClicked="{s:Action OnTrayBalloonTipClicked}">
|
||||||
|
|
||||||
|
<tb:TaskbarIcon.TrayToolTip>
|
||||||
|
<Border Background="{DynamicResource MaterialDesignToolTipBackground}" CornerRadius="2" Padding="5">
|
||||||
|
<TextBlock Foreground="{DynamicResource MaterialDesignPaper}">
|
||||||
|
Artemis
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</tb:TaskbarIcon.TrayToolTip>
|
||||||
<tb:TaskbarIcon.ContextMenu>
|
<tb:TaskbarIcon.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem Header="Home" Command="{s:Action TrayActivateSidebarItem}" CommandParameter="Home">
|
<MenuItem Header="Home" Command="{s:Action TrayActivateSidebarItem}" CommandParameter="Home">
|
||||||
@ -60,4 +61,4 @@
|
|||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</tb:TaskbarIcon.ContextMenu>
|
</tb:TaskbarIcon.ContextMenu>
|
||||||
</tb:TaskbarIcon>
|
</tb:TaskbarIcon>
|
||||||
</controls:MaterialWindow>
|
</Window>
|
||||||
@ -27,9 +27,13 @@
|
|||||||
},
|
},
|
||||||
"Hardcodet.NotifyIcon.Wpf.NetCore": {
|
"Hardcodet.NotifyIcon.Wpf.NetCore": {
|
||||||
"type": "Direct",
|
"type": "Direct",
|
||||||
"requested": "[1.0.14, )",
|
"requested": "[1.0.18, )",
|
||||||
"resolved": "1.0.14",
|
"resolved": "1.0.18",
|
||||||
"contentHash": "aNwwax4+C/xhIxTbwKHJnxh0A6hWGnqXZtppZ+/lkE8VOL+a2WuMOBgWpkiUk6Tv+pi1bc+yuHo0lh4Md6KEFw=="
|
"contentHash": "oI8YY/gUQooA0XIIZl4TgueexJcu+MbSvCQ2+ZBZRa+rIvFCWiyk8rjgywQ17sVrhLXRn+xF8+FTrWLxetkx0A==",
|
||||||
|
"dependencies": {
|
||||||
|
"H.NotifyIcon": "1.0.18",
|
||||||
|
"System.Drawing.Common": "5.0.0"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"Humanizer.Core": {
|
"Humanizer.Core": {
|
||||||
"type": "Direct",
|
"type": "Direct",
|
||||||
@ -225,6 +229,11 @@
|
|||||||
"resolved": "3.0.1",
|
"resolved": "3.0.1",
|
||||||
"contentHash": "i7CuPSikVroBaWG8sPvO707Ex9C6BP5+r4JufKNU1FGMmiFgLJvNo1ttUg6ZiXIzUNknvIb1VUTIO9iEDucibg=="
|
"contentHash": "i7CuPSikVroBaWG8sPvO707Ex9C6BP5+r4JufKNU1FGMmiFgLJvNo1ttUg6ZiXIzUNknvIb1VUTIO9iEDucibg=="
|
||||||
},
|
},
|
||||||
|
"H.NotifyIcon": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "1.0.18",
|
||||||
|
"contentHash": "vV0lNWD9xGeCH4pCmT8vKtax2QOmo8WwhCBgBDO3BYQtPG7Rjuf5Ua+3O8++XkZB7t9zromzxcT5nYdGDg1Puw=="
|
||||||
|
},
|
||||||
"HidSharp": {
|
"HidSharp": {
|
||||||
"type": "Transitive",
|
"type": "Transitive",
|
||||||
"resolved": "2.1.0",
|
"resolved": "2.1.0",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user