mirror of
https://github.com/4sval/FModel.git
synced 2026-05-15 00:49:53 -05:00
Some checks failed
FModel QA Builder / build (push) Has been cancelled
+ filter by types, find by references (UE5+), and a lot of other improvements Co-authored-by: Asval <asval.contactme@gmail.com> Co-authored-by: LongerWarrior <LongerWarrior@gmail.com>
56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using CUE4Parse.FileProvider.Objects;
|
|
using FModel.Framework;
|
|
|
|
namespace FModel.ViewModels.Commands;
|
|
|
|
public class CopyCommand : ViewModelCommand<ApplicationViewModel>
|
|
{
|
|
public CopyCommand(ApplicationViewModel contextViewModel) : base(contextViewModel)
|
|
{
|
|
}
|
|
|
|
public override void Execute(ApplicationViewModel contextViewModel, object parameter)
|
|
{
|
|
if (parameter is not object[] parameters || parameters[0] is not string trigger)
|
|
return;
|
|
|
|
var entries = (parameters[1] as IEnumerable)?.OfType<object>()
|
|
.SelectMany(item => item switch
|
|
{
|
|
GameFile gf => new[] { gf },
|
|
GameFileViewModel gvm => new[] { gvm.Asset },
|
|
_ => []
|
|
}) ?? [];
|
|
|
|
if (!entries.Any())
|
|
return;
|
|
|
|
var sb = new StringBuilder();
|
|
switch (trigger)
|
|
{
|
|
case "File_Path":
|
|
foreach (var entry in entries) sb.AppendLine(entry.Path);
|
|
break;
|
|
case "File_Name":
|
|
foreach (var entry in entries) sb.AppendLine(entry.Name);
|
|
break;
|
|
case "Directory_Path":
|
|
foreach (var entry in entries) sb.AppendLine(entry.Directory);
|
|
break;
|
|
case "File_Path_No_Extension":
|
|
foreach (var entry in entries) sb.AppendLine(entry.PathWithoutExtension);
|
|
break;
|
|
case "File_Name_No_Extension":
|
|
foreach (var entry in entries) sb.AppendLine(entry.NameWithoutExtension);
|
|
break;
|
|
}
|
|
|
|
Clipboard.SetText(sb.ToString().TrimEnd());
|
|
}
|
|
}
|