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(); }