private void LoadWindowPlugins() { string directory = Config.GetSubFolder(Config.Dir.Plugins, "windows"); if (!Directory.Exists(directory)) return; using (Settings xmlreader = new Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { string[] files = Directory.GetFiles(directory, "*.dll"); foreach (string pluginFile in files) { try { Assembly pluginAssembly = Assembly.LoadFrom(pluginFile); if (pluginAssembly != null) { Type[] exportedTypes = pluginAssembly.GetExportedTypes(); foreach (Type type in exportedTypes) { // an abstract class cannot be instanciated if (type.IsAbstract) continue; // Try to locate the interface we're interested in if (type.GetInterface("MediaPortal.GUI.Library.ISetupForm") != null) { try { // Create instance of the current type object pluginObject = Activator.CreateInstance(type); ISetupForm pluginForm = pluginObject as ISetupForm; if (pluginForm != null) { if (pluginForm.PluginName().Equals("Home")) continue; if (pluginForm.PluginName().Equals("my Plugins")) continue; if (pluginForm.PluginName().Equals("Topbar")) continue; //Works? string enabled = xmlreader.GetValue("plugins", pluginForm.PluginName()); if (enabled.CompareTo("yes") != 0) continue; string showInHome = xmlreader.GetValue("home", pluginForm.PluginName()); if (showInHome.CompareTo("no") == 0) { menuItem item = new menuItem(); item.name = pluginForm.PluginName(); item.hyperlink = pluginForm.GetWindowId(); item.bgImage = ""; item.media = ""; PluginmenuItems.Add(item); } if (showInHome.CompareTo("yes") == 0) { menuItem item = new menuItem(); item.name = pluginForm.PluginName(); item.hyperlink = pluginForm.GetWindowId(); item.bgImage = ""; item.media = ""; if (item.name == "TV" && tvhasbeenadded != true) // Fix for TV showing up two times in MP module-list. Bug? { tvhasbeenadded = true; HomemenuItems.Add(item); } else if (item.name != "TV") { HomemenuItems.Add(item); } } } } catch (Exception setupFormException) { Log.Info("Avalon plugin: Exception in plugin SetupForm loading :{0}", setupFormException.Message); Log.Info("Avalon plugin: Current class is :{0}", type.FullName); Log.Info(setupFormException.StackTrace); } } } } } catch (Exception unknownException) { Log.Info("Avalon plugin: Exception in plugin loading :{0}", unknownException.Message); Log.Info(unknownException.StackTrace); } } } // Manually add the plugins window menuItem item2 = new menuItem(); item2.name = "Plugins"; item2.hyperlink = 34; HomemenuItems.Add(item2); }