/// <summary> /// Forces this component to add its plugin members /// </summary> public void Update() { _tokenManager = new TokenManager(); _tokenManager.Directories = _directories; _tokenManager.UpdateStore(); if (_mainMenu != null) { ToolStripItem[] items = _mainMenu.Items.Find(MessageStrings.Plugins, true); ToolStripMenuItem mi = null; if (items.Length > 0) mi = items[0] as ToolStripMenuItem; if (mi == null) mi = _mainMenu.Items.Add(MessageStrings.Plugins) as ToolStripMenuItem; IMapPluginArgs args = new GeoPluginArgs(_map, _legend, _mainMenu, _toolStrip, _progressHandler, _geoPlugins, _toolStripContainer, _panelManager); foreach (PluginToken token in _tokenManager.Tokens) { bool isGeoPlugin = false; Type[] interfaces = token.PluginType.GetInterfaces(); foreach (Type t in interfaces) { if (t == typeof(IMapPlugin)) { isGeoPlugin = true; break; } } ToolStripMenuItem tsmi = new ToolStripMenuItem(token.Name); tsmi.Click += new EventHandler(tsmi_Click); tsmi.Image = Images.InactivePlugin.ToBitmap(); tsmi.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; tsmi.Tag = token; mi.DropDownItems.Add(tsmi); if (token.Enabled == true && isGeoPlugin) { IMapPlugin gp = token.CreateInstance<IMapPlugin>(); if(gp != null) { gp.Initialize(args); _geoPlugins.Add(gp); mi.Checked = true; } } } } }
/// <summary> /// Forces this component to add its plugin members /// </summary> public void Update() { _tokenManager = new TokenManager(); _tokenManager.Directories = _directories; _tokenManager.UpdateStore(); if (_mainMenu != null) { //ToolStripItem[] items = _mainMenu.Items.Find("Extensions", true); //ToolStripMenuItem mi = null; //if (items.Length > 0) mi = items[0] as ToolStripMenuItem; ToolStripMenuItem mi = _mainMenu.Items.Add(MessageStrings.Extensions) as ToolStripMenuItem; ToolStripMenuItem pluginMenu = null; if (mi != null) { if (mi.DropDownItems.ContainsKey(MessageStrings.Plugins)) { pluginMenu = mi.DropDownItems[MessageStrings.Plugins] as ToolStripMenuItem; } else { pluginMenu = mi.DropDownItems.Add(MessageStrings.Plugins) as ToolStripMenuItem; if (pluginMenu != null) { pluginMenu.Image = Images.PluginSubmenu.ToBitmap(); pluginMenu.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; } } } //IMapPluginArgs args = new GeoPluginArgs(_map, _legend, _mainMenu, _toolStrip, _progressHandler, _geoPlugins, _toolStripContainer); foreach (PluginToken token in _tokenManager.Tokens) { if (token.CanBecome(typeof(IMapPlugin))) { ToolStripMenuItem tsmi = new ToolStripMenuItem(token.Name); tsmi.Click += tsmi_Click; tsmi.Image = Images.InactivePlugin.ToBitmap(); tsmi.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; tsmi.Tag = token; if (pluginMenu != null) pluginMenu.DropDownItems.Add(tsmi); // Plugins don't activate right away. } else { // If it isn't a plug-in, it should be a provider, which should load. ActivateToken(token); } } } }