You can assign an implementation of the INShapeCreatedListener interface to the ShapeCreatedListener property of the map importer in order to get notified when a diagram element is created from a map feature and imported in the drawing document. You can then directly modify the created diagram element to your liking. For your convenience you can also inherit from the NShapeCreatedListener class, which is an empty implementation of the INShapeCreatedListener interface. The following code example demonstrates how to add a tooltip to each of the created polygon shapes:
Custom shape created listener |
Copy Code
|
private class CustomShapeCreatedListener : NShapeCreatedListener
{
public override bool OnPolygonCreated(NDiagramElement element, NMapFeature mapFeature)
{
NShape shape = element as NShape;
if (shape == null)
return true;
string name = mapFeature.GetAttributeValue("CNTRY_NAME").ToString();
int population = Int32.Parse(mapFeature.GetAttributeValue("POP_CNTRY").ToString());
NInteractivityStyle interactivityStyle = new NInteractivityStyle(String.Format("{0} population: {1:N0}", name, population));
NStyle.SetInteractivityStyle(shape, interactivityStyle);
return true;
}
public override bool OnMultiPolygonCreated(NDiagramElement element, NMapFeature mapFeature)
{
return OnPolygonCreated(element, mapFeature);
}
}
|
You can then create an instance of this class and assign it to the ShapeCreatedListener of the map importer:
Attach to map importer |
Copy Code
|
mapImoprter.ShapeCreatedListener = new CustomShapeCreatedListener();
|