From cb69760971080708112010c345dab7acea1d1b43 Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 11 Aug 2020 22:47:41 +0200 Subject: [PATCH] UI - Moved exception viewer to its own seperate window Conditions - Started adding list conditions --- .../Conditions/DisplayConditionGroup.cs | 4 +- .../DisplayConditionListPredicate.cs | 76 ++++- src/Artemis.Core/Resources/intro-profile.json | 295 +----------------- .../Storage/Interfaces/IProfileService.cs | 19 +- .../Services/Storage/ProfileService.cs | 23 ++ .../DisplayConditionListPredicateEntity.cs | 19 ++ .../Controls/DraggableFloat.xaml | 2 +- .../Controls/DraggableFloat.xaml.cs | 10 +- .../Screens/Dialogs/ExceptionDialogView.xaml | 50 --- .../Screens/Exceptions/ExceptionView.xaml | 59 ++++ .../ExceptionViewModel.cs} | 12 +- .../Services/Dialog/DialogService.cs | 34 +- .../Services/Interfaces/IDialogService.cs | 5 +- .../DisplayConditions.xaml | 79 ++++- .../Dialogs/ProfileCreateView.xaml | 10 - .../Dialogs/ProfileExportView.xaml | 40 +++ .../Dialogs/ProfileExportViewModel.cs | 39 +++ .../Dialogs/ProfileImportView.xaml | 51 +++ .../Dialogs/ProfileImportViewModel.cs | 47 +++ .../DisplayConditionGroupView.xaml | 8 + .../DisplayConditionGroupViewModel.cs | 2 + .../DisplayConditionListPredicateView.xaml | 142 ++++++++- .../DisplayConditionListPredicateView.xaml.cs | 26 ++ .../DisplayConditionListPredicateViewModel.cs | 192 +++++++++++- .../DisplayConditionPredicateView.xaml | 41 --- .../DisplayConditionPredicateViewModel.cs | 11 +- .../LayerProperties/LayerPropertiesView.xaml | 7 +- .../Tree/TreePropertyGroupViewModel.cs | 8 +- .../ProfileEditor/ProfileEditorView.xaml | 25 +- .../ProfileEditor/ProfileEditorViewModel.cs | 18 +- .../Settings/Debug/DeviceDebugViewModel.cs | 8 +- .../Screens/Settings/SettingsViewModel.cs | 12 +- .../Tabs/Devices/DeviceSettingsViewModel.cs | 4 +- .../Tabs/Plugins/PluginSettingsViewModel.cs | 14 +- .../DataModel/GeneralDataModel.cs | 4 + .../GeneralModule.cs | 5 + 36 files changed, 930 insertions(+), 471 deletions(-) create mode 100644 src/Artemis.Storage/Entities/Profile/DisplayConditionListPredicateEntity.cs delete mode 100644 src/Artemis.UI.Shared/Screens/Dialogs/ExceptionDialogView.xaml create mode 100644 src/Artemis.UI.Shared/Screens/Exceptions/ExceptionView.xaml rename src/Artemis.UI.Shared/Screens/{Dialogs/ExceptionDialogViewModel.cs => Exceptions/ExceptionViewModel.cs} (81%) create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/Dialogs/ProfileExportView.xaml create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/Dialogs/ProfileExportViewModel.cs create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/Dialogs/ProfileImportView.xaml create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/Dialogs/ProfileImportViewModel.cs create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionListPredicateView.xaml.cs diff --git a/src/Artemis.Core/Models/Profile/Conditions/DisplayConditionGroup.cs b/src/Artemis.Core/Models/Profile/Conditions/DisplayConditionGroup.cs index c6fcbfc97..cbadd2967 100644 --- a/src/Artemis.Core/Models/Profile/Conditions/DisplayConditionGroup.cs +++ b/src/Artemis.Core/Models/Profile/Conditions/DisplayConditionGroup.cs @@ -25,8 +25,10 @@ namespace Artemis.Core.Models.Profile.Conditions { if (childEntity is DisplayConditionGroupEntity groupEntity) AddChild(new DisplayConditionGroup(this, groupEntity)); - if (childEntity is DisplayConditionPredicateEntity predicateEntity) + else if (childEntity is DisplayConditionPredicateEntity predicateEntity) AddChild(new DisplayConditionPredicate(this, predicateEntity)); + else if (childEntity is DisplayConditionListPredicateEntity listPredicateEntity) + AddChild(new DisplayConditionListPredicate(this, listPredicateEntity)); } } diff --git a/src/Artemis.Core/Models/Profile/Conditions/DisplayConditionListPredicate.cs b/src/Artemis.Core/Models/Profile/Conditions/DisplayConditionListPredicate.cs index 2e96b913a..0f62eb0c4 100644 --- a/src/Artemis.Core/Models/Profile/Conditions/DisplayConditionListPredicate.cs +++ b/src/Artemis.Core/Models/Profile/Conditions/DisplayConditionListPredicate.cs @@ -1,30 +1,100 @@ -using Artemis.Core.Models.Profile.Conditions.Abstract; +using System.Linq; +using Artemis.Core.Exceptions; +using Artemis.Core.Models.Profile.Conditions.Abstract; +using Artemis.Core.Plugins.Abstract.DataModels; using Artemis.Core.Services.Interfaces; +using Artemis.Storage.Entities.Profile; using Artemis.Storage.Entities.Profile.Abstract; namespace Artemis.Core.Models.Profile.Conditions { public class DisplayConditionListPredicate : DisplayConditionPart { + public DisplayConditionListPredicate(DisplayConditionPart parent) + { + Parent = parent; + DisplayConditionListPredicateEntity = new DisplayConditionListPredicateEntity(); + } + + public DisplayConditionListPredicate(DisplayConditionPart parent, DisplayConditionListPredicateEntity entity) + { + Parent = parent; + DisplayConditionListPredicateEntity = entity; + ListOperator = (ListOperator) entity.ListOperator; + + foreach (var childEntity in DisplayConditionListPredicateEntity.Children) + { + if (childEntity is DisplayConditionGroupEntity groupEntity) + AddChild(new DisplayConditionGroup(this, groupEntity)); + else if (childEntity is DisplayConditionPredicateEntity predicateEntity) + AddChild(new DisplayConditionPredicate(this, predicateEntity)); + else if (childEntity is DisplayConditionListPredicateEntity listPredicateEntity) + AddChild(new DisplayConditionListPredicate(this, listPredicateEntity)); + } + } + + public DisplayConditionListPredicateEntity DisplayConditionListPredicateEntity { get; set; } + public ListOperator ListOperator { get; set; } + public DataModel ListDataModel { get; private set; } + public string ListPropertyPath { get; private set; } public override bool Evaluate() { return true; } - internal override void ApplyToEntity() { + // Target list + DisplayConditionListPredicateEntity.ListDataModelGuid = ListDataModel?.PluginInfo?.Guid; + DisplayConditionListPredicateEntity.ListPropertyPath = ListPropertyPath; + + // Operator + DisplayConditionListPredicateEntity.ListOperator = (int) ListOperator; + + // Children + DisplayConditionListPredicateEntity.Children.Clear(); + DisplayConditionListPredicateEntity.Children.AddRange(Children.Select(c => c.GetEntity())); + foreach (var child in Children) + child.ApplyToEntity(); } internal override DisplayConditionPartEntity GetEntity() { - return null; + return DisplayConditionListPredicateEntity; } internal override void Initialize(IDataModelService dataModelService) { + // Target list + if (DisplayConditionListPredicateEntity.ListDataModelGuid != null) + { + var dataModel = dataModelService.GetPluginDataModelByGuid(DisplayConditionListPredicateEntity.ListDataModelGuid.Value); + if (dataModel != null && dataModel.ContainsPath(DisplayConditionListPredicateEntity.ListPropertyPath)) + UpdateList(dataModel, DisplayConditionListPredicateEntity.ListPropertyPath); + } + + // Children + foreach (var child in Children) + child.Initialize(dataModelService); + } + + public void UpdateList(DataModel dataModel, string path) + { + if (dataModel != null && path == null) + throw new ArtemisCoreException("If a data model is provided, a path is also required"); + if (dataModel == null && path != null) + throw new ArtemisCoreException("If path is provided, a data model is also required"); + + if (dataModel != null) + { + if (!dataModel.ContainsPath(path)) + throw new ArtemisCoreException($"Data model of type {dataModel.GetType().Name} does not contain a property at path '{path}'"); + } + + ListDataModel = dataModel; + ListPropertyPath = path; } } diff --git a/src/Artemis.Core/Resources/intro-profile.json b/src/Artemis.Core/Resources/intro-profile.json index 7f8badd1c..ab5994505 100644 --- a/src/Artemis.Core/Resources/intro-profile.json +++ b/src/Artemis.Core/Resources/intro-profile.json @@ -52,7 +52,7 @@ "Id": "2464a52c-4cec-4f17-87ed-edfe4bfed6f6", "ParentId": "cc21b67c-3485-4dc6-b2af-105fda42a915", "Order": 1, - "Name": "Teal layer", + "Name": "Noise", "Enabled": true, "Leds": { "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.LedEntity, Artemis.Storage]], System.Private.CoreLib", @@ -149,14 +149,14 @@ "$values": [ { "$type": "Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage", - "Position": "00:00:02.5000000", + "Position": "00:00:01.3200000", "Timeline": 0, "Value": "{\"IsEmpty\":false,\"Width\":300.0,\"Height\":0.0}", "EasingFunction": 3 }, { "$type": "Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage", - "Position": "00:00:03.7500000", + "Position": "00:00:03", "Timeline": 0, "Value": "{\"IsEmpty\":false,\"Width\":300.0,\"Height\":400.0}", "EasingFunction": 0 @@ -193,7 +193,7 @@ }, { "$type": "Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage", - "Position": "00:00:04.4000000", + "Position": "00:00:04.9100000", "Timeline": 0, "Value": "0.0", "EasingFunction": 0 @@ -205,7 +205,7 @@ "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", "PluginGuid": "61cbbf01-8d69-4ede-a972-f3f269da66d9", "Path": "LayerBrush.ColorType", - "Value": "0", + "Value": "1", "KeyframesEnabled": false, "KeyframeEntities": { "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", @@ -238,7 +238,7 @@ "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", "PluginGuid": "61cbbf01-8d69-4ede-a972-f3f269da66d9", "Path": "LayerBrush.GradientColor", - "Value": "{\"Stops\":[{\"Color\":\"#ffff0000\",\"Position\":0.0},{\"Color\":\"#ffff8800\",\"Position\":0.125},{\"Color\":\"#ffedff00\",\"Position\":0.25},{\"Color\":\"#ff65ff00\",\"Position\":0.375},{\"Color\":\"#ff00ff22\",\"Position\":0.5},{\"Color\":\"#ff00ffaa\",\"Position\":0.625},{\"Color\":\"#ff00cbff\",\"Position\":0.75},{\"Color\":\"#ff0043ff\",\"Position\":0.875},{\"Color\":\"#ffff0000\",\"Position\":1.0}],\"Rotation\":0.0}", + "Value": "{\"Stops\":[{\"Color\":\"#ff0b4a40\",\"Position\":0.0},{\"Color\":\"#ff00897c\",\"Position\":0.242},{\"Color\":\"#ffffffff\",\"Position\":1.0},{\"Color\":\"#ff00ffe6\",\"Position\":0.67391306}],\"Rotation\":0.0}", "KeyframesEnabled": false, "KeyframeEntities": { "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", @@ -249,7 +249,7 @@ "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", "PluginGuid": "61cbbf01-8d69-4ede-a972-f3f269da66d9", "Path": "LayerBrush.Scale", - "Value": "{\"IsEmpty\":false,\"Width\":100.0,\"Height\":100.0}", + "Value": "{\"IsEmpty\":false,\"Width\":44.9,\"Height\":31.0}", "KeyframesEnabled": false, "KeyframeEntities": { "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", @@ -260,7 +260,7 @@ "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", "PluginGuid": "61cbbf01-8d69-4ede-a972-f3f269da66d9", "Path": "LayerBrush.Hardness", - "Value": "300.0", + "Value": "228.5", "KeyframesEnabled": false, "KeyframeEntities": { "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", @@ -294,267 +294,6 @@ "ExpandedPropertyGroups": { "$type": "System.Collections.Generic.List`1[[System.String, System.Private.CoreLib]], System.Private.CoreLib", "$values": [ - "Transform", - "General" - ] - }, - "RootDisplayCondition": { - "$type": "Artemis.Storage.Entities.Profile.DisplayConditionGroupEntity, Artemis.Storage", - "BooleanOperator": 0, - "Children": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.Abstract.DisplayConditionPartEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - } - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.LayerEntity, Artemis.Storage", - "Id": "8d5fa358-88ed-4501-8cb2-fd9c31a34274", - "ParentId": "cc21b67c-3485-4dc6-b2af-105fda42a915", - "Order": 2, - "Name": "RGB layer", - "Enabled": true, - "Leds": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.LedEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - }, - "Profile": null, - "ProfileId": "eb4f487b-475b-408f-a84f-733412d41b44", - "StartSegmentLength": "00:00:00", - "MainSegmentLength": "00:00:03.7500000", - "EndSegmentLength": "00:00:00", - "DisplayContinuously": false, - "AlwaysFinishTimeline": false, - "LayerEffects": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.LayerEffectEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - }, - "PropertyEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [ - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "ffffffff-ffff-ffff-ffff-ffffffffffff", - "Path": "General.ShapeType", - "Value": "1", - "KeyframesEnabled": false, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "ffffffff-ffff-ffff-ffff-ffffffffffff", - "Path": "General.ResizeMode", - "Value": "0", - "KeyframesEnabled": false, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "ffffffff-ffff-ffff-ffff-ffffffffffff", - "Path": "General.BlendMode", - "Value": "3", - "KeyframesEnabled": false, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "ffffffff-ffff-ffff-ffff-ffffffffffff", - "Path": "General.BrushReference", - "Value": "{\"BrushPluginGuid\":\"92a9d6ba-6f7a-4937-94d5-c1d715b4141a\",\"BrushType\":\"ColorBrush\"}", - "KeyframesEnabled": false, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "ffffffff-ffff-ffff-ffff-ffffffffffff", - "Path": "Transform.AnchorPoint", - "Value": "{\"IsEmpty\":true,\"Length\":0.0,\"LengthSquared\":0.0,\"X\":0.0,\"Y\":0.0}", - "KeyframesEnabled": false, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "ffffffff-ffff-ffff-ffff-ffffffffffff", - "Path": "Transform.Position", - "Value": "{\"IsEmpty\":false,\"Length\":0.5,\"LengthSquared\":0.25,\"X\":-0.5,\"Y\":-0.0}", - "KeyframesEnabled": true, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [ - { - "$type": "Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage", - "Position": "00:00:01.2500000", - "Timeline": 0, - "Value": "{\"IsEmpty\":false,\"Length\":0.25,\"LengthSquared\":0.0625,\"X\":-0.25,\"Y\":0.0}", - "EasingFunction": 0 - }, - { - "$type": "Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage", - "Position": "00:00:03.7500000", - "Timeline": 0, - "Value": "{\"IsEmpty\":false,\"Length\":0.25,\"LengthSquared\":0.0625,\"X\":0.25,\"Y\":0.0}", - "EasingFunction": 0 - } - ] - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "ffffffff-ffff-ffff-ffff-ffffffffffff", - "Path": "Transform.Scale", - "Value": "{\"IsEmpty\":false,\"Width\":200.0,\"Height\":0.0}", - "KeyframesEnabled": true, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [ - { - "$type": "Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage", - "Position": "00:00:01.2500000", - "Timeline": 0, - "Value": "{\"IsEmpty\":false,\"Width\":150.0,\"Height\":0.0}", - "EasingFunction": 5 - }, - { - "$type": "Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage", - "Position": "00:00:02.2700000", - "Timeline": 0, - "Value": "{\"IsEmpty\":false,\"Width\":150.0,\"Height\":100.0}", - "EasingFunction": 0 - } - ] - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "ffffffff-ffff-ffff-ffff-ffffffffffff", - "Path": "Transform.Rotation", - "Value": "0.0", - "KeyframesEnabled": false, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "ffffffff-ffff-ffff-ffff-ffffffffffff", - "Path": "Transform.Opacity", - "Value": "100.0", - "KeyframesEnabled": false, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "92a9d6ba-6f7a-4937-94d5-c1d715b4141a", - "Path": "LayerBrush.GradientType", - "Value": "1", - "KeyframesEnabled": false, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "92a9d6ba-6f7a-4937-94d5-c1d715b4141a", - "Path": "LayerBrush.TileMode", - "Value": "0", - "KeyframesEnabled": false, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "92a9d6ba-6f7a-4937-94d5-c1d715b4141a", - "Path": "LayerBrush.Color", - "Value": "\"#ffff0000\"", - "KeyframesEnabled": false, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "92a9d6ba-6f7a-4937-94d5-c1d715b4141a", - "Path": "LayerBrush.Colors", - "Value": "{\"Stops\":[{\"Color\":\"#ffff0000\",\"Position\":0.0},{\"Color\":\"#ffff8800\",\"Position\":0.125},{\"Color\":\"#ffedff00\",\"Position\":0.25},{\"Color\":\"#ff65ff00\",\"Position\":0.375},{\"Color\":\"#ff00ff22\",\"Position\":0.5},{\"Color\":\"#ff00ffaa\",\"Position\":0.625},{\"Color\":\"#ff00cbff\",\"Position\":0.75},{\"Color\":\"#ff0043ff\",\"Position\":0.875},{\"Color\":\"#ffff0000\",\"Position\":1.0}],\"Rotation\":0.0}", - "KeyframesEnabled": false, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "92a9d6ba-6f7a-4937-94d5-c1d715b4141a", - "Path": "LayerBrush.ColorsMultiplier", - "Value": "2", - "KeyframesEnabled": false, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "92a9d6ba-6f7a-4937-94d5-c1d715b4141a", - "Path": "LayerBrush.LinearGradientRotation", - "Value": "0.0", - "KeyframesEnabled": false, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "92a9d6ba-6f7a-4937-94d5-c1d715b4141a", - "Path": "LayerBrush.RadialGradient.CenterOffset", - "Value": "{\"IsEmpty\":true,\"Length\":0.0,\"LengthSquared\":0.0,\"X\":0.0,\"Y\":0.0}", - "KeyframesEnabled": false, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - } - }, - { - "$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage", - "PluginGuid": "92a9d6ba-6f7a-4937-94d5-c1d715b4141a", - "Path": "LayerBrush.RadialGradient.ResizeMode", - "Value": "0", - "KeyframesEnabled": false, - "KeyframeEntities": { - "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib", - "$values": [] - } - } - ] - }, - "ExpandedPropertyGroups": { - "$type": "System.Collections.Generic.List`1[[System.String, System.Private.CoreLib]], System.Private.CoreLib", - "$values": [ - "Transform", "LayerBrush" ] }, @@ -571,8 +310,8 @@ "$type": "Artemis.Storage.Entities.Profile.LayerEntity, Artemis.Storage", "Id": "72a7e56c-0649-4449-8dca-eb937161f228", "ParentId": "cc21b67c-3485-4dc6-b2af-105fda42a915", - "Order": 3, - "Name": "Exploison layer", + "Order": 2, + "Name": "Exploison", "Enabled": true, "Leds": { "$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.LedEntity, Artemis.Storage]], System.Private.CoreLib", @@ -581,7 +320,7 @@ "Profile": null, "ProfileId": "eb4f487b-475b-408f-a84f-733412d41b44", "StartSegmentLength": "00:00:00", - "MainSegmentLength": "00:00:02.2500000", + "MainSegmentLength": "00:00:03", "EndSegmentLength": "00:00:00", "DisplayContinuously": false, "AlwaysFinishTimeline": false, @@ -676,9 +415,9 @@ }, { "$type": "Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage", - "Position": "00:00:02", + "Position": "00:00:01.5000000", "Timeline": 0, - "Value": "{\"IsEmpty\":false,\"Width\":200.0,\"Height\":200.0}", + "Value": "{\"IsEmpty\":false,\"Width\":300.0,\"Height\":300.0}", "EasingFunction": 0 } ] @@ -798,9 +537,7 @@ }, "ExpandedPropertyGroups": { "$type": "System.Collections.Generic.List`1[[System.String, System.Private.CoreLib]], System.Private.CoreLib", - "$values": [ - "LayerBrush" - ] + "$values": [] }, "RootDisplayCondition": { "$type": "Artemis.Storage.Entities.Profile.DisplayConditionGroupEntity, Artemis.Storage", @@ -815,7 +552,7 @@ "$type": "Artemis.Storage.Entities.Profile.LayerEntity, Artemis.Storage", "Id": "f046f56f-a236-4ed6-bbd9-b5a4731878cf", "ParentId": "cc21b67c-3485-4dc6-b2af-105fda42a915", - "Order": 4, + "Order": 2, "Name": "Background", "Enabled": true, "Leds": { @@ -825,7 +562,7 @@ "Profile": null, "ProfileId": "eb4f487b-475b-408f-a84f-733412d41b44", "StartSegmentLength": "00:00:00", - "MainSegmentLength": "00:00:03.7500000", + "MainSegmentLength": "00:00:03", "EndSegmentLength": "00:00:00", "DisplayContinuously": false, "AlwaysFinishTimeline": false, diff --git a/src/Artemis.Core/Services/Storage/Interfaces/IProfileService.cs b/src/Artemis.Core/Services/Storage/Interfaces/IProfileService.cs index 31bd8efcb..7ebbae54a 100644 --- a/src/Artemis.Core/Services/Storage/Interfaces/IProfileService.cs +++ b/src/Artemis.Core/Services/Storage/Interfaces/IProfileService.cs @@ -88,9 +88,26 @@ namespace Artemis.Core.Services.Storage.Interfaces bool RedoUpdateProfile(Profile profile); /// - /// Prepares the profile for rendering. You should not need to call this, it is exposed for some niche usage in the core + /// Prepares the profile for rendering. You should not need to call this, it is exposed for some niche usage in the + /// core /// /// void InstantiateProfile(Profile profile); + + /// + /// [Placeholder] Exports the profile described in the given in a JSON format + /// + /// The descriptor of the profile to export + /// The resulting JSON + string ExportProfile(ProfileDescriptor profileDescriptor); + + /// + /// [Placeholder] Imports the provided base64 encoded GZIPed JSON as a profile for the given + /// + /// + /// The content of the profile as JSON + /// The module to import the profile in to + /// + ProfileDescriptor ImportProfile(string json, ProfileModule profileModule); } } \ No newline at end of file diff --git a/src/Artemis.Core/Services/Storage/ProfileService.cs b/src/Artemis.Core/Services/Storage/ProfileService.cs index 4170d9e84..0eee8c30d 100644 --- a/src/Artemis.Core/Services/Storage/ProfileService.cs +++ b/src/Artemis.Core/Services/Storage/ProfileService.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO.Compression; using System.Linq; using System.Threading.Tasks; using Artemis.Core.Events; @@ -10,6 +11,7 @@ using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.LayerEffect.Abstract; using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Storage.Interfaces; +using Artemis.Core.Utilities; using Artemis.Storage.Entities.Profile; using Artemis.Storage.Repositories.Interfaces; using Newtonsoft.Json; @@ -40,6 +42,7 @@ namespace Artemis.Core.Services.Storage } public JsonSerializerSettings MementoSettings { get; set; } = new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.All}; + public JsonSerializerSettings ExportSettings { get; set; } = new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.All, Formatting = Formatting.Indented}; public void ActivateLastActiveProfiles() { @@ -222,6 +225,26 @@ namespace Artemis.Core.Services.Storage InstantiateFolders(profile); } + public string ExportProfile(ProfileDescriptor profileDescriptor) + { + var profileEntity = _profileRepository.Get(profileDescriptor.Id); + if (profileEntity == null) + throw new ArtemisCoreException($"Cannot find profile named: {profileDescriptor.Name} ID: {profileDescriptor.Id}"); + + return JsonConvert.SerializeObject(profileEntity, ExportSettings); + } + + public ProfileDescriptor ImportProfile(string json, ProfileModule profileModule) + { + var profileEntity = JsonConvert.DeserializeObject(json, ExportSettings); + + // Assign a new GUID to make sure it is unique in case of a previous import of the same content + profileEntity.Id = Guid.NewGuid(); + + _profileRepository.Add(profileEntity); + return new ProfileDescriptor(profileModule, profileEntity); + } + /// /// Initializes the properties on the layers of the given profile /// diff --git a/src/Artemis.Storage/Entities/Profile/DisplayConditionListPredicateEntity.cs b/src/Artemis.Storage/Entities/Profile/DisplayConditionListPredicateEntity.cs new file mode 100644 index 000000000..6d40fae9c --- /dev/null +++ b/src/Artemis.Storage/Entities/Profile/DisplayConditionListPredicateEntity.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using Artemis.Storage.Entities.Profile.Abstract; + +namespace Artemis.Storage.Entities.Profile +{ + public class DisplayConditionListPredicateEntity : DisplayConditionPartEntity + { + public DisplayConditionListPredicateEntity() + { + Children = new List(); + } + + public Guid? ListDataModelGuid { get; set; } + public string ListPropertyPath { get; set; } + + public int ListOperator { get; set; } + } +} \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Controls/DraggableFloat.xaml b/src/Artemis.UI.Shared/Controls/DraggableFloat.xaml index a1944d9a1..a2c9b12ed 100644 --- a/src/Artemis.UI.Shared/Controls/DraggableFloat.xaml +++ b/src/Artemis.UI.Shared/Controls/DraggableFloat.xaml @@ -40,7 +40,7 @@ - - - - - - - - - - - - - - - - - - - - - -