1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2026-01-01 02:03:32 +00:00

Profile editor - Fixed layer copy with databindings

Shows how thoroughly tested it was :)
This commit is contained in:
SpoinkyNL 2020-11-08 23:13:16 +01:00
parent f80a7d658c
commit c0d0e421c7
2 changed files with 9 additions and 4 deletions

View File

@ -128,13 +128,17 @@ namespace Artemis.Core
} }
/// <summary> /// <summary>
/// Creates a deep copy of the layer /// Creates a deep copy of the folder
/// </summary> /// </summary>
/// <returns>The newly created copy</returns> /// <returns>The newly created copy</returns>
public Folder CreateCopy() public Folder CreateCopy()
{ {
FolderEntity entityCopy = JsonConvert.DeserializeObject<FolderEntity>(JsonConvert.SerializeObject(FolderEntity)); JsonSerializerSettings settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All };
FolderEntity entityCopy = JsonConvert.DeserializeObject<FolderEntity>(JsonConvert.SerializeObject(FolderEntity, settings), settings)!;
entityCopy.Id = Guid.NewGuid(); entityCopy.Id = Guid.NewGuid();
entityCopy.Name += " - Copy";
// TODO Children
return new Folder(Profile, Parent, entityCopy); return new Folder(Profile, Parent, entityCopy);
} }

View File

@ -122,9 +122,10 @@ namespace Artemis.Core
/// <returns>The newly created copy</returns> /// <returns>The newly created copy</returns>
public Layer CreateCopy() public Layer CreateCopy()
{ {
LayerEntity entityCopy = JsonConvert.DeserializeObject<LayerEntity>(JsonConvert.SerializeObject(LayerEntity)); JsonSerializerSettings settings = new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.All};
LayerEntity entityCopy = JsonConvert.DeserializeObject<LayerEntity>(JsonConvert.SerializeObject(LayerEntity, settings), settings)!;
entityCopy.Id = Guid.NewGuid(); entityCopy.Id = Guid.NewGuid();
entityCopy.Name = entityCopy.Name + " - Copy"; entityCopy.Name += " - Copy";
Layer copy = new Layer(Profile, Parent, entityCopy); Layer copy = new Layer(Profile, Parent, entityCopy);
copy.ChangeLayerBrush(LayerBrush.Descriptor); copy.ChangeLayerBrush(LayerBrush.Descriptor);