JD2022-TU1/main/tools/modules/Orbit.Module/ViewModel/ShellObjectCustomAdapter.cs

54 lines
No EOL
1.8 KiB
C#

using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using ActiproSoftware.Windows.Controls.Grids;
using ActiproSoftware.Windows.Controls.Shell;
using Orbit.Module.Actions;
using Orbit.Module.Actions.PhotoshopActions;
using Plume.Interfaces.WPF;
using Plume.Interfaces.WPF.Actions;
using ShowInP4VAction = Orbit.Module.Actions.ShowInP4VAction;
namespace Orbit.Module.ViewModel
{
public class ShellObjectCustomAdapter : ShellObjectItemAdapter
{
public override ContextMenu GetBackgroundContextMenu(TreeListBox ownerControl, ShellObjectViewModel rootViewModel)
{
return null;
}
public override ContextMenu GetItemContextMenu(TreeListBox ownerControl, IList<ShellObjectViewModel> viewModels)
{
var paths = new List<string>();
foreach (var vm in viewModels)
{
paths.Add(vm.FileSystemPath);
}
var context = new ContextMenu();
var actionManager = ((IWpfApplication)Application.Current).ActionManager;
if (viewModels.Any(x => !x.IsFolder))
{
var placeInPSItem = actionManager.Get<PlaceInPhotoshopAction>().ToMenuItem();
context.Items.Add(placeInPSItem);
}
var showInExplorerItem = actionManager.Get<ShowInExplorerAction>().ToMenuItem();
showInExplorerItem.CommandParameter = paths;
context.Items.Add(showInExplorerItem);
if (paths.Count == 1)
{
var showInP4VItem = actionManager.Get<ShowInP4VAction>().ToMenuItem();
showInP4VItem.CommandParameter = paths[0];
context.Items.Add(showInP4VItem);
}
return context;
}
}
}