xarial / xcad

Framework for developing CAD applications for SOLIDWORKS, including add-ins, stand-alone applications, macro features, property manager pages, etc.
https://xcad.net
MIT License
126 stars 25 forks source link

Cannot have ContextMenu and Commandgroup of same Enum #129

Closed foreachthing closed 2 weeks ago

foreachthing commented 2 weeks ago

I'd like to have a context menu of my submenu as well as have those commands in the toolbar. Please advice:

[Title("Verknüpfungen")]
    [CommandGroupInfo(0xB499, "Verknüpfungen")]
    [Icon(typeof(Resources), nameof(Resources._001_abstand0_128))]
    [CommandGroupParent(typeof(Commands_e))]
    [Guid("CB1D22E9-1508-44C7-A992-7F6695DC9CE2")]
    public enum Verknüpfungen_e
    {
       [Title("Command1")]
        [Description("Command One.")]
        [Icon(typeof(Resources), nameof(Resources.Icon))]
        [CommandItemInfo(true, true, WorkspaceTypes_e.Assembly, true, RibbonTabTextDisplay_e.TextHorizontal)]
        CommandOne = 0xB500
    }
}

public void Main(){
  IXCommandManager commandManager = CommandManager;
  // MAIN Menu, commented for this example
  // commandManager.AddCommandGroup<Commands_e>().CommandClick += OnCommandClick;

  commandManager.AddContextMenu<Verknüpfungen_e>().CommandClick += OnVerknüpfungenCommandClick;
  commandManager.AddCommandGroup<Verknüpfungen_e>().CommandClick += OnVerknüpfungenCommandClick;
}

So far I can either have it in the context or the toolbar... Any help is appreciated.