private async void allLightsOn() { var command = new LightCommand(); command.On = true; command.Brightness = 254; // to avoid switching on and still see nothing HueResults results = await client.SendCommandAsync(command); statusLabel.Text = gatherResults(results); foreach (System.Windows.Forms.Control control in flowLayoutPanel.Controls) { LightControl lc = (LightControl)control; lc.Resync(); } }
private async void allLightsOff() { var command = new LightCommand(); command.On = false; Task <HueResults> task = client.SendCommandAsync(command); HueResults results = await task; statusLabel.Text = gatherResults(results); foreach (System.Windows.Forms.Control control in flowLayoutPanel.Controls) { LightControl lc = (LightControl)control; lc.Resync(); } }
private async void setClient(bool value) { buttonAllOff.Enabled = buttonAllOn.Enabled = buttonBlink2.Enabled = value; flowLayoutPanel.SuspendLayout(); flowLayoutPanel.Controls.Clear(); if (value) { var lights = await client.GetLightsAsync(); if (lights != null) { foreach (Light light in lights) { LightControl ctrl = new LightControl(); ctrl.Light = light; ctrl.Client = client; flowLayoutPanel.Controls.Add(ctrl); } } } flowLayoutPanel.ResumeLayout(); }