Ejemplo n.º 1
0
        /// <summary>
        /// Stops a plugin.
        /// </summary>
        /// <param name="plugin">The plugin to stop</param>
        public static void Stop(Plugin plugin)
        {
            if (activePlugins.Contains(plugin))
            {
                if (plugin.OnStart())
                {
                    DispatchStopped(plugin);
                    activePlugins.Remove(plugin);

                    PluginSettings set = GetSettings(plugin.ID);
                    if (set != null)
                    {
                        set.Enabled = false;
                    }
                    PluginItem p = GetListItem(plugin.ID);
                    if (p != null)
                    {
                        p.Disabled = true;
                    }

                    if (activePlugins.Count == 0)
                    {
                        ticker.Dispose();
                        ticker = null;
                    }

                    if (plugin.Type == PluginType.Filter)
                    {
                        Plugins.Filter filter = plugin as Plugins.Filter;
                        filter.VolumeChanged -= Plugin_VolumeChanged;
                    }

                    U.L(LogLevel.Information, "PLUGIN", "Stopped plugin '" + plugin.ID + "'");
                }
                else
                {
                    U.L(LogLevel.Warning, "PLUGIN", "Could not stop plugin '" + plugin.ID + "'");
                }
            }
            else
            {
                U.L(LogLevel.Warning, "PLUGIN", "Won't stop not running plugin '" + plugin.ID + "'");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Starts a plugin.
        /// </summary>
        /// <param name="plugin">The plugin to start</param>
        public static void Start(Plugin plugin)
        {
            if (!activePlugins.Contains(plugin))
            {
                if (plugin.OnStart())
                {
                    DispatchStarted(plugin);
                    activePlugins.Add(plugin);
                    PluginSettings set = GetSettings(plugin.ID);
                    if (set != null)
                    {
                        set.Enabled = true;
                    }
                    PluginItem p = GetListItem(plugin.ID);
                    if (p != null)
                    {
                        p.Disabled = false;
                    }
                    if (ticker == null)
                    {
                        ticker = new Timer(Tick, null, 0, 30);
                    }

                    if (plugin.Type == PluginType.Filter)
                    {
                        Plugins.Filter filter = plugin as Plugins.Filter;
                        filter.VolumeChanged += Plugin_VolumeChanged;
                    }

                    U.L(LogLevel.Information, "PLUGIN", "Started plugin '" + plugin.ID + "'");
                }
                else
                {
                    U.L(LogLevel.Warning, "PLUGIN", "Could not start plugin '" + plugin.ID + "'");
                }
            }
            else
            {
                U.L(LogLevel.Warning, "PLUGIN", "Won't start running plugin '" + plugin.ID + "'");
            }
        }