//private async void PowerToggleSwitch_Toggled(object sender, RoutedEventArgs e) //{ // if (((ToggleSwitch)sender).IsOn) // { // Helper.ShowProgressIndicator("Turning on..."); // foreach (LifxBulb bulb in StorageHelper.SelectedBulbs) // { // LifxPowerStateMessage psm = await bulb.SetPowerStateCommand(LifxPowerState.On); // await HandlePowerStateMessage(psm, bulb); // } // Helper.HideProgressIndicator(); // } // else // { // Helper.ShowProgressIndicator("Turning off..."); // SetControlState(false); // foreach (LifxBulb bulb in StorageHelper.SelectedBulbs) // { // LifxPowerStateMessage psm = await bulb.SetPowerStateCommand(LifxPowerState.Off); // await HandlePowerStateMessage(psm, bulb); // } // Helper.HideProgressIndicator(); // } //} private async void SyncBulbAppBarButton_Click(object sender, RoutedEventArgs e) { Helper.ShowProgressIndicator("Syncing..."); foreach (LifxBulb bulb in StorageHelper.SelectedBulbs) { LifxLightStatusMessage lsm = await bulb.GetLightStatusCommand(); PowerStateAppBarToggleButton.IsChecked = lsm.PowerState == LifxPowerState.On ? true : false; //PowerToggleSwitch.IsOn = lsm.PowerState == LifxPowerState.On ? true : false; if (StorageHelper.SelectedType == SelectionType.IndividualBulb) { MainPivot.Title = APP_HEADING_TEXT + lsm.Label; } bulb.Colour = new LifxColour() { Hue = lsm.Hue, Saturation = lsm.Saturation, Luminosity = lsm.Lumnosity, Kelvin = lsm.Kelvin }; bulb.Label = lsm.Label; bulb.Tags = lsm.Tags; bulb.IsOn = lsm.PowerState; } StorageHelper.SaveToStorage(); Helper.HideProgressIndicator(); }
private async void SetColour() { LifxColour colour = new LifxColour() { Hue = (UInt16)HueSlider.Value, Saturation = (UInt16)SaturationSlider.Value, Luminosity = (UInt16)LuminositySlider.Value, Kelvin = (UInt16)(KelvinSlider.Value) }; foreach (LifxBulb bulb in StorageHelper.SelectedBulbs) { if (FadeTimeSlider.Value > 0) { await bulb.SetWaveformCommand(0, 0, colour, Convert.ToUInt32(FadeTimeSlider.Value), 1f, 1, Waveform.Sine); } else { await bulb.SetColorCommand(colour, 0); } bulb.Colour = colour; } StorageHelper.SaveToStorage(); }
private void HandleLightStatusMessage(LifxLightStatusMessage message, LifxBulb bulb) { if (message != null) { FadeTimeSlider.Value = message.Dim; bulb.Colour = new LifxColour() { Hue = message.Hue, Saturation = message.Saturation, Luminosity = message.Lumnosity, Kelvin = message.Kelvin }; bulb.Label = message.Label; bulb.Tags = message.Tags; bulb.IsOn = message.PowerState; StorageHelper.SaveToStorage(); if (firstLightStatusFlag) { UnBindValueChangedEventHandlers(); HueSlider.Value = message.Hue; SaturationSlider.Value = message.Saturation; LuminositySlider.Value = message.Lumnosity; KelvinSlider.Value = message.Kelvin; BindValueChangedEventHandlers(); firstLightStatusFlag = false; } } }
async void EditBulbDialog_Closed(ContentDialog sender, ContentDialogClosedEventArgs args) { LifxLabelMessage llm = await StorageHelper.SelectedBulbs[0].SetLabelCommand(((sender.Content as StackPanel).Children[1] as TextBox).Text); StorageHelper.SelectedBulbs[0].Label = llm.BulbLabel; StorageHelper.SaveToStorage(); await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (StorageHelper.SelectedType == SelectionType.IndividualBulb) { MainPivot.Title = APP_HEADING_TEXT + llm.BulbLabel; } }); }
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(); }); }
async void bulbPowerState_Tapped(object sender, TappedRoutedEventArgs e) { powerStateTapped = true; TextBlock powerTextBlock = sender as TextBlock; if (powerTextBlock != null) { LifxBulb bulb = StorageHelper.GetBulb(powerTextBlock.Tag as Byte[]); LIFX_Net.Messages.LifxPowerStateMessage psm = await bulb.SetPowerStateCommand(powerTextBlock.Text == LifxPowerState.On.ToString()?LifxPowerState.Off : LifxPowerState.On); powerTextBlock.Inlines.Clear(); powerTextBlock.Inlines.Add(new Run() { Text = psm.PowerState.ToString(), Foreground = psm.PowerState == LifxPowerState.On ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Gray) }); bulb.IsOn = psm.PowerState; StorageHelper.SaveToStorage(); } }
private async void SetColour(LifxColour colour) { Helper.ShowProgressIndicator("Setting colour..."); SetSliders(colour); foreach (LifxBulb bulb in StorageHelper.SelectedBulbs) { if (FadeColourAppBarButton.IsChecked.Value == true) { await bulb.SetWaveformCommand(0, 0, colour, Convert.ToUInt32(FadeTimeSlider.Value), 1.0f, 1, Waveform.Sine); } else { await bulb.SetColorCommand(colour, 0); } bulb.Colour = colour; } StorageHelper.SaveToStorage(); Helper.HideProgressIndicator(); }