/// <summary> /// Sends the new settings to the pie /// </summary> /// <param name="settings"></param> /// <returns></returns> private async Task SendNewSettings(ManualColorSettings settings) { Command cmd = new Command(); cmd.Program = GlowPrograms.ManualColors; cmd.MessageId = Command.COMMAND_RECIEVE_SETTINGS; cmd.Message = Newtonsoft.Json.JsonConvert.SerializeObject(settings); try { await App.GlowBack.ConnectionManager.SendCommand(cmd); } catch (Exception e) { Debug.WriteLine("Failed to send update manual color settings " + e.Message); } }
private async void ColorPicker_OnColorChanged(object sender, Controls.OnColorChangedArgs e) { ManualColorSettings newSettings = new ManualColorSettings(); newSettings.CurrentLedStateList = new List<List<SerlizableLed>>(); List<SerlizableLed> localList = new List<SerlizableLed>(); SerlizableLed led = new SerlizableLed(e.Red / 255.0, e.Green / 255.0, e.Blue / 255.0, 1.0, 0); localList.Add(led); localList.Add(led); localList.Add(led); localList.Add(led); localList.Add(led); newSettings.CurrentLedStateList.Add(localList); // Send the settings await SendNewSettings(newSettings); }
// Updates the settings given a settings command. private void UpdateSettings(Command command) { // Get the settings from the message ManualColorSettings newSettings = Newtonsoft.Json.JsonConvert.DeserializeObject <ManualColorSettings>(command.Message); if (newSettings == null) { return; } // Set the new settings m_settings = newSettings; m_settings.SaveSettings(); // Update the LEDs SetCurrentValues(); }
private async void ColorPicker_OnColorChanged(object sender, Controls.OnColorChangedArgs e) { ManualColorSettings newSettings = new ManualColorSettings(); newSettings.CurrentLedStateList = new List <List <SerlizableLed> >(); List <SerlizableLed> localList = new List <SerlizableLed>(); SerlizableLed led = new SerlizableLed(e.Red / 255.0, e.Green / 255.0, e.Blue / 255.0, 1.0, 0); localList.Add(led); localList.Add(led); localList.Add(led); localList.Add(led); localList.Add(led); newSettings.CurrentLedStateList.Add(localList); // Send the settings await SendNewSettings(newSettings); }
// Updates the settings given a settings command. private void UpdateSettings(Command command) { // Get the settings from the message ManualColorSettings newSettings = Newtonsoft.Json.JsonConvert.DeserializeObject<ManualColorSettings>(command.Message); if(newSettings == null) { return; } // Set the new settings m_settings = newSettings; m_settings.SaveSettings(); // Update the LEDs SetCurrentValues(); }