Ejemplo n.º 1
0
        protected void OnRemoveActionActivated(object sender, EventArgs e)
        {
            Gtk.ResponseType responseType  = Gtk.ResponseType.None;
            LoadedPlugins    loadedPlugins = new LoadedPlugins(plugins);

            try {
                responseType = (Gtk.ResponseType)loadedPlugins.Run();

                if (responseType == Gtk.ResponseType.Ok)
                {
                    Gtk.TreeModel  treeModel;
                    Gtk.TreeIter   iter;
                    Gtk.TreePath[] selectedRows = null;
                    selectedRows = loadedPlugins.treeView.Selection.GetSelectedRows();

                    for (int i = 0; i < selectedRows.Length; i++)
                    {
                        loadedPlugins.lsLoadedPlugins.GetIter(out iter, selectedRows[i]);
                        string          pluginPath = (string)loadedPlugins.lsLoadedPlugins.GetValue(iter, 0);
                        PluginInfo      pluginInfo = plugins.Plugins.Find(x => x.codeBase == pluginPath);
                        List <IService> services   = plugins.GetServices(pluginInfo);

                        foreach (IService service in services)
                        {
                            plugins.RemovePlugin(pluginInfo.codeBase);
                            (service as IPlugin).UnInit(null);
                        }
                    }
                }
            }
            finally {
                loadedPlugins.Hide();
            }
        }
Ejemplo n.º 2
0
 private void removePlugin(string pluginToDelete)
 {
     foreach (IPlugin plugin in plugins.GetServices <IPlugin>())
     {
         if (System.IO.Path.GetFileName(plugin.ToString()) == pluginToDelete)
         {
             plugin.UnInit(null);
         }
     }
     //plugins.RemovePlugin(pluginToDelete);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads a plugin using the Add command from the Plugins menu.
        /// </summary>
        /// <param name='sender'>
        /// Sender.
        /// </param>
        /// <param name='e'>
        /// Event args.
        /// </param>
        protected void OnAddActionActivated(object sender, EventArgs e)
        {
            var fc = new Gtk.FileChooserDialog("Choose the file to open", null,
                                               Gtk.FileChooserAction.Open, "Cancel",
                                               Gtk.ResponseType.Cancel, "Open", Gtk.ResponseType.Accept);

            try {
                fc.SelectMultiple = true;
                fc.SetCurrentFolder(Environment.CurrentDirectory);
                if (fc.Run() == (int)Gtk.ResponseType.Accept)
                {
                    PluginServiceContainer pluginsToAdd = new PluginServiceContainer();
                    for (int i = 0; i < fc.Filenames.Length; i++)
                    {
                        if (!plugins.Plugins.Exists(x => x.codeBase == fc.Filenames[i]))
                        {
                            plugins.AddPlugin(fc.Filenames[i]);
                            pluginsToAdd.AddPlugin(fc.Filenames[i]);
                        }
                    }

                    pluginsToAdd.LoadPlugins();
                    foreach (IPlugin p in pluginsToAdd.GetServices <IPlugin>())
                    {
                        p.Init(this);
                    }
                }
            } finally {
                fc.Destroy();
            }
        }