Esempio n. 1
0
        private void WeightUnitsChoice_SelectedIndexChanged(object sender, EventArgs e)
        {
            ResetFailure();
            ComboBox     Selector = (ComboBox)sender;
            PrimaryUnits NewUnits = DecideUnits((string)Selector.SelectedItem);

            try
            {
                if (NewUnits == CurrentUnits)
                {
                    return;
                }
                if (!WeightInput.Text.Equals(string.Empty))
                {
                    double CurrWeight = double.Parse(WeightInput.Text);
                    if (CurrentUnits == PrimaryUnits.METRIC)
                    {
                        WeightInput.Text = Math.Round(InputCleaner.KilogramsToPounds(CurrWeight)).ToString();
                    }
                    else
                    {
                        WeightInput.Text = Math.Round(InputCleaner.PoundsToKilograms(CurrWeight)).ToString();
                    }
                }
            } catch { FailedUnitsConversion(); }
            CurrentUnits = NewUnits;
        }
Esempio n. 2
0
 public MainWindow()
 {
     InitializeComponent();
     CurrentAltUnits = AltUnits.FEET;
     CurrentUnits    = PrimaryUnits.METRIC;
     this.AltUnitsChoice.SelectedIndex    = 0;
     this.WeightUnitsChoice.SelectedIndex = 0;
     this.RwyCondSel.SelectedIndex        = 0;
     this.FlapsSettingSel.SelectedIndex   = 0;
 }
Esempio n. 3
0
        private void ComputeBtn_Click(object sender, EventArgs e)
        {
            ResetFailure();
            ResetOutput();
            PrimaryUnits       Units         = DecideUnits((string)WeightUnitsChoice.SelectedValue);
            AltUnits           AltitudeUnits = DecideAltUnits((string)AltUnitsChoice.SelectedValue);
            FlapsSetting       Flaps         = DecideFlapsSetting((string)FlapsSettingSel.SelectedValue);
            LandingSpeedValues BaseValues    = new LandingSpeedValues {
                Units = Units, Flaps = Flaps,
            };
            bool ConvertSuccess = double.TryParse(OATInput.Text, out double OAT);

            ConvertSuccess &= double.TryParse(WeightInput.Text, out double WeightDouble);
            if (!ConvertSuccess)
            {
                FailedToClean(); return;
            }
            BaseValues.OAT    = (int)Math.Round(OAT);
            BaseValues.Weight = (int)Math.Round(WeightDouble);

            // Compute Landing
            bool CleanSuccess = InputCleaner.CleanedLandingSpeeds(BaseValues, out LandingSpeedValues CleanedLandingVals);

            if (!CleanSuccess)
            {
                FailedToClean(); return;
            }
            LandingComputation LandingComp = new LandingComputation(CleanedLandingVals);

            if (LandingComp.Failed)
            {
                FailedToCompute(); return;
            }

            // Display landing data
            DisplayLandingData(LandingComp.Output);

            TakeoffSpeedValues TakeOffValues = new TakeoffSpeedValues();

            // ALT Units, AntiIce, Runway HDG, Wind HFG, Wind Speed, Elevation, RWY Conditions
            TakeOffValues.BasicVals = CleanedLandingVals;
            bool ConvertValsSuccess = double.TryParse(RwyElevationInput.Text, out double RwyElev);

            ConvertValsSuccess &= double.TryParse(RwyHdgInput.Text, out double RwyHdg);
            double WindHdg = 0;
            double WindSpd = 0;

            try
            {
                string[] WindInfo = RwyWindInput.Text.Split('/');
                ConvertValsSuccess &= double.TryParse(WindInfo[0], out WindHdg);
                ConvertValsSuccess &= double.TryParse(WindInfo[1], out WindSpd);
            }
            catch { FailedToCleanTO(); return; }
            if (!ConvertValsSuccess)
            {
                FailedToCleanTO(); return;
            }
            TakeOffValues.Elevation  = (int)Math.Round(RwyElev);
            TakeOffValues.RunwayHdg  = (int)Math.Round(RwyHdg);
            TakeOffValues.WindHdg    = (int)Math.Round(WindHdg);
            TakeOffValues.WindSpd    = (int)Math.Round(WindSpd);
            TakeOffValues.Conditions = DecideRunwayConditions((string)RwyCondSel.SelectedItem);
            TakeOffValues.AntiIce    = DeIceOnCheckbox.Checked;

            CleanSuccess = InputCleaner.CleanedTakeoffSpeeds(TakeOffValues, out TakeoffSpeedValues CleanedTakeOffVals);
            if (!CleanSuccess)
            {
                FailedTakeoffComputation(); return;
            }

            TakeoffComputation TakeoffComp = new TakeoffComputation(CleanedTakeOffVals);

            if (TakeoffComp.Failed)
            {
                FailedTakeoffComputation(); return;
            }

            // Display Takeoff Data
            DisplayTakeoffData(TakeoffComp.Output);
            Success();
        }