Exemple #1
0
 private static void RealStartPlugin(DarkPlugin plugin)
 {
     if (_mainWindow.InvokeRequired)
     {
         _mainWindow.Invoke(new MethodInvoker(delegate
         {
             //Lets check if the plugin author wants to handle exceptions.
             //ConsoleLog.WriteLine("loaded plugin with " + plugin.DebugMode.ToString());
             if (plugin.DebugMode)
             {
                 plugin.DarkPluginMain();
                 //plugin.MainForm.MdiParent = MainWindow._mainWindow;
             }
             else
             {
                 try
                 {
                     plugin.DarkPluginMain();
                     //plugin.MainForm.MdiParent = MainWindow._mainWindow;
                 }
                 catch (Exception e)
                 {
                     ConsoleLog.WriteError("A DarkPlugin has encountered an error!");
                     ConsoleLog.WriteError("Message: " + e.Message);
                     ConsoleLog.WriteError("StackTrace: " + e.StackTrace);
                     ConsoleLog.WriteError("Attributes: " + e.TargetSite.Attributes.ToString());
                 }
             }
         }));
     }
 }
Exemple #2
0
        public static Thread RunDarkPlugin(DarkPlugin plugin)
        {
            var t = new Thread(() => RealStartPlugin(plugin));

            t.Start();
            return(t);
        }
Exemple #3
0
 private void layoutView1_FieldValueClick(object sender, DevExpress.XtraGrid.Views.Layout.Events.FieldValueClickEventArgs e)
 {
     if (e.Column.ToString() == "Plugin")
     {
         if (Properties.Settings.Default.HaloOnlineFolder != "")
         {
             if (e.Column.ToString() != null)
             {
                 string key = e.FieldValue.ToString();
                 if (ProgramGlobals._Plugins.ContainsKey(key))
                 {
                     DarkPlugin plugin = ProgramGlobals._Plugins[key];
                     RunDarkPlugin(plugin);
                 }
             }
         }
         else
         {
             DevExpress.XtraEditors.XtraMessageBox.Show("Please first setup your Halo Online folder in `File -> Settings`.");
             ConsoleLog.WriteLine("Please first setup your Halo Online folder in `File -> Settings`.");
         }
     }
     else if (e.Column.ToString() == "URL")
     {
         Process.Start(e.FieldValue.ToString(), "");
     }
 }
Exemple #4
0
        public static ICollection <DarkPlugin> LoadPlugins(string path)
        {
            string[] dllFileNames = null;

            if (Directory.Exists(path))
            {
                dllFileNames = Directory.GetFiles(path, "*.dll");

                ICollection <Assembly> assemblies = new List <Assembly>(dllFileNames.Length);

                foreach (string dllFile in dllFileNames)
                {
                    // AssemblyName an = AssemblyName.GetAssemblyName(dllFile);

                    // Assembly assembly = Assembly.Load(an);


                    byte[]   assemblyBytes = File.ReadAllBytes(dllFile);
                    Assembly assembly      = Assembly.Load(assemblyBytes);
                    assemblies.Add(assembly);
                }

                Type pluginType = typeof(DarkPlugin);
                ICollection <Type> pluginTypes = new List <Type>();
                foreach (Assembly assembly in assemblies)
                {
                    if (assembly != null)
                    {
                        Type[] types = assembly.GetTypes();

                        foreach (Type type in types)
                        {
                            if (type.IsInterface || type.IsAbstract)
                            {
                                continue;
                            }
                            else
                            {
                                if (type.GetInterface(pluginType.FullName) != null)
                                {
                                    pluginTypes.Add(type);
                                }
                            }
                        }
                    }
                }

                plugins = new List <DarkPlugin>(pluginTypes.Count);
                foreach (Type type in pluginTypes)
                {
                    DarkPlugin plugin = (DarkPlugin)Activator.CreateInstance(type);
                    plugins.Add(plugin);
                }
                return(plugins);
            }
            return(null);
        }
Exemple #5
0
 public static void b_ClickMenuStrip(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (Properties.Settings.Default.HaloOnlineFolder != "")
     {
         if (e.Item.Caption != null)
         {
             string key = e.Item.Caption;
             if (ProgramGlobals._Plugins.ContainsKey(key))
             {
                 DarkPlugin plugin = ProgramGlobals._Plugins[key];
                 RunDarkPlugin(plugin);
             }
         }
     }
     else
     {
         DevExpress.XtraEditors.XtraMessageBox.Show("Please first setup your Halo Online folder in `File -> Settings`.");
         ConsoleLog.WriteLine("Please first setup your Halo Online folder in `File -> Settings`.");
     }
 }
 private static void RealStartPlugin(DarkPlugin plugin)
 {
     if (_mainWindow.InvokeRequired)
     {
         _mainWindow.Invoke(new MethodInvoker(delegate
         {
             //Lets check if the plugin author wants to handle exceptions.
             //ConsoleLog.WriteLine("loaded plugin with " + plugin.DebugMode.ToString());
             if (plugin.DebugMode)
             {
                 plugin.DarkPluginMain();
                 //plugin.MainForm.MdiParent = MainWindow._mainWindow;
             }
             else
             {
                 try
                 {
                     plugin.DarkPluginMain();
                     //plugin.MainForm.MdiParent = MainWindow._mainWindow;
                 }
                 catch (Exception e)
                 {
                     ConsoleLog.WriteError("A DarkPlugin has encountered an error!");
                     ConsoleLog.WriteError("Message: " + e.Message);
                     ConsoleLog.WriteError("StackTrace: " + e.StackTrace);
                     ConsoleLog.WriteError("Attributes: " + e.TargetSite.Attributes.ToString());
                 }
             }
         }));
     }
 }
 public static Thread RunDarkPlugin(DarkPlugin plugin)
 {
     var t = new Thread(() => RealStartPlugin(plugin));
     t.Start();
     return t;
 }