|
@@ -157,7 +157,7 @@ internal class ClipboardViewModel : SubViewModel<ViewModelMain>
|
|
|
if (doc is null)
|
|
|
return;
|
|
|
|
|
|
- List<Guid> toDuplicate = await ClipboardController.GetNodeIds();
|
|
|
+ Guid[] toDuplicate = await ClipboardController.GetNodeIds();
|
|
|
|
|
|
List<Guid> newIds = new();
|
|
|
|
|
@@ -200,6 +200,56 @@ internal class ClipboardViewModel : SubViewModel<ViewModelMain>
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ [Command.Basic("PixiEditor.Clipboard.PasteCels", "PASTE_CELS", "PASTE_CELS_DESCRIPTIVE",
|
|
|
+ CanExecute = "PixiEditor.Clipboard.CanPasteCels", Key = Key.V, Modifiers = KeyModifiers.Control,
|
|
|
+ ShortcutContexts = [typeof(TimelineDockViewModel)], Icon = PixiPerfectIcons.Paste, AnalyticsTrack = true)]
|
|
|
+ public async Task PasteCels()
|
|
|
+ {
|
|
|
+ var doc = Owner.DocumentManagerSubViewModel.ActiveDocument;
|
|
|
+ if (doc is null)
|
|
|
+ return;
|
|
|
+
|
|
|
+ var cels = await ClipboardController.GetCelIds();
|
|
|
+
|
|
|
+ if (cels.Length == 0)
|
|
|
+ return;
|
|
|
+
|
|
|
+ using var block = doc.Operations.StartChangeBlock();
|
|
|
+
|
|
|
+ List<Guid> newCels = new();
|
|
|
+
|
|
|
+ int i = 0;
|
|
|
+ foreach (var celId in cels)
|
|
|
+ {
|
|
|
+ ICelHandler cel = doc.AnimationDataViewModel.AllCels.First(x => x.Id == celId);
|
|
|
+ Guid? newCel = doc.AnimationDataViewModel.CreateCel(cel.LayerGuid, doc.AnimationDataViewModel.ActiveFrameBindable + i, cel.LayerGuid,
|
|
|
+ cel.StartFrameBindable);
|
|
|
+ if (newCel != null)
|
|
|
+ {
|
|
|
+ newCels.Add(newCel.Value);
|
|
|
+ }
|
|
|
+
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ doc.Operations.InvokeCustomAction(() =>
|
|
|
+ {
|
|
|
+ foreach (var cel in doc.AnimationDataViewModel.AllCels)
|
|
|
+ {
|
|
|
+ cel.IsSelected = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var cel in newCels)
|
|
|
+ {
|
|
|
+ var celInstance = doc.AnimationDataViewModel.AllCels.FirstOrDefault(x => x.Id == cel);
|
|
|
+ if (celInstance != null)
|
|
|
+ {
|
|
|
+ celInstance.IsSelected = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
[Command.Basic("PixiEditor.Clipboard.Copy", "COPY", "COPY_DESCRIPTIVE", CanExecute = "PixiEditor.Clipboard.CanCopy",
|
|
|
Key = Key.C, Modifiers = KeyModifiers.Control,
|
|
@@ -324,6 +374,12 @@ internal class ClipboardViewModel : SubViewModel<ViewModelMain>
|
|
|
return Owner.DocumentIsNotNull(null) && ClipboardController.AreNodesInClipboard().Result;
|
|
|
}
|
|
|
|
|
|
+ [Evaluator.CanExecute("PixiEditor.Clipboard.CanPasteCels")]
|
|
|
+ public bool CanPasteCels()
|
|
|
+ {
|
|
|
+ return Owner.DocumentIsNotNull(null) && ClipboardController.AreCelsInClipboard().Result;
|
|
|
+ }
|
|
|
+
|
|
|
[Evaluator.CanExecute("PixiEditor.Clipboard.CanPasteColor")]
|
|
|
public static async Task<bool> CanPasteColor()
|
|
|
{
|