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:
parent
5f41716b56
commit
426b0c6024
@ -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));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user