Not sure if you’ve already noticed it, but every button or menu item you see inside the Topobase panel comes from a plug-in. The entire Topobase architecture is based on plug-in technology. This gives of us all many possibilities to customize, configure and extend the Topobase solution. You’d like to see some examples? No problem. Here is a list that shows how you can extend Topobase with plug-ins:
- extend the context menu of a feature class with a new entry
- add new capabilities to the attributive form accessible through a button
- validate features before they are inserted or updated into the database
- maintain and extend the structure of your own data model automatically
In fact, many of the Autodesk Topobase components are based on plug-ins created by our developers. Some examples are the Workspace Management and Administration dialog, Map Interface, COGOs, and the reporting tool.
So let’s take a look at some code. In this code fragment you can see what a plug-in class looks like. This plug-in class extends the context menu of all point feature classes in the Document Explorer with one new menu item. The capabilities of the menu item can then be anything you like.
// Create a new class which is derived from our Document Plugin class.
// A Document Plugin will automatically be loaded per document when a workspace is opened.
public class MyDocument : Topobase.Forms.DocumentPlugin
{
// Create a new MenuItem object.
public Topobase.Forms.MenuItem myMenuItem1 = new Topobase.Forms.MenuItem();
// Override the OnInit method to add our own menu item.
public override void OnInitMenus(object sender, Topobase.Forms.Events.MenusEventArgs e)
{
// Obtain the context menu to which you want to add your new MenuItem.
Topobase.Forms.Menu pointMenu = e.Menus.Item(Topobase.Data.FeatureClassType.Point);
// Add your MenuItem with the text “My MenuItem1” to the context menu.
pointMenu.MenuItems.Add(myMenuItem1, "My MenuItem1");
// Add a click event handler to the menu item, there you can implement the logic.
myMenuItem1.Click += new MenuItemClickEventHandler(MyMenuItem1_Click);
}
... // other code
}
Take a look at the folder C:\Program Files\Autodesk Topobase Client 2008\Development. Then go to the Samples subfolder and take a look at Sample 10: 10_Document_ContextMenu. There you have a fully functional C# or VB.NET solution, which creates a plug-in and extends the context menu.