Ejemplo n.º 1
0
 /*
  * Update active groups
  */
 private void updateActiveGroups()
 {
     activeGroups.Clear();
     foreach (var item in GroupRooms.CheckedItems)
     {
         activeGroups.Add(groups[item.ToString()]);
         groupProperties tGroup = groups[item.ToString()];
         foreach (var tLight in tGroup.lights)
         {
             activeLights.Add(tLight.id);
         }
     }
 }
Ejemplo n.º 2
0
        /*
         * Initalise Form2 with stuff
         */
        public async void Form2Setup()
        {
            //Get bridges and groups
            Bridge bridgeAsync = await client.GetBridgeAsync();

            Group[] groupsAsync = bridgeAsync.Groups.ToArray();

            //Clear groupRooms
            GroupRooms.Items.Clear();
            GroupRooms.CheckOnClick = true;

            //Get lights
            IEnumerable <Light> lightsAsync = await client.GetLightsAsync();

            Light[] lightsArray = lightsAsync.ToArray();
            Dictionary <string, Light> allLights = new Dictionary <string, Light>();

            foreach (Light lightAsync in lightsArray)
            {
                allLights.Add(lightAsync.Id, lightAsync);
            }

            //Build groups
            foreach (Group group in groupsAsync)
            {
                groupProperties gProperty = new groupProperties(group.Id);
                foreach (String lightId in group.Lights)
                {
                    lightProperties newLight = new lightProperties(allLights[lightId]);
                    gProperty.lights.Add(newLight);
                }
                groups.Add(group.Name, gProperty);

                //Add checkboxes to form
                GroupRooms.Items.Add(group.Name);
            }

            //Set startup color for bounty alert
            setStartupBounyColor();
        }