Fix copying layers/duplicating folders

This commit is contained in:
RobertBeekman authored and Robert committed 2024-02-27 22:38:25 +01:00
1 parent 5f41716b56
commit 426b0c6024
2 files changed
+5 -10

No files matched your search

@@ -1,11 +1,7 @@
using System;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Artemis.Core;
using Artemis.Storage.Entities.Profile;
using Artemis.UI.Models;
using Artemis.UI.Shared.Extensions;
using Avalonia;
using Avalonia.Input;
namespace Artemis.UI.Extensions;
@@ -28,7 +24,7 @@ public static class ProfileElementExtensions
public static async Task CopyToClipboard(this Layer layer)
{
DataObject dataObject = new();
string copy = CoreJson.Serialize(layer.LayerEntity);
string copy = CoreJson.Serialize(new LayerClipboardModel(layer));
dataObject.Set(ClipboardDataFormat, copy);
await Shared.UI.Clipboard.SetDataObjectAsync(dataObject);
}
@@ -6,6 +6,7 @@ using Artemis.Core.Services;
using Artemis.Storage.Entities.Profile;
using Artemis.UI.DryIoc.Factories;
using Artemis.UI.Extensions;
using Artemis.UI.Models;
using Artemis.UI.Shared.Services;
using Artemis.UI.Shared.Services.ProfileEditor;
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
@@ -36,11 +37,9 @@ public class FolderTreeItemViewModel : TreeItemViewModel
{
await ProfileEditorService.SaveProfileAsync();
FolderEntity copy = CoreJson.Deserialize<FolderEntity>(CoreJson.Serialize(Folder.FolderEntity))!;
copy.Id = Guid.NewGuid();
copy.Name = Folder.Parent.GetNewFolderName(copy.Name + " - copy");
FolderClipboardModel copy = CoreJson.Deserialize<FolderClipboardModel>(CoreJson.Serialize(new FolderClipboardModel(Folder)))!;
Folder copied = copy.Paste(Folder.Profile, Folder.Parent);
Folder copied = new(Folder.Profile, Folder.Parent, copy);
ProfileEditorService.ExecuteCommand(new AddProfileElement(copied, Folder.Parent, Folder.Order - 1));
}