1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Fix copying layers/duplicating folders

This commit is contained in:
RobertBeekman 2024-02-27 22:38:18 +01:00 committed by Robert
parent 5f41716b56
commit 426b0c6024
2 changed files with 5 additions and 10 deletions

View File

@ -1,11 +1,7 @@
using System; using System.Threading.Tasks;
using System.Text;
using System.Threading.Tasks;
using Artemis.Core; using Artemis.Core;
using Artemis.Storage.Entities.Profile;
using Artemis.UI.Models; using Artemis.UI.Models;
using Artemis.UI.Shared.Extensions; using Artemis.UI.Shared.Extensions;
using Avalonia;
using Avalonia.Input; using Avalonia.Input;
namespace Artemis.UI.Extensions; namespace Artemis.UI.Extensions;
@ -28,7 +24,7 @@ public static class ProfileElementExtensions
public static async Task CopyToClipboard(this Layer layer) public static async Task CopyToClipboard(this Layer layer)
{ {
DataObject dataObject = new(); DataObject dataObject = new();
string copy = CoreJson.Serialize(layer.LayerEntity); string copy = CoreJson.Serialize(new LayerClipboardModel(layer));
dataObject.Set(ClipboardDataFormat, copy); dataObject.Set(ClipboardDataFormat, copy);
await Shared.UI.Clipboard.SetDataObjectAsync(dataObject); await Shared.UI.Clipboard.SetDataObjectAsync(dataObject);
} }

View File

@ -6,6 +6,7 @@ using Artemis.Core.Services;
using Artemis.Storage.Entities.Profile; using Artemis.Storage.Entities.Profile;
using Artemis.UI.DryIoc.Factories; using Artemis.UI.DryIoc.Factories;
using Artemis.UI.Extensions; using Artemis.UI.Extensions;
using Artemis.UI.Models;
using Artemis.UI.Shared.Services; using Artemis.UI.Shared.Services;
using Artemis.UI.Shared.Services.ProfileEditor; using Artemis.UI.Shared.Services.ProfileEditor;
using Artemis.UI.Shared.Services.ProfileEditor.Commands; using Artemis.UI.Shared.Services.ProfileEditor.Commands;
@ -36,11 +37,9 @@ public class FolderTreeItemViewModel : TreeItemViewModel
{ {
await ProfileEditorService.SaveProfileAsync(); await ProfileEditorService.SaveProfileAsync();
FolderEntity copy = CoreJson.Deserialize<FolderEntity>(CoreJson.Serialize(Folder.FolderEntity))!; FolderClipboardModel copy = CoreJson.Deserialize<FolderClipboardModel>(CoreJson.Serialize(new FolderClipboardModel(Folder)))!;
copy.Id = Guid.NewGuid(); Folder copied = copy.Paste(Folder.Profile, Folder.Parent);
copy.Name = Folder.Parent.GetNewFolderName(copy.Name + " - copy");
Folder copied = new(Folder.Profile, Folder.Parent, copy);
ProfileEditorService.ExecuteCommand(new AddProfileElement(copied, Folder.Parent, Folder.Order - 1)); ProfileEditorService.ExecuteCommand(new AddProfileElement(copied, Folder.Parent, Folder.Order - 1));
} }