- Open MyCtrlAction.cs.
MyCtrlAction.cs defines the action that will be performed when the control event is triggered. The class bound to the control must be inherited from the CtrlAction class or implement the ICtrlAction interface. Below is the CtrlAction.cs file.
- Rewrite the Run() method in MyCtrlAction.
The Run() method responds to the control event. In this example, when the corresponding control event is triggered, the Run() method will output the information about all plugins of SuperMap Deskpro .NET in the Output Window. To achieve this function, you need to replace the contents in the Run() method with the code below:
//Get the total number of plugins in the application program
Int32 pluginCount = SuperMap.Desktop.Application.ActiveApplication.PluginManager.Count;
//Traverse all plugins and output plugins information in the Output Window
for (Int32 index = 0; index < pluginCount; index++)
{
//Get the class object that defines the plugin
Plugin plugin = SuperMap.Desktop.Application.ActiveApplication.PluginManager[index];
//Get the info object of the plugin
PluginInfo pluginInfo = plugin.PluginInfo;
//Get the name of the plugin
String pluginName = pluginInfo.Name;
//Get the full path of the assembly where the plugin is located
String pluginAssemble = pluginInfo.AssemblyName;
//Output the plugin name and the assembly to which the plugin belongs in the Output Window
SuperMap.Desktop.Application.ActiveApplication.Output.Output("Plugin Name: " + pluginName + "\r\n" + "Assembly: " + pluginAssemble,InfoLevel.Information);
}
- Compile the MyCtrlAction project to generate MyCtrlAction.dll. For this example, you can find the assembly file in SuperMap iDesktop\SampleCode\MyCtrlAction\MyCtrlAction\obj\X86 after comiling.
- When you get MyCtrlAction.dll, you can configure it for the control event. Please refer to CtrlAction.