diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj
index a9c4706ed..5a94be1b2 100644
--- a/src/Artemis.Core/Artemis.Core.csproj
+++ b/src/Artemis.Core/Artemis.Core.csproj
@@ -14,6 +14,9 @@
pdbonly
+
+ x64
+
false
diff --git a/src/Artemis.Core/Models/Profile/Folder.cs b/src/Artemis.Core/Models/Profile/Folder.cs
index daf70f7ff..48b8bbe6a 100644
--- a/src/Artemis.Core/Models/Profile/Folder.cs
+++ b/src/Artemis.Core/Models/Profile/Folder.cs
@@ -72,14 +72,6 @@ namespace Artemis.Core.Models.Profile
return folder;
}
- public Layer AddLayer(string name)
- {
- var layer = new Layer(Profile, this, name) {Order = Children.LastOrDefault()?.Order ?? 1};
- layer.LayerShape = new Rectangle(layer);
- AddChild(layer);
- return layer;
- }
-
public override string ToString()
{
return $"[Folder] {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
diff --git a/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs b/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs
index 2277c9157..405a00b5c 100644
--- a/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs
+++ b/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs
@@ -130,14 +130,17 @@ namespace Artemis.Core.Models.Profile
if (propertyDescription != null)
{
if (!typeof(BaseLayerProperty).IsAssignableFrom(propertyInfo.PropertyType))
- throw new ArtemisPluginException("Layer property with PropertyDescription attribute must be of type LayerProperty");
+ throw new ArtemisPluginException($"Layer property with PropertyDescription attribute must be of type LayerProperty at {path + propertyInfo.Name}");
var instance = (BaseLayerProperty) Activator.CreateInstance(propertyInfo.PropertyType, true);
- instance.Parent = this;
- instance.PropertyDescription = (PropertyDescriptionAttribute)propertyDescription;
+ if (instance == null)
+ throw new ArtemisPluginException($"Failed to create instance of layer property at {path + propertyInfo.Name}");
+
instance.Layer = layer;
-
+ instance.Parent = this;
+ instance.PropertyDescription = (PropertyDescriptionAttribute) propertyDescription;
InitializeProperty(layer, path + propertyInfo.Name, instance);
+
propertyInfo.SetValue(this, instance);
_layerProperties.Add(instance);
}
@@ -150,16 +153,23 @@ namespace Artemis.Core.Models.Profile
throw new ArtemisPluginException("Layer property with PropertyGroupDescription attribute must be of type LayerPropertyGroup");
var instance = (LayerPropertyGroup) Activator.CreateInstance(propertyInfo.PropertyType);
+ if (instance == null)
+ throw new ArtemisPluginException($"Failed to create instance of layer property group at {path + propertyInfo.Name}");
+
instance.Parent = this;
- instance.GroupDescription = (PropertyGroupDescriptionAttribute)propertyGroupDescription;
+ instance.GroupDescription = (PropertyGroupDescriptionAttribute) propertyGroupDescription;
instance.InitializeProperties(layerService, layer, $"{path}{propertyInfo.Name}.");
+
propertyInfo.SetValue(this, instance);
_layerPropertyGroups.Add(instance);
}
}
}
+ // Request the property group to populate defaults
PopulateDefaults();
+
+ // Apply the newly populated defaults
foreach (var layerProperty in _layerProperties.Where(p => !p.IsLoadedFromStorage))
layerProperty.ApplyDefaultValue();
@@ -167,7 +177,7 @@ namespace Artemis.Core.Models.Profile
PropertiesInitialized = true;
OnPropertyGroupInitialized();
}
-
+
internal void ApplyToEntity()
{
if (!PropertiesInitialized)
diff --git a/src/Artemis.Core/Services/LayerService.cs b/src/Artemis.Core/Services/LayerService.cs
index 42e8e33e3..8dac3ed62 100644
--- a/src/Artemis.Core/Services/LayerService.cs
+++ b/src/Artemis.Core/Services/LayerService.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
+using Artemis.Core.Exceptions;
using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Services.Interfaces;
@@ -25,6 +26,7 @@ namespace Artemis.Core.Services
public Layer CreateLayer(Profile profile, ProfileElement parent, string name)
{
var layer = new Layer(profile, parent, name);
+ parent.AddChild(layer);
// Layers have two hardcoded property groups, instantiate them
layer.General.InitializeProperties(this, layer, "General.");
@@ -60,6 +62,7 @@ namespace Artemis.Core.Services
};
layer.LayerBrush = (BaseLayerBrush) _kernel.Get(descriptor.LayerBrushType, arguments);
layer.LayerBrush.Initialize(this);
+ layer.LayerBrush.Update(0);
layer.OnLayerBrushUpdated();
return layer.LayerBrush;
}
diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs
index fa30d4764..da3fdb39f 100644
--- a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs
+++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs
@@ -141,8 +141,8 @@ namespace Artemis.UI.Shared.Controls
var drawingImage = new DrawingImage(opacityDrawingGroup);
var image = new Image {Source = drawingImage};
var bitmap = new RenderTargetBitmap(
- (int) (opacityDrawingGroup.Bounds.Width * 2.5),
- (int) (opacityDrawingGroup.Bounds.Height * 2.5),
+ Math.Max(1, (int) (opacityDrawingGroup.Bounds.Width * 2.5)),
+ Math.Max(1, (int) (opacityDrawingGroup.Bounds.Height * 2.5)),
96,
96,
PixelFormats.Pbgra32
@@ -181,7 +181,6 @@ namespace Artemis.UI.Shared.Controls
deviceVisualizerLed.RenderColor(drawingContext, false);
}
-
drawingContext.Close();
}
}
diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj
index dd8684199..0b3b09ceb 100644
--- a/src/Artemis.UI/Artemis.UI.csproj
+++ b/src/Artemis.UI/Artemis.UI.csproj
@@ -9,7 +9,7 @@
en-US
Adds third-party support for RGB keyboards to games.
Copyright © Robert Beekman - 2019
- 2.0.0.0
+ 1.0.0.0
2.0.0.0
true
MinimumRecommendedRules.ruleset
diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileTree/TreeItem/TreeItemViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileTree/TreeItem/TreeItemViewModel.cs
index 7138ecdc9..1b9950548 100644
--- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileTree/TreeItem/TreeItemViewModel.cs
+++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileTree/TreeItem/TreeItemViewModel.cs
@@ -122,8 +122,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
if (!SupportsChildren)
throw new ArtemisUIException("Cannot add a layer to a profile element of type " + ProfileElement.GetType().Name);
- var layer = _layerService.CreateLayer(ProfileElement.Profile, ProfileElement, "New layer");
- ProfileElement.AddChild(layer);
+ _layerService.CreateLayer(ProfileElement.Profile, ProfileElement, "New layer");
UpdateProfileElements();
_profileEditorService.UpdateSelectedProfile();
}
diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileLayerViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileLayerViewModel.cs
index 08cd6475d..bb8165241 100644
--- a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileLayerViewModel.cs
+++ b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileLayerViewModel.cs
@@ -55,6 +55,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
private void Update()
{
IsSelected = _profileEditorService.SelectedProfileElement == Layer;
+
CreateLayerGeometry();
CreateShapeGeometry();
CreateViewportRectangle();
@@ -223,6 +224,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
private void ProfileEditorServiceOnProfilePreviewUpdated(object sender, EventArgs e)
{
+ if (!Layer.Transform.PropertiesInitialized || !Layer.General.PropertiesInitialized)
+ return;
+
CreateShapeGeometry();
CreateViewportRectangle();
}
diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileViewModel.cs
index 2e45471e7..b00e757e1 100644
--- a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileViewModel.cs
+++ b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileViewModel.cs
@@ -9,6 +9,7 @@ using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services;
+using Artemis.Core.Services.Interfaces;
using Artemis.Core.Services.Storage.Interfaces;
using Artemis.UI.Events;
using Artemis.UI.Extensions;
@@ -24,6 +25,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
public class ProfileViewModel : ProfileEditorPanelViewModel, IHandle, IHandle
{
private readonly ILayerEditorService _layerEditorService;
+ private readonly ILayerService _layerService;
private readonly IProfileEditorService _profileEditorService;
private readonly IProfileLayerVmFactory _profileLayerVmFactory;
private readonly ISettingsService _settingsService;
@@ -35,6 +37,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
public ProfileViewModel(IProfileEditorService profileEditorService,
ILayerEditorService layerEditorService,
+ ILayerService layerService,
ISurfaceService surfaceService,
ISettingsService settingsService,
IEventAggregator eventAggregator,
@@ -42,6 +45,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
{
_profileEditorService = profileEditorService;
_layerEditorService = layerEditorService;
+ _layerService = layerService;
_surfaceService = surfaceService;
_settingsService = settingsService;
_profileLayerVmFactory = profileLayerVmFactory;
@@ -228,7 +232,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
ActiveToolViewModel = new EditToolViewModel(this, _profileEditorService, _layerEditorService);
break;
case 2:
- ActiveToolViewModel = new SelectionToolViewModel(this, _profileEditorService);
+ ActiveToolViewModel = new SelectionToolViewModel(this, _profileEditorService, _layerService);
break;
case 3:
ActiveToolViewModel = new SelectionRemoveToolViewModel(this, _profileEditorService);
diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/Tools/SelectionToolViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/Tools/SelectionToolViewModel.cs
index afb3c66c5..f8c705799 100644
--- a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/Tools/SelectionToolViewModel.cs
+++ b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/Tools/SelectionToolViewModel.cs
@@ -3,6 +3,8 @@ using System.Linq;
using System.Windows;
using System.Windows.Input;
using Artemis.Core.Models.Profile;
+using Artemis.Core.Services;
+using Artemis.Core.Services.Interfaces;
using Artemis.UI.Properties;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
@@ -11,8 +13,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
{
public class SelectionToolViewModel : VisualizationToolViewModel
{
- public SelectionToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService) : base(profileViewModel, profileEditorService)
+ private readonly ILayerService _layerService;
+
+ public SelectionToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService, ILayerService layerService)
+ : base(profileViewModel, profileEditorService)
{
+ _layerService = layerService;
using (var stream = new MemoryStream(Resources.aero_crosshair))
{
Cursor = new Cursor(stream);
@@ -48,19 +54,21 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
// If no layer selected, apply it to a new layer in the selected folder
else if (ProfileEditorService.SelectedProfileElement is Folder folder)
{
- var newLayer = folder.AddLayer("New layer");
+ var newLayer = _layerService.CreateLayer(folder.Profile, folder, "New layer");
newLayer.AddLeds(selectedLeds);
ProfileEditorService.ChangeSelectedProfileElement(newLayer);
ProfileEditorService.UpdateSelectedProfileElement();
+ ProfileEditorService.UpdateSelectedProfile();
}
// If no folder selected, apply it to a new layer in the root folder
else
{
var rootFolder = ProfileEditorService.SelectedProfile.GetRootFolder();
- var newLayer = rootFolder.AddLayer("New layer");
+ var newLayer = _layerService.CreateLayer(rootFolder.Profile, rootFolder, "New layer");
newLayer.AddLeds(selectedLeds);
ProfileEditorService.ChangeSelectedProfileElement(newLayer);
ProfileEditorService.UpdateSelectedProfileElement();
+ ProfileEditorService.UpdateSelectedProfile();
}
}