protected void Button1_Click(object sender, EventArgs e) { var inputLeft = txtLeftBox.Text; var inUnit = DropDownList1.SelectedValue; var outUnit = DropDownList2.SelectedValue; var outValue = TemperatureConverter.ConvertTemperature(double.Parse(inputLeft), (TUnit)Enum.Parse(typeof(TUnit), inUnit), (TUnit)Enum.Parse(typeof(TUnit), outUnit)); txtRightBox.Text = outValue.ToString(); }
private void getResultButton_Click(object sender, EventArgs e) { try { if (currentTemperatureTextBox.Text == "") { throw new FormatException("Входная строка пуста."); } var currentTemperature = Convert.ToDouble(currentTemperatureTextBox.Text); var resultTemperature = _temperatureConverter.ConvertTemperature(currentTemperature, currentScaleListBox.SelectedItem.ToString(), resultScaleListBox.SelectedItem.ToString()); resultTemperatureTextBox.Text = resultTemperature.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }