private async Task readResults(TempConverter c) { string strMessage = ""; switch (u) { case SysOfUnits.Kelvin: strMessage += c.InKelvin.ToString() + " Kelvin is equivalent to " + c.InCelsius.ToString() + " degrees Celsius and " + c.InFahrenheit.ToString() + " degrees Fahrenheit"; break; case SysOfUnits.Celsius: strMessage += c.InCelsius.ToString() + " degrees Celsius is equivalent to " + c.InFahrenheit.ToString() + " degrees Fahrenheit and " + c.InKelvin.ToString() + " Kelvin"; break; case SysOfUnits.Fahrenheit: strMessage += c.InFahrenheit.ToString() + " degrees Fahrenheit is equivalent to " + c.InCelsius.ToString() + " degrees Celsius and " + c.InKelvin.ToString() + " Kelvin"; break; default: break; } await talker.SpeakTextAsync(strMessage, uiMediaElement); }
private async void CalculateTemp() { if (!String.IsNullOrEmpty(txtInput.Text)) { try { decimal t; if (!Decimal.TryParse(txtInput.Text, out t)) { txtInput.Foreground = errorBrush; } else { TempConverter c = new TempConverter(t, u); moveCelsius.To = (double)c.InCelsius; moveFahrenheit.To = (double)c.InFahrenheit; moveKelvin.To = (double)c.InKelvin; myStoryboard.Begin(); if (playSpeech) { await readResults(c); } } } catch (ArgumentOutOfRangeException) { string strMessage = "Input Temperature cannot be below Absolute Zero ( " + abZero[(int)u] + " )"; App.ShowMessage("Physics Error", strMessage); txtInput.Foreground = correctBrush; txtInput.Text = ""; if (playSpeech) { await talker.SpeakTextAsync(strMessage, uiMediaElement); } } catch (Exception ex) { App.ShowMessage("Calculation Error", ex.Message); txtInput.Foreground = correctBrush; txtInput.Text = ""; if (playSpeech) { await talker.SpeakTextAsync(ex.Message, uiMediaElement); } } } }