diff --git a/HueUWP/APIHandler.cs b/HueUWP/APIHandler.cs index d8748d1..0aacfb2 100755 --- a/HueUWP/APIHandler.cs +++ b/HueUWP/APIHandler.cs @@ -13,7 +13,7 @@ namespace HueUWP { public class APIHandler { - + bool discomode = false; NetworkHandler nwh; public APIHandler(NetworkHandler nwh) @@ -52,8 +52,9 @@ namespace HueUWP public async void DiscoMode(ObservableCollection lights) { + discomode = true; Random rnd = new Random(); - for(int i = 0; i < 100; i++) + while(discomode) { lights.ToList().ForEach(l => { @@ -67,6 +68,11 @@ namespace HueUWP } + public async void DiscoMode(bool on) + { + discomode = on; + } + public async Task SetLightValues(Light l) { if(l.IsOn) diff --git a/HueUWP/MainPage.xaml b/HueUWP/MainPage.xaml index 67e4769..69cc931 100644 --- a/HueUWP/MainPage.xaml +++ b/HueUWP/MainPage.xaml @@ -61,7 +61,7 @@ - + diff --git a/HueUWP/MainPage.xaml.cs b/HueUWP/MainPage.xaml.cs index 315e90f..cd5358a 100644 --- a/HueUWP/MainPage.xaml.cs +++ b/HueUWP/MainPage.xaml.cs @@ -119,9 +119,12 @@ namespace HueUWP rootframe.Navigate(typeof(AboutView)); } - private void AppBarButton_Click(object sender, RoutedEventArgs e) + private void DiscoButton_Click(object sender, RoutedEventArgs e) { - api.DiscoMode(_lightsViewModel); + if ((bool)DiscoButton.IsChecked) + api.DiscoMode(_lightsViewModel); + else + api.DiscoMode(false); } } }