Exemplo n.º 1
0
 /// <summary>
 /// Shutdown the plugin
 /// </summary>
 public void ShutdownPlugin()
 {
     try
     {
         this.Log().Debug("Shutting down plugin {0}", m_plugin.GetType().Name);
         m_plugin.Shutdown();
     }
     catch (Exception ex)
     {
         this.Log().Error("Failed to shutdown plugin {0} - {1}", m_plugin.GetType().Name, ex.Message);
     }
 }
Exemplo n.º 2
0
        public FigureParameters(AbstractPlugin figure) : this()
        {
            Type figureType = figure.GetType();

            foreach (PropertyInfo pi in figureType.GetProperties())
            {
                if (pi.Name != "GraphicsPath" && pi.Name != "Pen")
                {
                    this.AddLabel(pi.Name);
                    this.AddNumericUpDown(pi.Name, (int)pi.GetValue(figure));
                }
            }

            this.Draw_button.Click += (sender, args) =>
            {
                foreach (PropertyInfo pi in figureType.GetProperties())
                {
                    if (pi.Name != "GraphicsPath" && pi.Name != "Pen")
                    {
                        pi.SetValue(figure,
                                    (int)(this.ElementsPanel.Controls[pi.Name + NumericUpDownPostfix] as NumericUpDown).Value);
                    }
                }

                this.DialogResult = DialogResult.OK;
            };
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns a list of command info.
        /// </summary>
        /// <param name="plugin"></param>
        /// <param name="listCommands"></param>
        /// <returns></returns>
        public static List <string> ListInfo(this AbstractPlugin plugin, bool listCommands)
        {
            List <string> ret = new List <string>
            {
                "Plugin Name: " + plugin.GetType().Name,
                "Plugin Namespace: " + plugin.GetType().Namespace,
                "Plugin Version: " + plugin.GetType().Assembly.GetName().Version,
                "Plugin Include Global: " + plugin.IncludeGlobal,
                "Plugin Prefixes: " + plugin.Prefix.Unpack(", ")
            };

            if (listCommands)
            {
                ret.Add("Plugin Commands:");
                ret.AddRange(ListAllCommands(plugin.Info, plugin.Prefix));
            }
            ret.Add("");
            return(ret);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Add an individual to the master list.
 /// </summary>
 /// <param name="plugin">The plugin instance to add.</param>
 public bool AddPlugin(AbstractPlugin plugin)
 {
     lock (m_pluginsAvailable)
     {
         if (m_pluginsAvailable.ContainsKey(plugin.UUID))
         {
             this.Log().Warn("Plugin with UUID '{0}' is already registered.", plugin.UUID);
             return(false);
         }
         this.Log().Debug("Adding plugin {0} (ID = '{1}')", plugin.GetType().Name, plugin.UUID);
         m_pluginsAvailable[plugin.UUID] = plugin;
     }
     return(true);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Converts the Plugin to a basic markdown text that can be used to generate readmes.
        /// </summary>
        /// <param name="plugin">The plugin to list</param>
        /// <returns>The plugin description in markdown</returns>
        public static string[] ToMarkdown(this AbstractPlugin plugin)
        {
            List <string> ret = new List <string>
            {
                "______________________________________________",
                "#### " + plugin.GetType().Name + " Information:",
                "",
                "* Prefix: " + plugin.Prefix.Unpack(", "),
                "* Commands:",
                ""
            };

            ret.AddRange(ToMarkdown(plugin.Info));
            return(ret.ToArray());
        }
Exemplo n.º 6
0
        /// <summary>
        /// Converts the Plugin to a basic markdown text that can be used to generate readmes.
        /// </summary>
        /// <param name="plugin"></param>
        /// <returns></returns>
        public static string[] ToMarkdown(this AbstractPlugin plugin)
        {
            List <string> ret = new List <string>()
            {
                "______________________________________________",
                "#### " + plugin.GetType().Name + " Information:",
                "",
                "* Prefix: " + plugin.Prefix.Unpack(", "),
                "* Commands:",
                ""
            };

            string tab = "\t\t";

            for (int i = 0; i < plugin.Info.Count; i++)
            {
                string[] helpt = plugin.Info[i].HelpText.Split("\n");
                ret.Add(tab + plugin.Info[i].Command + "/" + plugin.Info[i].ShortCut);
                ret.Add(tab + "\t" + helpt.Unpack("\n\t" + tab));
            }

            return(ret.ToArray());
        }
Exemplo n.º 7
0
 public static void AddPlugin(AbstractPlugin plugin)
 {
     logger.Debug("Registered plugin {0}", plugin.GetType());
     Plugins.Add(plugin);
 }