public HueLightShow(ColorGeneratorBase colorGenerator, HueLighting lighting) { this.ColorGenerator = colorGenerator; this.Lighting = lighting; // Instead of having a special case for the lightshow loop before the first set of colors has been generated, // we provide initial dummy values. this.mostRecentGeneratedColors = new GeneratedColors() { Colors = Enumerable.Range(0, this.ColorGenerator.NumberOfColors).Select(i => new LightColor()).ToArray() }; }
protected virtual void OnColorsGenerated(GeneratedColors generatedColors) { if (generatedColors.Colors.Length != this.NumberOfColors) { throw new ArgumentException("The number of generated colors must match NumberOfColors", "generatedColors"); } var ev = this.ColorsGenerated; if (ev != null) { ev(this, generatedColors); } }
private void ColorGenerator_ColorsGenerated(object sender, GeneratedColors e) { this.mostRecentGeneratedColors = e; }