I am using the DotSpatial DemoMap
as the main frontend in my application, and I created a number of plugins to be loaded into DemoMap at launch and they are working. However, I am not very clear how to allow my custom plugins to access the main map control.
I see in the main form of DemoMap, there is App.Map
property as the handle to the main map control (am I right?), if this is true, then I suppose I need to pass it into each plugin when it is initiated?
Bottom line, what is the most efficient/best way to allow the main map control to be accessible throughout the entire application from all custom plugins? (I am using DotSpatial 2.0 libraries on .Net 4.5.2)
Derive from
Extension
and access theAppManger
-supplied map via theApp.Map
property.An extension (plugin) can access the map via the
App.Map
property. The is accessible to any class which derives fromExtension
so it doesn't need to be passed into the plugin. The AppManager which lets you access that property is injected via MEF automatically.Here's a sample extension