Esempio n. 1
0
        public async Task <string> BruteForceLight(Light light)
        {
            Random       random    = new Random();
            HueConnector connector = room.getConnector();

            while (bruteForce)
            {
                light.state.on = !light.state.on;
                light.updateAll("state");

                if (random.Next(10) >= 5)
                {
                    light.name = getRandomName();
                    await connector.changename(light);

                    light.updateAll("name");
                }
                light.state.hue = random.Next(65535);
                light.state.sat = random.Next(254);
                light.state.bri = random.Next(154) + 100;
                light.updateAll("color");
                string response = await connector.changestate(light, false);

                if (response == null)
                {
                    return("");
                }
            }
            return("");
        }
Esempio n. 2
0
        public async Task <string> getUsername(Room room)
        {
            HueConnector connector = new HueConnector(room);

            if (room.username == null)
            {
                var usernameresponse = await connector.getUsername("HueController");

                if (usernameresponse == null)
                {
                    return("-1");
                }
                return(JSONParser.getUsername(usernameresponse));
            }
            else
            {
                return(room.username);
            }
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.Parameter == null && connector != null && connector.room != null)
            {
                return;
            }
            if (e.Parameter is Room)
            {
                room      = (Room)e.Parameter;
                connector = room.getConnector();
            }
            lights = room.lights;
            if (!await getLights())
            {
                Frame.Navigate(typeof(RoomView), $"{((Room)e.Parameter).name} is not reachable!");
            }
        }
        public ColorChangeDialog(object e)
        {
            InitializeComponent();

            var collection = new GradientStopCollection();

            for (var i = 0; i < 100; i++)
            {
                collection.Add(new GradientStop {
                    Color = ColorUtil.getColor(655.35 * i, 254, 254), Offset = i / 100.0
                });
            }

            HueSlider.Background = new LinearGradientBrush
            {
                GradientStops = collection
            };

            if (((object[])e)[0] is Light)
            {
                lights = new List <Light> {
                    (Light)((object[])e)[0]
                }
            }
            ;
            if (((object[])e)[0] is List <Light> )
            {
                lights = (List <Light>)((object[])e)[0];
            }

            connector = (HueConnector)((object[])e)[1];


            if (lights.Count != 1)
            {
                NameBox.Visibility = Visibility.Collapsed;
            }
        }