private void UsePlugin() { if (cbAvailablePlugIns.SelectedIndex <= 0) { return; } var plugIn = OutputPlugins.FindPlugin(cbAvailablePlugIns.SelectedItem.ToString(), true); var node = _setupData.CreatePlugInData(plugIn); Xml.SetAttribute(node, PlugInAttrStartCh, DefaultChannel.ToString(CultureInfo.InvariantCulture)); Xml.SetAttribute(node, PlugInAttrEndCh, _channels.Count.ToString(CultureInfo.InvariantCulture)); Cursor = Cursors.WaitCursor; try { InitializePlugin(plugIn, node); } catch (Exception exception) { MessageBox.Show(string.Format(Resources.PluginSetupErrorInvalidStatePossible, exception.Message), Vendor.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { Cursor = Cursors.Default; } AddPlugInRow(node, plugIn); }
private void PluginListDialog() { var executableObject = _contextProfile; _setupData = executableObject.PlugInData; _executableObject = executableObject; Cursor = Cursors.WaitCursor; List <IHardwarePlugin> hardwarePlugins; try { hardwarePlugins = OutputPlugins.LoadPlugins(); OutputPlugins.VerifyPlugIns(_executableObject); } finally { Cursor = Cursors.Default; } _channels = executableObject.Channels; _sequencePlugins = new List <IHardwarePlugin>(); if (cbAvailablePlugIns.Items.Count > 0 || null == hardwarePlugins) { return; } cbAvailablePlugIns.Items.Clear(); cbAvailablePlugIns.Items.Add("Please select a plug in to add"); foreach (var plugin in hardwarePlugins) { cbAvailablePlugIns.Items.Add(plugin.Name); } cbAvailablePlugIns.SelectedIndex = 0; }
private void InitializePlugInTab() { PluginListDialog(); Cursor = Cursors.WaitCursor; try { _internalUpdate = true; _lastRow = NoRow; dgvPlugIns.Rows.Clear(); foreach (XmlNode node in _setupData.GetAllPluginData()) { var plugin = node.Attributes != null && (node.Attributes[PlugInAttrName] != null) ? OutputPlugins.FindPlugin(node.Attributes[PlugInAttrName].Value, true) : null; if (plugin == null) { continue; } InitializePlugin(plugin, node); AddPlugInRow(node, plugin); } _internalUpdate = false; } finally { Cursor = Cursors.Default; _internalUpdate = true; dgvPlugIns.Focus(); _internalUpdate = false; SetPluginsTabButtons(); } }
protected Output(SerializationInfo info, StreamingContext context) { try { ColorTransformerConfigs = (IList <ColorTransformerConfig>)info.GetValue("ColorTransformerConfigs", typeof(IList <ColorTransformerConfig>)); } catch (SerializationException) { } string pluginName = info.GetString("OutputPluginName"); if (!string.IsNullOrEmpty(pluginName)) { IOutputPlugin outputPlugin = OutputPlugins.GetOutputPlugin(pluginName); if (outputPlugin == null) { throw new SerializationException(string.Format("Error while deserializing: Output plugin {0} not found", pluginName)); } IOutputInfo outputInfo = outputPlugin.GetNewOutputInfo(); outputInfo.Deserialize((Dictionary <string, string>)info.GetValue("OutputInfoDictionary", typeof(Dictionary <string, string>))); OutputInfo = outputInfo; } }
public ChangeOutputForm() { InitializeComponent(); _plugins = OutputPlugins.GetAvailablePlugins(); outputPluginsDropDown.DisplayMember = "DisplayName"; if (_plugins.Count == 0) { okButton.Enabled = false; } else { outputPluginsDropDown.Items.AddRange(_plugins.Cast <object>().ToArray()); outputPluginsDropDown.SelectedIndex = 0; } }
private void Compose() { AfterglowRuntime.Logger.Info("Loading Plugins..."); string folder = Path.Combine((new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location)).Directory.FullName, PLUGINS_DIRECTORY); var catalog = new DirectoryCatalog(folder); var container = new CompositionContainer(catalog); try { container.ComposeParts(this); AfterglowRuntime.Logger.Info("The following plugins were loaded"); if (LightSetupPlugins != null && LightSetupPlugins.Any()) { LightSetupPluginTypes.ToList().ForEach(p => AfterglowRuntime.Logger.Info("Type: Light Setup Plugin Name: {0}", p.Name)); } else { AfterglowRuntime.Logger.Fatal("No Light Setup Plugins were loaded"); } if (CapturePlugins != null && CapturePlugins.Any()) { CapturePluginTypes.ToList().ForEach(p => AfterglowRuntime.Logger.Info("Type: Capture Plugin Name: {0}", p.Name)); } else { AfterglowRuntime.Logger.Fatal("No Capture Plugins were loaded"); } if (ColourExtractionPlugins != null && ColourExtractionPlugins.Any()) { ColourExtractionPluginTypes.ToList().ForEach(p => AfterglowRuntime.Logger.Info("Type: Colour Extraction Plugin Name: {0}", p.Name)); } else { AfterglowRuntime.Logger.Info("No Colour Extraction Plugins were loaded"); } if (PostProcessPlugins != null && PostProcessPlugins.Any()) { PostProcessPluginTypes.ToList().ForEach(p => AfterglowRuntime.Logger.Info("Type: Post Process Plugin Name: {0}", p.Name)); } else { AfterglowRuntime.Logger.Info("No Post Process Plugins were loaded"); } if (PreOutputPlugins != null && PreOutputPlugins.Any()) { PreOutputPluginTypes.ToList().ForEach(p => AfterglowRuntime.Logger.Info("Type: Pre Output Plugin Name: {0}", p.Name)); } else { AfterglowRuntime.Logger.Info("No Pre Output Plugins were loaded"); } if (OutputPlugins != null && OutputPlugins.Any()) { OutputPluginTypes.ToList().ForEach(p => AfterglowRuntime.Logger.Info("Type: Output Plugin Name: {0}", p.Name)); } else { AfterglowRuntime.Logger.Fatal("No Output Plugins were loaded"); } } catch (System.Reflection.ReflectionTypeLoadException reflectionTypeLoadException) { foreach (Exception exception in reflectionTypeLoadException.LoaderExceptions) { AfterglowRuntime.Logger.Fatal(exception, "Plugin Loader"); } } finally { AfterglowRuntime.Logger.Info("Plugin Loading Complete"); } }
private void ApplyConfig(AmbiLightConfig config) { if (_screenCaptureService != null) { _screenCaptureService.Dispose(); } _screenCaptureService = _screenCaptureServiceProvider.Provide(true); List <IOutputPlugin> plugins = OutputPlugins.GetAvailablePlugins(); List <ScreenRegionOutput> regions = config.RegionsToOutput; if (_regionConfigurations != null) { foreach (RegionConfiguration regionConfiguration in _regionConfigurations) { regionConfiguration.Dispose(); } } _regionConfigurations = new List <RegionConfiguration>(); var regionConfigId = 0; foreach (ScreenRegionOutput region in regions) { var regionConfig = new RegionConfiguration(regionConfigId++) { ScreenRegion = region.ScreenRegion, ColorAveragingService = _colorAveragingServiceProvider.Provide(region.ColorAveragingConfig), OutputConfigs = new List <OutputConfiguration>() }; var outputId = 0; foreach (Output output in region.Outputs) { IOutputInfo outputInfo = output.OutputInfo; IOutputPlugin plugin = plugins.FirstOrDefault(y => y.Name == outputInfo.PluginName); if (plugin == null) { throw new InvalidOperationException(string.Format("Missing OutputPlugin {0}", outputInfo.PluginName)); } OutputService outputService = _regionConfigurations.SelectMany(x => x.OutputConfigs).Select(x => x.OutputService).FirstOrDefault(x => x.IsReusableFor(outputInfo)) ?? plugin.GetNewOutputService(); outputService.Initialize(outputInfo); IList <ColorTransformerConfig> colorTransformerConfigs = output.ColorTransformerConfigs; if (colorTransformerConfigs == null) { colorTransformerConfigs = new List <ColorTransformerConfig> { new ColorTransformerConfig { Type = typeof(HysteresisColorTransformer), Config = new Dictionary <string, object> { { "hysteresis", "0.01" } } }, new ColorTransformerConfig { Type = typeof(BrightnessColorTransformer), Config = new Dictionary <string, object> { { "factorR", "1" }, { "factorG", "1" }, { "factorB", "0.9" } } }, //new ColorTransformerConfig //{ // Type = typeof (GammaColorTransformer), // Config = new Dictionary<string, object> // { // {"gammaR", "1"}, // {"gammaG", "1.2"}, // {"gammaB", "1.2"} // } //}, new ColorTransformerConfig { Type = typeof(ThresholdColorTransformer), Config = new Dictionary <string, object> { { "threshold", "0.01" } } } }; } var outputConfig = new OutputConfiguration(regionConfig.Id, outputId++) { ColorTransformerContexts = colorTransformerConfigs.Select(x => new ColorTransformerContext(x)).ToList(), OutputService = outputService, ResendIntervalFunc = outputService.GetResendInterval, OutputInfo = outputInfo }; regionConfig.OutputConfigs.Add(outputConfig); } _regionConfigurations.Add(regionConfig); } _screenRegions = _regionConfigurations.Select(x => x.ScreenRegion).ToList(); }