public static LifxBulb GetBulb(Byte[] bulbUID) { foreach (LifxPanController panController in panControllers.Values) { foreach (LifxBulb bulb in panController.Bulbs) { if (LifxHelper.ByteArrayToString(bulb.UID) == LifxHelper.ByteArrayToString(bulbUID)) { return(bulb); } } } throw new BulbNotFoundException(ErrorMessages.GetString("BulbNotFound")); }
async void Instance_PanControllerFound(object sender, LifxPanController e) { StorageHelper.StorePanController(e); foreach (LifxBulb bulb in e.Bulbs) { LifxLightStatusMessage lightstatusmessage = await StorageHelper.GetBulb(bulb.UID).GetLightStatusCommand(); if (lightstatusmessage != null) { StorageHelper.GetBulb(lightstatusmessage.ReceivedData.TargetMac).Label = lightstatusmessage.Label; StorageHelper.GetBulb(lightstatusmessage.ReceivedData.TargetMac).Tags = lightstatusmessage.Tags; StorageHelper.GetBulb(lightstatusmessage.ReceivedData.TargetMac).IsOn = lightstatusmessage.PowerState; StorageHelper.GetBulb(lightstatusmessage.ReceivedData.TargetMac).Colour = new LifxColour() { Hue = lightstatusmessage.Hue, Luminosity = lightstatusmessage.Lumnosity, Saturation = lightstatusmessage.Saturation, Kelvin = lightstatusmessage.Kelvin }; await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { NextPageButton.IsEnabled = true; LooksGoodTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible; BulbListBox.Visibility = Windows.UI.Xaml.Visibility.Visible; BulbListBox.Items.Add(new ListBoxItem() { Content = (lightstatusmessage.Label + " - " + LifxHelper.ByteArrayToString(lightstatusmessage.ReceivedData.TargetMac)) as string }); }); } } StorageHelper.SaveToStorage(); await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { Helper.HideProgressIndicator(); }); }