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
cec2696fb9
@ -457,6 +457,7 @@ namespace Artemis.Core
|
|||||||
{
|
{
|
||||||
// Other properties are computed
|
// Other properties are computed
|
||||||
DeviceEntity.Id = Identifier;
|
DeviceEntity.Id = Identifier;
|
||||||
|
DeviceEntity.DeviceProvider = DeviceProvider.Plugin.Guid.ToString();
|
||||||
|
|
||||||
DeviceEntity.InputIdentifiers.Clear();
|
DeviceEntity.InputIdentifiers.Clear();
|
||||||
foreach (ArtemisDeviceInputIdentifier identifier in InputIdentifiers)
|
foreach (ArtemisDeviceInputIdentifier identifier in InputIdentifiers)
|
||||||
|
|||||||
@ -237,7 +237,7 @@ namespace Artemis.Core.Modules
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual DataModelPropertyAttribute GetDataModelDescription()
|
public virtual DataModelPropertyAttribute GetDataModelDescription()
|
||||||
{
|
{
|
||||||
return new() {Name = Plugin.Info.Name, Description = Plugin.Info.Description};
|
return new() {Name = Info.Name, Description = Info.Description};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -10,6 +10,7 @@ using Artemis.Core.DeviceProviders;
|
|||||||
using Artemis.Core.Ninject;
|
using Artemis.Core.Ninject;
|
||||||
using Artemis.Storage.Entities.General;
|
using Artemis.Storage.Entities.General;
|
||||||
using Artemis.Storage.Entities.Plugins;
|
using Artemis.Storage.Entities.Plugins;
|
||||||
|
using Artemis.Storage.Entities.Surface;
|
||||||
using Artemis.Storage.Repositories.Interfaces;
|
using Artemis.Storage.Repositories.Interfaces;
|
||||||
using McMaster.NETCore.Plugins;
|
using McMaster.NETCore.Plugins;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
@ -28,15 +29,17 @@ namespace Artemis.Core.Services
|
|||||||
private readonly IKernel _kernel;
|
private readonly IKernel _kernel;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IPluginRepository _pluginRepository;
|
private readonly IPluginRepository _pluginRepository;
|
||||||
|
private readonly IDeviceRepository _deviceRepository;
|
||||||
private readonly IQueuedActionRepository _queuedActionRepository;
|
private readonly IQueuedActionRepository _queuedActionRepository;
|
||||||
private readonly List<Plugin> _plugins;
|
private readonly List<Plugin> _plugins;
|
||||||
private bool _isElevated;
|
private bool _isElevated;
|
||||||
|
|
||||||
public PluginManagementService(IKernel kernel, ILogger logger, IPluginRepository pluginRepository, IQueuedActionRepository queuedActionRepository)
|
public PluginManagementService(IKernel kernel, ILogger logger, IPluginRepository pluginRepository, IDeviceRepository deviceRepository, IQueuedActionRepository queuedActionRepository)
|
||||||
{
|
{
|
||||||
_kernel = kernel;
|
_kernel = kernel;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_pluginRepository = pluginRepository;
|
_pluginRepository = pluginRepository;
|
||||||
|
_deviceRepository = deviceRepository;
|
||||||
_queuedActionRepository = queuedActionRepository;
|
_queuedActionRepository = queuedActionRepository;
|
||||||
_plugins = new List<Plugin>();
|
_plugins = new List<Plugin>();
|
||||||
|
|
||||||
@ -572,7 +575,11 @@ namespace Artemis.Core.Services
|
|||||||
{
|
{
|
||||||
if (plugin.IsEnabled)
|
if (plugin.IsEnabled)
|
||||||
throw new ArtemisCoreException("Cannot remove the settings of an enabled plugin");
|
throw new ArtemisCoreException("Cannot remove the settings of an enabled plugin");
|
||||||
|
|
||||||
_pluginRepository.RemoveSettings(plugin.Guid);
|
_pluginRepository.RemoveSettings(plugin.Guid);
|
||||||
|
foreach (DeviceEntity deviceEntity in _deviceRepository.GetAll().Where(e => e.DeviceProvider == plugin.Guid.ToString()))
|
||||||
|
_deviceRepository.Remove(deviceEntity);
|
||||||
|
|
||||||
plugin.Settings?.ClearSettings();
|
plugin.Settings?.ClearSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ namespace Artemis.Storage.Entities.Surface
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
public string DeviceProvider { get; set; }
|
||||||
public float X { get; set; }
|
public float X { get; set; }
|
||||||
public float Y { get; set; }
|
public float Y { get; set; }
|
||||||
public float Rotation { get; set; }
|
public float Rotation { get; set; }
|
||||||
|
|||||||
19
src/Artemis.UI/Services/Interfaces/IThemeService.cs
Normal file
19
src/Artemis.UI/Services/Interfaces/IThemeService.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using Artemis.UI.Events;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Services
|
||||||
|
{
|
||||||
|
public interface IThemeService : IArtemisUIService
|
||||||
|
{
|
||||||
|
WindowsTheme GetAppsTheme();
|
||||||
|
WindowsTheme GetSystemTheme();
|
||||||
|
event EventHandler<WindowsThemeEventArgs> AppsThemeChanged;
|
||||||
|
event EventHandler<WindowsThemeEventArgs> SystemThemeChanged;
|
||||||
|
|
||||||
|
enum WindowsTheme
|
||||||
|
{
|
||||||
|
Light,
|
||||||
|
Dark
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,32 +2,56 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Management;
|
using System.Management;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Artemis.Core;
|
using Artemis.Core;
|
||||||
using Artemis.Core.Services;
|
using Artemis.Core.Services;
|
||||||
using Artemis.UI.Events;
|
using Artemis.UI.Events;
|
||||||
using Artemis.UI.Screens.Settings.Tabs.General;
|
using Artemis.UI.Screens.Settings.Tabs.General;
|
||||||
using MaterialDesignThemes.Wpf;
|
using MaterialDesignThemes.Wpf;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace Artemis.UI.Services
|
namespace Artemis.UI.Services
|
||||||
{
|
{
|
||||||
public class ThemeService : IThemeService
|
public class ThemeService : IThemeService
|
||||||
{
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
private readonly PluginSetting<ApplicationColorScheme> _colorScheme;
|
private readonly PluginSetting<ApplicationColorScheme> _colorScheme;
|
||||||
private const string RegistryKeyPath = @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";
|
private const string RegistryKeyPath = @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";
|
||||||
|
|
||||||
private const string AppsThemeRegistryValueName = "AppsUseLightTheme";
|
private const string AppsThemeRegistryValueName = "AppsUseLightTheme";
|
||||||
private const string SystemThemeRegistryValueName = "SystemUsesLightTheme";
|
private const string SystemThemeRegistryValueName = "SystemUsesLightTheme";
|
||||||
|
|
||||||
public ThemeService(ISettingsService settingsService)
|
public ThemeService(ISettingsService settingsService, ILogger logger)
|
||||||
{
|
{
|
||||||
WatchTheme();
|
_logger = logger;
|
||||||
|
|
||||||
_colorScheme = settingsService.GetSetting("UI.ColorScheme", ApplicationColorScheme.Automatic);
|
_colorScheme = settingsService.GetSetting("UI.ColorScheme", ApplicationColorScheme.Automatic);
|
||||||
_colorScheme.SettingChanged += ColorSchemeOnSettingChanged;
|
_colorScheme.SettingChanged += ColorSchemeOnSettingChanged;
|
||||||
|
|
||||||
ApplyColorSchemeSetting();
|
|
||||||
AppsThemeChanged += OnAppsThemeChanged;
|
AppsThemeChanged += OnAppsThemeChanged;
|
||||||
|
|
||||||
|
Task.Run(Initialize);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Initialize()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
WatchTheme();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.Warning(e, "WatchTheme failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ApplyColorSchemeSetting();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.Warning(e, "ApplyColorSchemeSetting failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IThemeService.WindowsTheme GetAppsTheme()
|
public IThemeService.WindowsTheme GetAppsTheme()
|
||||||
@ -159,18 +183,4 @@ namespace Artemis.UI.Services
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IThemeService : IArtemisUIService
|
|
||||||
{
|
|
||||||
WindowsTheme GetAppsTheme();
|
|
||||||
WindowsTheme GetSystemTheme();
|
|
||||||
event EventHandler<WindowsThemeEventArgs> AppsThemeChanged;
|
|
||||||
event EventHandler<WindowsThemeEventArgs> SystemThemeChanged;
|
|
||||||
|
|
||||||
enum WindowsTheme
|
|
||||||
{
|
|
||||||
Light,
|
|
||||||
Dark
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user