mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Event condition - Added toggle off mode
Profile editor - Added element copy/pasting Shared UI - Fix namespaces
This commit is contained in:
1 parent
8c7bbc3f0f
commit
52f2338154
84 files changed
+1059
-608
No files matched your search
@@ -1,32 +1,71 @@
|
||||
using Artemis.Core;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Artemis.UI.Extensions;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
|
||||
namespace Artemis.UI.Screens.ProfileEditor.ProfileTree;
|
||||
|
||||
public class LayerTreeItemViewModel : TreeItemViewModel
|
||||
{
|
||||
public class LayerTreeItemViewModel : TreeItemViewModel
|
||||
public LayerTreeItemViewModel(TreeItemViewModel? parent,
|
||||
Layer layer,
|
||||
IWindowService windowService,
|
||||
IProfileEditorService profileEditorService,
|
||||
IRgbService rgbService,
|
||||
ILayerBrushService layerBrushService,
|
||||
IProfileEditorVmFactory profileEditorVmFactory)
|
||||
: base(parent, layer, windowService, profileEditorService, rgbService, layerBrushService, profileEditorVmFactory)
|
||||
{
|
||||
public LayerTreeItemViewModel(TreeItemViewModel? parent,
|
||||
Layer layer,
|
||||
IWindowService windowService,
|
||||
IProfileEditorService profileEditorService,
|
||||
IRgbService rgbService,
|
||||
ILayerBrushService layerBrushService,
|
||||
IProfileEditorVmFactory profileEditorVmFactory)
|
||||
: base(parent, layer, windowService, profileEditorService, rgbService, layerBrushService, profileEditorVmFactory)
|
||||
{
|
||||
Layer = layer;
|
||||
}
|
||||
|
||||
public Layer Layer { get; }
|
||||
|
||||
#region Overrides of TreeItemViewModel
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool SupportsChildren => false;
|
||||
|
||||
#endregion
|
||||
Layer = layer;
|
||||
}
|
||||
|
||||
public Layer Layer { get; }
|
||||
|
||||
#region Overrides of TreeItemViewModel
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task ExecuteDuplicate()
|
||||
{
|
||||
await ProfileEditorService.SaveProfileAsync();
|
||||
|
||||
LayerEntity copy = CoreJson.DeserializeObject<LayerEntity>(CoreJson.SerializeObject(Layer.LayerEntity, true), true)!;
|
||||
copy.Id = Guid.NewGuid();
|
||||
copy.Name = Layer.Parent.GetNewFolderName(copy.Name + " - copy");
|
||||
|
||||
Layer copied = new(Layer.Profile, Layer.Parent, copy);
|
||||
ProfileEditorService.ExecuteCommand(new AddProfileElement(copied, Layer.Parent, Layer.Order - 1));
|
||||
}
|
||||
|
||||
protected override async Task ExecuteCopy()
|
||||
{
|
||||
await ProfileEditorService.SaveProfileAsync();
|
||||
await Layer.CopyToClipboard();
|
||||
}
|
||||
|
||||
protected override async Task ExecutePaste()
|
||||
{
|
||||
if (Layer.Parent is not Folder parent)
|
||||
return;
|
||||
RenderProfileElement? pasted = await parent.PasteChildFromClipboard();
|
||||
if (pasted == null)
|
||||
return;
|
||||
|
||||
// If the target contains an element with the same name, affix with " - copy"
|
||||
if (parent.Children.Any(c => c.Name == pasted.Name))
|
||||
pasted.Name = parent.GetNewLayerName(pasted.Name + " - copy");
|
||||
|
||||
ProfileEditorService.ExecuteCommand(new AddProfileElement(pasted, parent, Layer.Order - 1));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool SupportsChildren => false;
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in new issue
Block a user