Add a Button to the Main Form - Cloud - Author-it

Development Documentation

Use the ToolbarAddArgs class to add a button on the main form. The screen shot below shows a button named Hello Plug-in added to the XML and Data groups on the Manage ribbon in the Author book editor.

The code below is shows an example of adding the button plug-in shown above.

public class PluginManager : IPlugin

{

private AitApplicationProxy proxy; //Create a class-scoped field for the proxy

public PluginManager(AitApplicationProxy applicationProxy)

{

proxy = applicationProxy; //Set the field to the proxy passed to the plug-in

ToolbarAddArgs helloPluginButtonSmall = new ToolbarAddArgs(); //Initialize a new instance of the ToolbarAddArgs class

helloPluginButtonSmall.IconImage = Properties.Resources.debug_add_16; //Set the image to a resource in the assembly

helloPluginButtonSmall.OnClick = helloPluginButton_OnClick; //Set the OnClick event handler

helloPluginButtonSmall.PluginName = "Hello_Plugin_Small"; //Set the unique name for the button

helloPluginButtonSmall.TargetButtonName = "Hello\r\nPlug-in"; //Set the display text for the button

helloPluginButtonSmall.TargetForm = TargetForm.MainForm; //Set the form for the button

helloPluginButtonSmall.TargetGroupName = "XML"; //Set the ribbon group for the button

proxy.AddPluginToToolbar(helloPluginButtonSmall); //Use the proxy to add the button

ToolbarAddArgs helloPluginButtonLarge = new ToolbarAddArgs(); //Initialize a new instance of the ToolbarAddArgs class

helloPluginButtonLarge.IconImage = Properties.Resources.debug_add_32; //Set the image to a resource in the assembly

helloPluginButtonLarge.OnClick = helloPluginButton_OnClick; //Set the OnClick event handler

helloPluginButtonLarge.PluginName = "Hello_Plugin_Large"; //Set the unique name for the button

helloPluginButtonLarge.TargetButtonName = "Hello\r\nPlug-in"; //Set the display text for the button

helloPluginButtonLarge.TargetForm = TargetForm.MainForm; //Set the form for the button

helloPluginButtonLarge.TargetGroupName = "Data"; //Set the ribbon group for the button

proxy.AddPluginToToolbar(helloPluginButtonLarge); //Use the proxy to add the button

}

private void helloPluginButton_OnClick(Object sender, AuthoritEventArgs e)

{

//Plug-in code goes here

}

}