Exemple #1
0
        private async Task FindRooms()
        {
            var rooms = await Common.hueClient.GetGroupsAsync();

            Common.Rooms          = new ObservableCollection <SensesGroup>();
            RoomsView.ItemsSource = Common.Rooms;

            foreach (Group room in rooms)
            {
                SensesGroup sensesRoom = new SensesGroup(room);
                Common.Rooms.Add(sensesRoom);
            }
        }
Exemple #2
0
        private List <string> GetLights(FrameworkElement element)
        {
            List <string> lights = new List <string>();

            if (typeof(SensesLight) == element.DataContext.GetType())
            {
                var light = (SensesLight)element.DataContext;
                var id    = light.Id;
                lights.Add(id);
            }
            else if (typeof(SensesGroup) == element.DataContext.GetType())
            {
                SensesGroup group = (SensesGroup)element.DataContext;
                lights.AddRange(group.Lights);
            }

            return(lights);
        }
Exemple #3
0
        private void BlinkAndExpand_Tap(Object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            Grid          grid   = (Grid)sender;
            List <string> lights = new List <string>();

            if (typeof(SensesLight) == grid.DataContext.GetType())
            {
                var light = (SensesLight)grid.DataContext;
                var id    = light.Id;
                lights.Add(id);
            }
            else if (typeof(SensesGroup) == grid.DataContext.GetType())
            {
                SensesGroup group = (SensesGroup)grid.DataContext;
                lights.AddRange(group.Lights);
            }

            var blink = new LightCommand();

            blink.Alert = Alert.Once;
            Common.hueClient.SendCommandAsync(blink, lights);
        }