예제 #1
0
        private void TempUnitComboBoxSelectedIndexChanged(object sender, EventArgs e)
        {
            if (double.TryParse(oatTxtBox.Text, out var temp))
            {
                if (tempUnitComboBox.SelectedIndex == 0)
                {
                    // deg F -> deg C
                    temp = ConversionTools.ToCelsius(temp);
                }
                else
                {
                    // deg C -> deg F
                    temp = ConversionTools.ToFahrenheit(temp);
                }

                oatTxtBox.Text = Numbers.RoundToInt(temp).ToString();
            }
        }
예제 #2
0
 private int TempConvertUnit(double tempCelsuis, TemperatureUnit tempUnit)
 {
     return(Numbers.RoundToInt(tempUnit == TemperatureUnit.Fahrenheit ?
                               ConversionTools.ToFahrenheit(tempCelsuis) : tempCelsuis));
 }