Skip to content

命令的分组与排序

默认情况下,命令的分组是其他

1670082076398-1eab8733-356b-48e3-8009-5235b8c1af86.png

可以通过标注CategoryAttribute来自定义分组

csharp
    [Category("我的分组")]
    public class MyPluginCommand : Command
    {
    }

效果如下
1670082540936-baa350dc-1efb-48e8-b969-db345bd42429.png

如果分组名与既有的分组名一致,会加到已有的组里

csharp
    [Category("导航")]
    public class MyPluginCommand : Command
    {
    }

效果如下

1670082639300-b77b3621-db53-4206-84a5-5d631168241e.png

如果有多个插件,在同一分组,可以通过OrderWeightAttribute标注排序权重

csharp
    [OrderWeight(1)]
    [Category("我的分组")]
    public class MyPluginCommand1 : Command
    {
    }
    [OrderWeight(2)]
    [Category("我的分组")]
    public class MyPluginCommand2 : Command
    {
    }
    [OrderWeight(3)]
    [Category("我的分组")]
    public class MyPluginCommand3 : Command
    {
    }

设计器效果
1670082769371-980e0962-4e11-4424-b434-0aeb083a6580.png

更新: 2022-12-03 23:52:57
原文: https://www.yuque.com/robert-bh51n/ea8l6c/gk143psosyoow0lw