Пример #1
0
        /// <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>
        /// Activates the specified token
        /// </summary>
        /// <param name="token">The token to activate</param>
        public void ActivateToken(PluginToken token)
        {
            IExtension ext;
            if (_activeTokens == null) _activeTokens = new Dictionary<PluginToken, IExtension>();
            if (_activeTokens.ContainsKey(token))
            {
                ext = _activeTokens[token];
            }
            else
            {
                ext = token.CreateInstance<IExtension>();
                if (ext == null) return;
                _activeTokens.Add(token, ext);
            }


            IMapPlugin gp = ext as IMapPlugin;
            if (gp != null)
            {
                IMapPluginArgs args = new GeoPluginArgs(_map, _legend, _mainMenu, _toolStrip, _progressHandler, _geoPlugins, _toolStripContainer, _panelManager);
                gp.Initialize(args);
                _geoPlugins.Add(gp);
            }

            ext.Activate();     
          
        }
Пример #3
0
 /// <summary>
 /// Activates the specified token
 /// </summary>
 /// <param name="token">The token to activate</param>
 public void ActivateToken(PluginToken token)
 {
     IMapPlugin gp = null;
     if (_tokenPlugins.ContainsKey(token))
     {
         gp = _tokenPlugins[token];
     }
     else
     {
         gp = token.CreateInstance<IMapPlugin>();
         IMapPluginArgs args = new GeoPluginArgs(_map, _legend, _mainMenu, _toolStrip, _progressHandler, _geoPlugins, _toolStripContainer, _panelManager);
         gp.Initialize(args);
         _tokenPlugins.Add(token, gp);
     }
     
     _geoPlugins.Add(gp);
     gp.Activate();
     
 }