Hello,
Here is the code from Zookeeper which creates a main menu entry with some actions:
#region Menu And Actions
//private IPrimitive primZKLaunch;
IIMenu menuZookeeper = null;
IIMenuItem menuItemZookeeper = null;
IIMenuItem menuItemLaunch = null;
IIMenuItem menuItemReset = null;
uint idActionTable = 0;
IActionTable actionTable = null;
IActionCallback actionCallback = null;
private void MenusAndActionsUnregister()
{
if( actionTable != null )
{
Global.COREInterface.ActionManager.DeactivateActionTable( actionCallback, idActionTable );
}
// Clean up menu
if( menuZookeeper != null )
{
Global.COREInterface.MenuManager.UnRegisterMenu( menuZookeeper );
Global.ReleaseIMenu( menuZookeeper );
Global.ReleaseIMenuItem( menuItemLaunch );
Global.ReleaseIMenuItem( menuItemZookeeper );
menuZookeeper = null;
menuItemZookeeper = null;
menuItemZookeeper = null;
}
}
private void MenusAndActionsRegister()
{
//// Declare the global "ZKLaunch" function
//if( !manager.PostLoad )
//{
// primZKLaunch = global.MaxScript.Primitive( "ZKLaunch", Launch );
//}
//else
//{
// Log( "Unable to create 'ZKLaunch' MXS function because system is in a post-loaded state" );
//}
IIActionManager actionManager = global.COREInterface.ActionManager;
IIMenuManager menuManager = global.COREInterface.MenuManager;
IActionTable actionTable = null;
// Set up global actions
{
idActionTable = (uint)actionManager.NumActionTables;
//actionTable = Global.ActionTable.Create( idActionTable, 0, "Zookeeper Actions" );
string actionTableName = "Zookeeper Actions";
actionTable = Global.ActionTable.Create( idActionTable, 0, ref actionTableName );
actionTable.AppendOperation( new ActionLaunch() );
actionTable.AppendOperation( new ActionReset() );
actionCallback = new ZKActionCallback();
actionManager.RegisterActionTable( actionTable );
actionManager.ActivateActionTable( (ActionCallback)actionCallback, idActionTable );
}
// Set up menu
{
menuZookeeper = menuManager.FindMenu( "Zookeeper" );
if( menuZookeeper != null )
{
menuManager.UnRegisterMenu( menuZookeeper );
global.ReleaseIMenu( menuZookeeper );
menuZookeeper = null;
}
menuItemZookeeper = global.IMenuItem;
menuItemZookeeper.Title = "Zookeeper";
// Zookeeper menu
{
menuZookeeper = global.IMenu;
menuZookeeper.Title = "Zookeeper";
menuManager.RegisterMenu( menuZookeeper, 0 );
// Launch option
{
menuItemLaunch = global.IMenuItem;
menuItemLaunch.Title = "&Launch";
menuItemLaunch.ActionItem = actionTable[0];
menuZookeeper.AddItem( menuItemLaunch, -1 );
}
// Reset option
{
menuItemReset = global.IMenuItem;
menuItemReset.Title = "&Reset...";
menuItemReset.ActionItem = actionTable[1];
menuZookeeper.AddItem( menuItemReset, -1 );
}
}
menuItemZookeeper.SubMenu = menuZookeeper;
menuManager.MainMenuBar.AddItem( menuItemZookeeper, -1 );
global.COREInterface.MenuManager.UpdateMenuBar();
}
}
#endregion
ActionLaunch/ActionReset are classes derived from Plugins.ActionItem, and ZKActionCallback is derived from Plugins.ActionCallback.
Hope this helps, let me know if you need more help.
Marsel
Marsel Khadiyev (Software Developer, EPHERE Inc.)