JD2022-TU1/main/tools/modules/JD.AssetBrowser/ViewModel/AssetViewModel.ContextMenu.cs

45 lines
1.3 KiB
C#

using System.Collections.Generic;
using System.Linq;
using System.Windows;
using JD.Collections.Extensions;
using JD.Filters;
using TeaBox;
using Control = System.Windows.Controls.Control;
using MenuItem = System.Windows.Controls.MenuItem;
namespace JD.AssetBrowser.ViewModel
{
public partial class AssetViewModel
{
private MenuItem _defaultMenuAction;
[Filterable(false)]
public MenuItem DefaultMenuAction
{
get
{
if (_defaultMenuAction == null)
{
ContextMenuItems.Consume();
}
return _defaultMenuAction;
}
set
{
if (_defaultMenuAction != null)
{
_defaultMenuAction.FontWeight = FontWeights.Normal;
}
value.FontWeight = FontWeights.Bold;
_defaultMenuAction = value;
}
}
public static IContextMenuProvider ContextMenuItemProvider { get; set; } = new DefaultContextMenuProvider();
[Filterable(false)]
public virtual IEnumerable<Control> ContextMenuItems => ContextMenuItemProvider != null ? ContextMenuItemProvider.ContextMenuItems(this) : Enumerable.Empty<Control>();
}
}