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
|
||||
DeviceEntity.Id = Identifier;
|
||||
DeviceEntity.DeviceProvider = DeviceProvider.Plugin.Guid.ToString();
|
||||
|
||||
DeviceEntity.InputIdentifiers.Clear();
|
||||
foreach (ArtemisDeviceInputIdentifier identifier in InputIdentifiers)
|
||||
|
||||
@ -237,7 +237,7 @@ namespace Artemis.Core.Modules
|
||||
/// <returns></returns>
|
||||
public virtual DataModelPropertyAttribute GetDataModelDescription()
|
||||
{
|
||||
return new() {Name = Plugin.Info.Name, Description = Plugin.Info.Description};
|
||||
return new() {Name = Info.Name, Description = Info.Description};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -10,6 +10,7 @@ using Artemis.Core.DeviceProviders;
|
||||
using Artemis.Core.Ninject;
|
||||
using Artemis.Storage.Entities.General;
|
||||
using Artemis.Storage.Entities.Plugins;
|
||||
using Artemis.Storage.Entities.Surface;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using McMaster.NETCore.Plugins;
|
||||
using Ninject;
|
||||
@ -28,15 +29,17 @@ namespace Artemis.Core.Services
|
||||
private readonly IKernel _kernel;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPluginRepository _pluginRepository;
|
||||
private readonly IDeviceRepository _deviceRepository;
|
||||
private readonly IQueuedActionRepository _queuedActionRepository;
|
||||
private readonly List<Plugin> _plugins;
|
||||
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;
|
||||
_logger = logger;
|
||||
_pluginRepository = pluginRepository;
|
||||
_deviceRepository = deviceRepository;
|
||||
_queuedActionRepository = queuedActionRepository;
|
||||
_plugins = new List<Plugin>();
|
||||
|
||||
@ -572,7 +575,11 @@ namespace Artemis.Core.Services
|
||||
{
|
||||
if (plugin.IsEnabled)
|
||||
throw new ArtemisCoreException("Cannot remove the settings of an enabled plugin");
|
||||
|
||||
_pluginRepository.RemoveSettings(plugin.Guid);
|
||||
foreach (DeviceEntity deviceEntity in _deviceRepository.GetAll().Where(e => e.DeviceProvider == plugin.Guid.ToString()))
|
||||
_deviceRepository.Remove(deviceEntity);
|
||||
|
||||
plugin.Settings?.ClearSettings();
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ namespace Artemis.Storage.Entities.Surface
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string DeviceProvider { get; set; }
|
||||
public float X { get; set; }
|
||||
public float Y { 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.Management;
|
||||
using System.Security.Principal;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Events;
|
||||
using Artemis.UI.Screens.Settings.Tabs.General;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Microsoft.Win32;
|
||||
using Serilog;
|
||||
|
||||
namespace Artemis.UI.Services
|
||||
{
|
||||
public class ThemeService : IThemeService
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly PluginSetting<ApplicationColorScheme> _colorScheme;
|
||||
private const string RegistryKeyPath = @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";
|
||||
|
||||
private const string AppsThemeRegistryValueName = "AppsUseLightTheme";
|
||||
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.SettingChanged += ColorSchemeOnSettingChanged;
|
||||
|
||||
ApplyColorSchemeSetting();
|
||||
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()
|
||||
@ -123,7 +147,7 @@ namespace Artemis.UI.Services
|
||||
object registryValueObject = key?.GetValue(themeKeyName);
|
||||
if (registryValueObject == null) return IThemeService.WindowsTheme.Light;
|
||||
|
||||
int registryValue = (int) registryValueObject;
|
||||
int registryValue = (int)registryValueObject;
|
||||
|
||||
return registryValue > 0 ? IThemeService.WindowsTheme.Light : IThemeService.WindowsTheme.Dark;
|
||||
}
|
||||
@ -159,18 +183,4 @@ namespace Artemis.UI.Services
|
||||
|
||||
#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