public PluginSettingsWindow(WsapmPluginAdvancedBase plugin) { InitializeComponent(); this.plugin = plugin; this.plugin.LoadSettings(); if (this.plugin.SettingsControl != null && this.plugin.SettingsControl is UserControl) { UserControl control = (UserControl)this.plugin.SettingsControl; this.settingsWindowContentPresenter.Content = control; //this.settingsWindowContentPresenter.Height = control.Width; //this.settingsWindowContentPresenter.Width = control.Height; } else { var control = this.plugin.SettingsControl as System.Windows.Forms.UserControl; if (control != null) { var host = new WindowsFormsHost(); host.Child = control; this.settingsWindowContentPresenter.Content = host; //this.settingsWindowContentPresenter.Height = width; //this.settingsWindowContentPresenter.Width = height; } } }
/// <summary> /// Prepares, checks the policies and tears down all loaded plugins. /// </summary> /// <param name="activatedPlugins">The list of activated plugins.</param> /// <returns>The result of the check as PluginCheckSuspendResult.</returns> public CheckSuspendResult CheckPluginPolicies(List <Guid> activatedPlugins) { var checkResult = new CheckSuspendResult(false, String.Empty); if (activatedPlugins == null || activatedPlugins.Count == 0 || this.pluginLoader.Plugins == null || this.pluginLoader.Plugins.Length == 0) { return(checkResult); } foreach (var plugin in this.pluginLoader.Plugins) { // Skip non activated plugins. if (!activatedPlugins.Contains(plugin.PluginAttribute.PluginGuid)) { continue; } // Skip plugins which are not initialized. if (!plugin.IsInitialized) { continue; } // First load current settings (if any), then prepare, then check - plugin by plugin. try { // Load settings only if it is an advanced plugin. WsapmPluginAdvancedBase pluginAdvanced = plugin as WsapmPluginAdvancedBase; if (pluginAdvanced != null) { pluginAdvanced.LoadSettings(); } // Prepare. plugin.PreparePlugin(); WsapmLog.Log.WriteLine(String.Format(Resources.Wsapm_Core.PluginManager_PluginPrepared, plugin.PluginAttribute.Name), LogMode.Verbose); } catch (Exception ex) { WsapmLog.Log.WriteError(String.Format(Resources.Wsapm_Core.PluginManager_ErrorPluginPrepare, plugin.PluginAttribute.Name), ex); continue; } // Skip plugins which were not prepared. if (!plugin.IsPrepared) { continue; } try { WsapmLog.Log.WriteLine(String.Format(Resources.Wsapm_Core.PluginManager_PluginCheckPolicy, plugin.PluginAttribute.Name), LogMode.Normal); var checkResultPlugin = plugin.CheckPluginPolicyForPlugin(); if (checkResultPlugin.SuspendStandby) { checkResult = CheckSuspendResult.FromPluginCheckSuspendResult(checkResultPlugin, plugin); break; } } catch (Exception ex) { WsapmLog.Log.WriteError(String.Format(Resources.Wsapm_Core.PluginManager_ErrorPluginCheckPolicy, plugin.PluginAttribute.Name), ex); } finally { // Make sure that the plugin gets teared down. try { WsapmLog.Log.WriteLine(String.Format(Resources.Wsapm_Core.PluginManager_PluginTearedDown, plugin.PluginAttribute.Name), LogMode.Verbose); plugin.TearDownPlugin(); } catch (Exception ex) { WsapmLog.Log.WriteError(String.Format(Resources.Wsapm_Core.PluginManager_ErrorPluginTearDown, plugin.PluginAttribute.Name), ex); } } } return(checkResult); }