private void ButtonClick(object sender, EventArgs e) { if (e is MouseEventArgs) { var preset = (LgPreset)(sender as Button).Tag; var _ = _lgService.ApplyPreset(preset); } }
public static async Task <bool> ExecutePresetAsync(string presetName) { try { var lgService = new LgService(Program.DataDir, true); await lgService.RefreshDevices(afterStartUp : true); var result = await lgService.ApplyPreset(presetName); if (!result) { Console.WriteLine("Preset not found or error while executing."); } return(result); } catch (Exception ex) { Console.WriteLine("Error executing preset: " + ex.ToLogString()); return(false); } }