可以通过实现 ISubListCommand 和 IContainSubCommands 实现给命令添加子命令。
using GrapeCity.Forguncy.Commands; using System.Collections.Generic; using System.ComponentModel; namespace MyPlugin { public class MyPluginCommand : Command, ISubListCommand, IContainSubCommands { [Browsable(false)] public List<Command> CommandList { get; set; } = new List<Command>(); public IEnumerable<List<Command>> EnumSubCommands() { yield return CommandList; } } }
代码说明:给 CommandList属性标注 [Browsable(false)] 避免CommandList属性出现在主命令的属性中。
效果: