Profile editor - Only save profile on drag-edit when mouse is released

Profile editor - Format all numbers with 3 decimals 
Profile editor - Fixed drag-edit rounding errors with very small steps
Logging - Output logs to debug
Settings - Added logging level setting
Nuget - Updated Serilog and the used sinks
This commit is contained in:
Robert committed 2020-02-19 17:17:35 +01:00
1 parent 05cf1f0b53
commit 318a679744
26 files changed
+323 -161

No files matched your search

+16 -1
View File
@@ -4,12 +4,15 @@ using System.Threading.Tasks;
using Artemis.Core.Events;
using Artemis.Core.Exceptions;
using Artemis.Core.JsonConverters;
using Artemis.Core.Ninject;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces;
using Artemis.Core.Services.Storage.Interfaces;
using Newtonsoft.Json;
using RGB.NET.Core;
using Serilog;
using Serilog.Events;
using SkiaSharp;
namespace Artemis.Core.Services
@@ -25,16 +28,21 @@ namespace Artemis.Core.Services
private readonly IRgbService _rgbService;
private readonly ISurfaceService _surfaceService;
private List<Module> _modules;
private PluginSetting<LogEventLevel> _loggingLevel;
internal CoreService(ILogger logger, IPluginService pluginService, IRgbService rgbService, ISurfaceService surfaceService, IProfileService profileService)
internal CoreService(ILogger logger, ISettingsService settingsService, IPluginService pluginService, IRgbService rgbService,
ISurfaceService surfaceService, IProfileService profileService)
{
_logger = logger;
_pluginService = pluginService;
_rgbService = rgbService;
_surfaceService = surfaceService;
_profileService = profileService;
_loggingLevel = settingsService.GetSetting("Core.LoggingLevel", LogEventLevel.Information);
_rgbService.Surface.Updating += SurfaceOnUpdating;
_rgbService.Surface.Updated += SurfaceOnUpdated;
_loggingLevel.SettingChanged += (sender, args) => ApplyLoggingLevel();
_modules = _pluginService.GetPluginsOfType<Module>();
_pluginService.PluginEnabled += (sender, args) => _modules = _pluginService.GetPluginsOfType<Module>();
@@ -79,6 +87,7 @@ namespace Artemis.Core.Services
throw new ArtemisCoreException("Cannot initialize the core as it is already initialized.");
_logger.Information("Initializing Artemis Core version {version}", typeof(CoreService).Assembly.GetName().Version);
ApplyLoggingLevel();
// Initialize the services
await Task.Run(() => _pluginService.CopyBuiltInPlugins());
@@ -95,6 +104,12 @@ namespace Artemis.Core.Services
OnInitialized();
}
private void ApplyLoggingLevel()
{
_logger.Information("Setting logging level to {loggingLevel}", _loggingLevel.Value);
LoggerProvider.LoggingLevelSwitch.MinimumLevel = _loggingLevel.Value;
}
private void SurfaceOnUpdating(UpdatingEventArgs args)
{
try
@@ -10,6 +10,7 @@ using Artemis.Core.Services.Storage.Interfaces;
using Artemis.Storage.Entities.Profile;
using Artemis.Storage.Repositories.Interfaces;
using Newtonsoft.Json;
using Serilog;
namespace Artemis.Core.Services.Storage
{
@@ -19,12 +20,14 @@ namespace Artemis.Core.Services.Storage
public class ProfileService : IProfileService
{
private readonly ILayerService _layerService;
private readonly ILogger _logger;
private readonly IPluginService _pluginService;
private readonly IProfileRepository _profileRepository;
private readonly ISurfaceService _surfaceService;
internal ProfileService(IPluginService pluginService, ISurfaceService surfaceService, ILayerService layerService, IProfileRepository profileRepository)
internal ProfileService(ILogger logger, IPluginService pluginService, ISurfaceService surfaceService, ILayerService layerService, IProfileRepository profileRepository)
{
_logger = logger;
_pluginService = pluginService;
_surfaceService = surfaceService;
_layerService = layerService;
@@ -121,7 +124,10 @@ namespace Artemis.Core.Services.Storage
public void UndoUpdateProfile(Profile profile, ProfileModule module)
{
if (!profile.UndoStack.Any())
{
_logger.Debug("Undo profile update - Failed, undo stack empty");
return;
}
ActivateProfile(module, null);
var top = profile.UndoStack.Pop();
@@ -130,12 +136,17 @@ namespace Artemis.Core.Services.Storage
profile.ProfileEntity = JsonConvert.DeserializeObject<ProfileEntity>(top);
profile.ApplyToProfile();
ActivateProfile(module, profile);
_logger.Debug("Undo profile update - Success");
}
public void RedoUpdateProfile(Profile profile, ProfileModule module)
{
if (!profile.RedoStack.Any())
{
_logger.Debug("Redo profile update - Failed, redo empty");
return;
}
ActivateProfile(module, null);
var top = profile.RedoStack.Pop();
@@ -144,6 +155,8 @@ namespace Artemis.Core.Services.Storage
profile.ProfileEntity = JsonConvert.DeserializeObject<ProfileEntity>(top);
profile.ApplyToProfile();
ActivateProfile(module, profile);
_logger.Debug("Redo profile update - Success");
}
private void InstantiateProfileLayerBrushes(Profile profile)