Added progress rings and error feedback

This commit is contained in:
2015-12-02 22:27:30 +01:00
parent a77bf79119
commit 2dfc29591d
6 changed files with 58 additions and 26 deletions
+15 -8
View File
@@ -20,17 +20,21 @@ namespace HueUWP
this.nwh = nwh;
}
public async Task Register()
public async Task<String> Register()
{
try {
var json = await nwh.RegisterName("Hue", "Kenneth&Yorick");
try
{
var json = await nwh.RegisterName("YK Hue", "YK");
json = json.Replace("[", "").Replace("]", "");
JObject o = JObject.Parse(json);
string id = o["success"]["username"].ToString();
MainPage.LOCAL_SETTINGS.Values["id"] = id; }
catch(Exception e)
MainPage.LOCAL_SETTINGS.Values["id"] = id;
return "success";
}
catch (Exception e)
{
Debug.WriteLine("Could not register.");
return "error";
}
}
@@ -45,15 +49,17 @@ namespace HueUWP
lights.ForEach(l => SetLightState(l));
}
public async void SetLightValues(Light l)
public async Task<String> SetLightValues(Light l)
{
if(l.IsOn)
{
Debug.WriteLine(l.Hue);
var json = await nwh.SetLightInfo(l.ID, $"{{\"bri\": {l.Brightness},\"hue\": {(l.Hue)},\"sat\": {l.Saturation}}}");
Debug.WriteLine(json);
return "success";
}
return "error";
}
public async void SetLightValues(List<Light> lights)
@@ -85,14 +91,15 @@ namespace HueUWP
// );
//lightlist.ForEach(q => alllights.Add(q));
return "success";
}
catch(Exception e)
{
Debug.WriteLine(e.StackTrace);
Debug.WriteLine("Could not get all lights.");
return "error";
}
return string.Empty;
}