/* Copyright (C) 2014-2019 de4dot@gmail.com This file is part of dnSpy dnSpy is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. dnSpy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with dnSpy. If not, see . */ using System; using System.ComponentModel.Composition; using dnSpy.Contracts.Images; namespace dnSpy.Contracts.Menus { /// /// A menu item command /// public interface IMenuItem { /// /// Returns true if the menu item is visible in the menu /// /// Context /// bool IsVisible(IMenuItemContext context); /// /// Returns true if the menu item is enabled and its /// method can be called. /// /// Context /// bool IsEnabled(IMenuItemContext context); /// /// Executes the command /// /// Context void Execute(IMenuItemContext context); /// /// Gets the menu item header or null if the default header from the attribute should be /// used. /// /// Context /// string? GetHeader(IMenuItemContext context); /// /// Gets the menu item input gesture text or null if the default input gesture text from the /// attribute should be used. /// /// Context /// string? GetInputGestureText(IMenuItemContext context); /// /// Gets the menu item icon or null if the default icon from the attribute should be used. /// /// Context /// ImageReference? GetIcon(IMenuItemContext context); /// /// Returns true if the menu item is checked /// /// Context /// bool IsChecked(IMenuItemContext context); } /// Metadata public interface IMenuItemMetadata { /// See string? OwnerGuid { get; } /// See string? Guid { get; } /// See string? Group { get; } /// See double Order { get; } /// See string? Header { get; } /// See string? InputGestureText { get; } /// See string? Icon { get; } } /// /// Exports a menu item () /// [MetadataAttribute, AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] public sealed class ExportMenuItemAttribute : ExportAttribute, IMenuItemMetadata { /// Constructor public ExportMenuItemAttribute() : base(typeof(IMenuItem)) { } /// /// Guid of owner menu or menu item. null if it's a context menu () /// public string? OwnerGuid { get; set; } /// /// Guid of this item or null if it can't contain any child items /// public string? Guid { get; set; } /// /// Group name, must be of the format "order,name" where order is a decimal number and the /// order of the group in this menu. /// public string? Group { get; set; } /// /// Order within the menu group () /// public double Order { get; set; } /// /// Menu item header property value /// public string? Header { get; set; } /// /// Menu item input gesture text property value /// public string? InputGestureText { get; set; } /// /// Icon name /// public string? Icon { get; set; } } }