Add a Button to the Book Editor - Author-it On-Premises - Author-it

Author-it Development Documentation

Use the ToolbarAddArgs class to add a button to the book editor. The screen shot below shows a button named Hello Plugin added to the Show group on the View ribbon in the Author book editor.

The code below is shows an example of adding the button plugin shown above.

public class PluginManager : IPlugin //Inherit from the IPlugin interface so Author can communicate with your plugin

{

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 plugin

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

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

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

helloPluginButton.PluginName = "Hello_Plugin"; //Set the unique name for the button

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

helloPluginButton.TargetForm = TargetForm.BookEditor; //Set the form for the button

helloPluginButton.TargetGroupName = "Show"; //Set the ribbon group for the button

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

}

private void helloPluginButton_OnClick(Object sender, AuthoritEventArgs e)

{

//Plugin code goes here

}

}