Storage - Added migration for plugin features

UI - Fixed an error on layer creation when the default brush is disabled
This commit is contained in:
SpoinkyNL committed 2020-11-13 00:09:36 +01:00
1 parent 9452f81214
commit ed58745a6e
5 files changed
+155 -3

No files matched your search

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Artemis.Core;
using Artemis.Core.LayerBrushes;
using Artemis.Core.Services;
using Artemis.UI.Exceptions;
using Artemis.UI.Ninject.Factories;
@@ -139,7 +140,12 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem
throw new ArtemisUIException("Cannot add a layer to a profile element of type " + ProfileElement.GetType().Name);
Layer layer = new Layer(ProfileElement, "New layer");
layer.ChangeLayerBrush(_layerBrushService.GetDefaultLayerBrush());
// Could be null if the default brush got disabled
LayerBrushDescriptor? brush = _layerBrushService.GetDefaultLayerBrush();
if (brush != null)
layer.ChangeLayerBrush(brush);
layer.AddLeds(_surfaceService.ActiveSurface.Devices.SelectMany(d => d.Leds));
_profileEditorService.UpdateSelectedProfile();
_profileEditorService.ChangeSelectedProfileElement(layer);
@@ -4,6 +4,7 @@ using System.Linq;
using System.Windows;
using System.Windows.Input;
using Artemis.Core;
using Artemis.Core.LayerBrushes;
using Artemis.Core.Services;
using Artemis.UI.Properties;
using Artemis.UI.Shared.Services;
@@ -91,7 +92,11 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools
private void CreateLayer(Folder folder, List<ArtemisLed> selectedLeds)
{
Layer newLayer = new Layer(folder, "New layer");
newLayer.ChangeLayerBrush(_layerBrushService.GetDefaultLayerBrush());
LayerBrushDescriptor brush = _layerBrushService.GetDefaultLayerBrush();
if (brush != null)
newLayer.ChangeLayerBrush(brush);
newLayer.AddLeds(selectedLeds);
ProfileEditorService.ChangeSelectedProfileElement(newLayer);
ProfileEditorService.UpdateSelectedProfileElement();