private void Button_Click(object sender, RoutedEventArgs e) { Button myButton = (Button)sender; HueLamp hl = myButton.DataContext as HueLamp; this.Frame.Navigate(typeof(SettingsLamp), hl); }
protected override void OnNavigatedTo(NavigationEventArgs e) { huelamp = (HueLamp)e.Parameter; NameLight.Text = huelamp.name; int r, g, b; huelamp.getRGBValue(out r, out g, out b); Red.Value = r; Green.Value = g; Blue.Value = b; SetOn.IsOn = huelamp.OnLamp; SolidColorBrush color = new SolidColorBrush(huelamp.getColor()); ColorChanger.Fill = color; }
public async void InitLights() { if ((await createUser("hueapplication")) == true) { //lampen String jsonreturn = await nw.GetCommand("api/" + apikey + "/lights"); JObject lampsjson = JObject.Parse(jsonreturn); foreach (var i in lampsjson) { JObject lamp = JObject.Parse(lampsjson["" + i.Key].ToString()); JObject lampstate = JObject.Parse(lamp["state"].ToString()); lamps.Add(hue = new HueLamp( this, i.Key, getKey(lampstate, "on"), getKey(lampstate, "bri"), getKey(lampstate, "hue"), getKey(lampstate, "sat"), "0", "0", getKey(lampstate, "ct"), getKey(lampstate, "alert"), getKey(lampstate, "effect"), getKey(lampstate, "colormode"), getKey(lampstate, "reachable"), getKey(lamp, "type"), getKey(lamp, "name"), getKey(lamp, "modelid"), getKey(lamp, "swversion") )); } //groepen jsonreturn = await nw.GetCommand("api/" + apikey + "/groups"); foreach (var i in JObject.Parse(jsonreturn)) { string groupinformation = await nw.GetCommand("api/" + apikey + "/groups/" + i.Key); JObject group = JObject.Parse(groupinformation); JObject groupaction; try { groupaction = JObject.Parse(group["action"].ToString()); } catch { groupaction = group; }; List <HueLamp> grouplamps = new List <HueLamp>(); foreach (var l in group["lights"]) { foreach (HueLamp h in lamps) { if (h.id == l.ToString()) { grouplamps.Add(h); } } } groups.Add(new HueGroup( this, i.Key, getKey(groupaction, "on"), getKey(groupaction, "bri"), getKey(groupaction, "hue"), getKey(groupaction, "sat"), "0", "0", getKey(groupaction, "ct"), getKey(groupaction, "alert"), getKey(groupaction, "effect"), getKey(groupaction, "colormode"), getKey(groupaction, "reachable"), getKey(group, "name"), grouplamps )); } } ; }