Esempio n. 1
0
        private async void button_Click(object sender, RoutedEventArgs e)
        {
            int red   = 0;
            int green = 0;
            int blue  = 0;

            await api.Register();

            ObservableCollection <Bulb> bulbs = await api.GetAllLights(totalBulbs);

            HueCalculator hue = new HueCalculator();

            listBox.Items.Clear();
            foreach (Bulb bulb in bulbs)
            {
                listBox.Items.Add("Lamp " + bulb.id);
                bulb.on = true;

                bulb.hue = hue.CalculateHue(red, green, blue);
                bulb.bri = hue.CalculateLum(red, green, blue);
                bulb.sat = hue.CalculateSat(red, green, blue);
            }
            if (totalBulbs.Count > 0)
            {
                button.IsEnabled = false;
            }
        }