public void Compute(object sender, EventArgs e) { try { var para = new ParameterValidator(elements).Validate(); if (!CheckWeight(para)) { return; } var report = controller.GetReport(para); var text = report.ToString((LengthUnit)elements.LengthUnit.SelectedIndex); // To center the text in the richTxtBox elements.Result.Text = text.ShiftToRight(15); TrySaveState(); elements.Result.ForeColor = Color.Black; } catch (InvalidUserInputException ex) { this.ShowWarning(ex.Message); } catch (RunwayTooShortException) { this.ShowWarning("Runway length is insufficient for landing."); } }
public void Compute(object sender, EventArgs e) { try { var para = ParameterValidator.Validate(elements); if (!CheckWeight(para)) { return; } var tempUnit = (TemperatureUnit)elements.TempUnit.SelectedIndex; var tempIncrement = tempUnit == TemperatureUnit.Celsius ? 1.0 : 2.0 / 1.8; var report = controller.GetReport(para, tempIncrement); var text = report.ToString(tempUnit, (LengthUnit)elements.lengthUnit.SelectedIndex); // To center the text in the richTxtBox elements.Result.Text = text.ShiftToRight(20); elements.Result.ForeColor = Color.Black; TrySaveState(); } catch (InvalidUserInputException ex) { this.ShowWarning(ex.Message); } catch (RunwayTooShortException) { this.ShowWarning("Runway length is insufficient for takeoff."); } catch (PoorClimbPerformanceException) { this.ShowWarning("Aircraft too heavy to meet " + "climb performance requirement."); } catch (Exception ex) { this.ShowError(ex.Message); } }