My event framework is a little complex, but the following should give you some ideas. I verify that just my client feature is selected before adding a button definition to the linear menu.
void OnLinearMarkingMenu(ObjectsEnumerator selectedEntities, SelectionDeviceEnum selectionDevice, CommandControls linearMenu, NameValueMap additionalInfo)
{
AssemblyDocument assembly = Addin.Application.ActiveEditDocument as AssemblyDocument;
if (assembly != null && selectedEntities.Count == 1 && new NotchDefinitionFeature(assembly, selectedEntities[1]).Exists)
linearMenu.AddButton(m_editButton.ButtonDefinition, false, true, "AssemblyShowAssemblyFeatureDimsCtxCmd", false);
}
Then my button execute handler, which is also used for the button on the ribbon panel to create a new client feature, displays a dialog to edit the client feature. My event framework inserts the first parameter which could be avoided if we used a different handler for each button.
void OnExecute(ButtonDefinition events, NameValueMap context)
{
AssemblyDocument assembly = Addin.Application.ActiveEditDocument as AssemblyDocument;
if(assembly==null)
throw new Exception(events.DisplayName + " requires an active assembly document.");
object selected = (events.InternalName==m_editButton.InternalName && assembly.SelectSet.Count==1) ? assembly.SelectSet[1] : null;
NotchDefinitionFeature clientFeature = new NotchDefinitionFeature(assembly, selected);
new NotchDefinitionDialog(clientFeature);
}
Regards,
cadull