diff --git a/src/Artemis.Core/Plugins/LayerBrush/Abstract/PerLedLayerBrush.cs b/src/Artemis.Core/Plugins/LayerBrush/Abstract/PerLedLayerBrush.cs index 758ba6d69..c435a2496 100644 --- a/src/Artemis.Core/Plugins/LayerBrush/Abstract/PerLedLayerBrush.cs +++ b/src/Artemis.Core/Plugins/LayerBrush/Abstract/PerLedLayerBrush.cs @@ -30,10 +30,13 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract // We don't want translations on this canvas because that'll displace the LEDs, translations are applied to the points of each LED instead Layer.ExcludeCanvasFromTranslation(canvas, true); - // Apply a translated version of the shape as the clipping mask - var shapePath = new SKPath(Layer.LayerShape.Path); - Layer.IncludePathInTranslation(shapePath, true); - canvas.ClipPath(shapePath); + if (Layer.General.ResizeMode == LayerResizeMode.Normal) + { + // Apply a translated version of the shape as the clipping mask + var shapePath = new SKPath(Layer.LayerShape.Path); + Layer.IncludePathInTranslation(shapePath, true); + canvas.ClipPath(shapePath); + } using var pointsPath = new SKPath(); using var ledPaint = new SKPaint(); diff --git a/src/Artemis.Core/Resources/intro-profile.json b/src/Artemis.Core/Resources/intro-profile.json index 895a03515..7f8badd1c 100644 --- a/src/Artemis.Core/Resources/intro-profile.json +++ b/src/Artemis.Core/Resources/intro-profile.json @@ -87,7 +87,7 @@ "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", "PluginGuid": "ffffffff-ffff-ffff-ffff-ffffffffffff", "Path": "General.ResizeMode", - "Value": "0", + "Value": "1", "KeyframesEnabled": false, "KeyframeEntities": { "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", diff --git a/src/Artemis.Core/Services/Storage/ProfileService.cs b/src/Artemis.Core/Services/Storage/ProfileService.cs index 9212eb87f..4170d9e84 100644 --- a/src/Artemis.Core/Services/Storage/ProfileService.cs +++ b/src/Artemis.Core/Services/Storage/ProfileService.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Artemis.Core.Events; +using Artemis.Core.Exceptions; using Artemis.Core.Models.Profile; using Artemis.Core.Models.Surface; using Artemis.Core.Plugins.Abstract; @@ -58,6 +59,8 @@ namespace Artemis.Core.Services.Storage public ProfileDescriptor CreateProfileDescriptor(ProfileModule module, string name) { var profileEntity = new ProfileEntity {Id = Guid.NewGuid(), Name = name, PluginGuid = module.PluginInfo.Guid}; + _profileRepository.Add(profileEntity); + return new ProfileDescriptor(module, profileEntity); } @@ -67,10 +70,15 @@ namespace Artemis.Core.Services.Storage return profileDescriptor.ProfileModule.ActiveProfile; var profileEntity = _profileRepository.Get(profileDescriptor.Id); + if (profileEntity == null) + throw new ArtemisCoreException($"Cannot find profile named: {profileDescriptor.Name} ID: {profileDescriptor.Id}"); + var profile = new Profile(profileDescriptor.ProfileModule, profileEntity); InstantiateProfile(profile); profileDescriptor.ProfileModule.ChangeActiveProfile(profile, _surfaceService.ActiveSurface); + SaveActiveProfile(profileDescriptor.ProfileModule); + return profile; } @@ -80,16 +88,32 @@ namespace Artemis.Core.Services.Storage return profileDescriptor.ProfileModule.ActiveProfile; var profileEntity = _profileRepository.Get(profileDescriptor.Id); + if (profileEntity == null) + throw new ArtemisCoreException($"Cannot find profile named: {profileDescriptor.Name} ID: {profileDescriptor.Id}"); + var profile = new Profile(profileDescriptor.ProfileModule, profileEntity); InstantiateProfile(profile); await profileDescriptor.ProfileModule.ChangeActiveProfileAnimated(profile, _surfaceService.ActiveSurface); + SaveActiveProfile(profileDescriptor.ProfileModule); + return profile; } public void ClearActiveProfile(ProfileModule module) { module.ChangeActiveProfile(null, _surfaceService.ActiveSurface); + SaveActiveProfile(module); + } + + private void SaveActiveProfile(ProfileModule module) + { + var profileEntities = _profileRepository.GetByPluginGuid(module.PluginInfo.Guid); + foreach (var profileEntity in profileEntities) + { + profileEntity.IsActive = module.ActiveProfile.EntityId == profileEntity.Id; + _profileRepository.Save(profileEntity); + } } public async Task ClearActiveProfileAnimated(ProfileModule module) @@ -103,7 +127,7 @@ namespace Artemis.Core.Services.Storage // If the given profile is currently active, disable it first (this also disposes it) if (profile.Module.ActiveProfile == profile) - profile.Module.ChangeActiveProfile(null, _surfaceService.ActiveSurface); + ClearActiveProfile(profile.Module); else profile.Dispose(); diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs index c1887f0cf..05b56eea8 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs @@ -286,11 +286,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor Profiles.AddRange(_profileService.GetProfileDescriptors(Module).OrderBy(d => d.Name)); // Populate the selected profile - SelectedProfile = Profiles.FirstOrDefault(p => p.IsLastActiveProfile); - - if (SelectedProfile != null) + var lastActiveProfile = Profiles.FirstOrDefault(p => p.IsLastActiveProfile) ?? Profiles.FirstOrDefault(); + if (lastActiveProfile != null) + { + SelectedProfile = lastActiveProfile; return; - + } + // Create a default profile if there is none var defaultProfile = _profileService.CreateProfileDescriptor(Module, "Default"); Profiles.Add(defaultProfile);