private void SetByName(NamedColour colour) { Red = 0.0f; Green = 0.0f; Blue = 0.0f; switch (colour) { case NamedColour.Green: Green = 1.0f; break; case NamedColour.Yellow: Red = 1.0f; Green = 1.0f; break; case NamedColour.Red: Red = 1.0f; break; case NamedColour.White: Red = 1.0f; Green = 1.0f; Blue = 1.0f; break; case NamedColour.Black: default: break; } }
public INamedColourDetail GetNamedColourDetail(NamedColour namedColour) { INamedColourDetail namedColourDetail = null; IEnumerable<INamedColourDetail> namedColourEnumerator = this.GetNamedColourDetails(); foreach (INamedColourDetail namedColourDetailCandidate in namedColourEnumerator) { NamedColour namedColourInDetail = this.GetNamedColourFromDetail(namedColourDetailCandidate); if (namedColourInDetail == namedColour) { namedColourDetail = namedColourDetailCandidate; } } return namedColourDetail; }
public static string GetColourCssClass(NamedColour colour) { switch (colour) { case NamedColour.Default: return(String.Empty); case NamedColour.Blue: return(Blue); case NamedColour.Green: return(Green); case NamedColour.Orange: return(Orange); case NamedColour.Red: return(Red); case NamedColour.Purple: return(Purple); case NamedColour.Cyan: return(Cyan); default: throw new NotImplementedException(); } }
public async Task SetColourLightAsync(NamedColour namedColour, string lightName) { string lightID = await LightQuery.GetLightIDAsync(lightName); Dictionary<string, ILightDescription> lightDescriptions = await LightQuery.GetLightDescriptionsAsync(); ILightDescription lightDescription = lightDescriptions[lightName]; Gamut gamut = GetGamut(lightDescription); INamedColourDetail namedColourDetail = ColourQuery.GetNamedColourDetail(namedColour); string xyString = string.Empty; switch (gamut) { case Gamut.A: xyString = namedColourDetail.GamutA; break; case Gamut.B: xyString = namedColourDetail.GamutB; break; case Gamut.C: xyString = namedColourDetail.GamutC; break; } if (!string.IsNullOrEmpty(xyString)) { Uri RequestUri = new Uri("http://" + HueConfiguration.BridgeAddress + "/api/" + HueConfiguration.UserName + "/lights/" + lightID + "/state"); StringContent requestContent = new StringContent("{\"xy\" : " + xyString + "}"); HttpRequestMessage request = new HttpRequestMessage { Method = HttpMethod.Put, RequestUri = RequestUri, Content = requestContent }; using (var client = new HttpClient()) { HttpResponseMessage response = await client.SendAsync(request); } } }
public void ChangeTo(NamedColour colour) { SetByName(colour); }
public Colour(NamedColour colour) { SetByName(colour); }