Register Ribbon Icon using ProcessNet

 

Figure 1  User Icon on Ribbon

 

The user can customize the ribbon layout and register ProcessNet function.

Following things are supported:

     Creation ribbon tab

     Creation ribbon group

     Creation ribbon icon

     Register the ProcessNet function to the icon

 

Creation custom group and icon

The user can create ribbon group and icon.

 

    Casting the ribbon Manager interface: IRibbonManager ribbonManager = application.RibbonManager;

    Find the ribbon tab “Customize”: IRibbonTab ribbonTab = ribbonManager.FindRibbonTab("Customize");

    Create the ribbon Group: IRibbonGroup ribbonGroup = ribbonTab.AddRibbonGroup("PNet Example");

    Create the ribbon icon : IMenuControl menuControl = ribbonGroup.AddMenuControl(MenuControlType.MenuControlType_Button, 8001);

 

Register ProcessNet function to ribbon icon

The user can register ProcessNet function to ribbon icon.

    Set using ProcessNet function: IMenuControl.UseProcessNetFunction = true

    Set the ProcessNet dll path: IMenuControl.ProcessNetDllPath = ProcessNetDllPath;

    Set the function name in the ProcessNet dll: IMenuControl.ProcessNetFunctionName = "CreateBodyExample";

Set the ProcessNet type : IMenuControl.ProcessNetType = ProcessNetType. ProcessNetType_VSTA

Sample Code

The user can use example code from ProcessNet example project

Project location : <Install dir> Help\Examples\ProcessNet

 

public void RegisterFunction ()

{

            IRibbonManager ribbonManager = application.RibbonManager;

            IRibbonTab ribbonTab = ribbonManager.FindRibbonTab("Customize");

            IRibbonGroup ribbonGroup = ribbonTab.AddRibbonGroup("PNet Example");

 

            //ID for user created processNet function must be between 8000 - 8999 .

            IMenuControl menuControl = ribbonGroup.AddMenuControl(MenuControlType.MenuControlType_Button, 8001);

 

            // Set example control information.          

            IntPtr iIcon = ProcessNet.Properties.Resources.example.GetHicon();

            menuControl.SetIcon(iIcon);

            menuControl.UseBigIcon = true;

            menuControl.Caption = "MyExample";

            menuControl.Tooltip = "MyTooltip";

            //menuControl.Description = "MyDescription";

            menuControl.UseProcessNetFunction = true; //if ID is not between 8000 - 8999, this can set ID to 8000

 

            // Get current ProcessNet dll fullpath. 'ProcessNetDllPath' must be absolute path.

            string assemblyname = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;

            string ProcessNetDllPath = AppDomain.CurrentDomain.BaseDirectory + @"\" + assemblyname + ".dll";

            menuControl.ProcessNetDllPath = ProcessNetDllPath;

            menuControl.ProcessNetFunctionName = "CreateBodyExample";

            menuControl.ProcessNetType = ProcessNetType. ProcessNetType_VSTA;

}

Note

If the user wants to Register ProcessNet function when startup, the function name should be changed as RegisterFunction instead of IRibbonManager

And then register the ProcessNet dll on ProcessNet Register dialog. Refer to click here