/// <summary> /// Initializes a new instance of the <see cref="MapListener" /> class. /// </summary> /// <param name="context">The application context.</param> /// <param name="plugin">The plugin.</param> /// <param name="sampleDockWindow">Reference to the sample dock window</param> public MapListener(IAppContext context, InitPlugin plugin, SampleDockWindow sampleDockWindow) { // Check input: if (context == null) { throw new ArgumentNullException("context"); } if (plugin == null) { throw new ArgumentNullException("plugin"); } if (sampleDockWindow == null) { throw new ArgumentNullException("sampleDockWindow"); } // Save local references: _context = context; _sampleDockWindow = sampleDockWindow; // As show case: Debug.WriteLine("Number of loaded layers; " + _context.Layers.Count); // Create event handlers: plugin.ExtentsChanged += PluginOnExtentsChanged; plugin.ChooseLayer += PluginOnChooseLayer; plugin.LayerSelected += PluginOnLayerSelected; }
/// <summary> /// The initialize method, called when the plug-in is loaded /// </summary> /// <param name="context">The application context.</param> public override void Initialize(IAppContext context) { // Save to local properties: _context = context; // Will better to preserve state if plugin is unloaded, therefore singleton // Because SampleDockWindow is injected in MenuListener and MapListener it should be call before them: _sampleDockWindow = context.Container.GetSingleton <SampleDockWindow>(); _menuGenerator = context.Container.GetInstance <MenuGenerator>(); _menuListener = context.Container.GetInstance <MenuListener>(); _mapListener = context.Container.GetInstance <MapListener>(); // Event handlers are in the MapListener class: // Just to show case: Debug.WriteLine("Number of layers loaded" + _context.Layers.Count()); // adding all the available tools in the toolbox _context.Toolbox.AddTools(GetType().Assembly.GetTools()); }