From 747c68bd1e9d4dfe31b2476d4460ce536dde4361 Mon Sep 17 00:00:00 2001 From: Jonathan Arndt Date: Wed, 16 Feb 2022 22:17:45 -0800 Subject: [PATCH] Updates to forEach loop sceneIndex to include local sceneIndex context --- .../PepperDashEssentialsBase/Lighting/LightingBase.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs index 569d2005..0549985c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs @@ -99,13 +99,18 @@ namespace PepperDash.Essentials.Core.Lighting var sceneIndex = 0; foreach (var scene in lightingDevice.LightingScenes) { - trilist.SetSigTrueAction((uint)(joinMap.SelectSceneDirect.JoinNumber + sceneIndex), () => lightingDevice.SelectScene(lightingDevice.LightingScenes[sceneIndex])); + var index1 = sceneIndex; + trilist.SetSigTrueAction((uint)(joinMap.SelectSceneDirect.JoinNumber + sceneIndex), () => + { + var index = index1; + Debug.Console(2, this, "LightingDevice: sceneIndex: {0} index: {1} > inside action", index1, index); + lightingDevice.SelectScene(lightingDevice.LightingScenes[index]); + }); scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.SelectSceneDirect.JoinNumber + sceneIndex)]); trilist.StringInput[(uint)(joinMap.SelectSceneDirect.JoinNumber + sceneIndex)].StringValue = scene.Name; trilist.BooleanInput[(uint)(joinMap.ButtonVisibility.JoinNumber + sceneIndex)].BoolValue = true; sceneIndex++; } - return joinMap; }