Ejemplo n.º 1
0
 public void updateBaseUnits(string aUnit, string dUnit, string sUnit, string fUnit, string lUnit)
 {
     startingfuel  = DataConverters.MassUnits(startingfuel, baseFuelunit, fUnit);
     minima        = DataConverters.MassUnits(minima, baseFuelunit, fUnit);
     rdfuel        = DataConverters.MassUnits(rdfuel, baseFuelunit, fUnit);
     baseAltunit   = aUnit;
     baseDistunit  = dUnit;
     baseSpeedunit = sUnit;
     baseFuelunit  = fUnit;
     baseLfftunit  = lUnit;
 }
        private void changeUnits(object sender, SelectionChangedEventArgs e)
        {
            if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
            {
                isUnitsFixed               = false;
                default_unitsBtn.Content   = "Fix Units";
                default_unitsBtn.IsEnabled = true;
            }
            switch ((sender as ComboBox).Name)
            {
            case "alt_units":
                if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
                {
                    foreach (PerformanceData param in pdata.performanceDatas)
                    {
                        param.alt = DataConverters.LengthUnits(param.alt, alt_units.Text, alt_units.SelectedValue.ToString());
                    }
                    performanceChart.Items.Refresh();
                }
                break;

            case "dist_units":
                if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
                {
                    foreach (PerformanceData param in pdata.performanceDatas)
                    {
                        param.climbdist   = DataConverters.LengthUnits(param.climbdist, dist_units.Text, dist_units.SelectedValue.ToString());
                        param.descenddist = DataConverters.LengthUnits(param.descenddist, dist_units.Text, dist_units.SelectedValue.ToString());
                    }
                    performanceChart.Items.Refresh();
                }
                break;

            case "speed_units":
                if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
                {
                    if (!String.IsNullOrEmpty(dataspd1.Text))
                    {
                        dataspd1.Text = DataConverters.SpeedUnits(Convert.ToDouble(dataspd1.Text), speed_units.Text.Split('-')[1], speed_units.SelectedValue.ToString().Split('-')[1]).ToString();
                    }
                    if (!String.IsNullOrEmpty(dataspd2.Text))
                    {
                        dataspd2.Text = DataConverters.SpeedUnits(Convert.ToDouble(dataspd2.Text), speed_units.Text.Split('-')[1], speed_units.SelectedValue.ToString().Split('-')[1]).ToString();
                    }
                    if (!String.IsNullOrEmpty(dataspd3.Text))
                    {
                        dataspd3.Text = DataConverters.SpeedUnits(Convert.ToDouble(dataspd3.Text), speed_units.Text.Split('-')[1], speed_units.SelectedValue.ToString().Split('-')[1]).ToString();
                    }
                    if (!String.IsNullOrEmpty(dataspd4.Text))
                    {
                        dataspd4.Text = DataConverters.SpeedUnits(Convert.ToDouble(dataspd4.Text), speed_units.Text.Split('-')[1], speed_units.SelectedValue.ToString().Split('-')[1]).ToString();
                    }
                    if (!String.IsNullOrEmpty(dataspd5.Text))
                    {
                        dataspd5.Text = DataConverters.SpeedUnits(Convert.ToDouble(dataspd5.Text), speed_units.Text.Split('-')[1], speed_units.SelectedValue.ToString().Split('-')[1]).ToString();
                    }
                }
                break;

            case "fuel_units":
                if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
                {
                    foreach (PerformanceData param in pdata.performanceDatas)
                    {
                        param.climbfuel   = DataConverters.MassUnits(param.climbfuel, fuel_units.Text, fuel_units.SelectedValue.ToString());
                        param.descendfuel = DataConverters.MassUnits(param.descendfuel, fuel_units.Text, fuel_units.SelectedValue.ToString());
                    }
                    foreach (FuelStartData param in fsdata.fuelStartDatas)
                    {
                        param.startval = DataConverters.MassUnits(param.startval, fuel_units.Text, fuel_units.SelectedValue.ToString());
                    }
                    foreach (FuelReduceData param in frdata.fuelReduceDatas)
                    {
                        param.reductionval = DataConverters.MassUnits(param.reductionval, fuel_units.Text, fuel_units.SelectedValue.ToString());
                    }
                    performanceChart.Items.Refresh();
                    startFuelChart.Items.Refresh();
                    reductionFuelChart.Items.Refresh();
                }
                break;

            case "lfft_units":
                if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
                {
                    if (pdata.performanceDatas.Count != 0)
                    {
                        if (MessageBox.Show($"Changing This Unit Will Result in Resetting All the Existing {Environment.NewLine} Value Corresponding to This Unit {Environment.NewLine} {Environment.NewLine} Are you sure you want to proceed?", "Warning", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.Cancel)
                        {
                            lfft_units.SelectionChanged -= changeUnits;
                            lfft_units.SelectedValue     = lfft_units.Text;
                            lfft_units.SelectionChanged += changeUnits;
                            return;
                        }
                    }
                    foreach (PerformanceData param in pdata.performanceDatas)
                    {
                        param.spd1 = DataConverters.ConsumptionUnits(param.spd1, lfft_units.Text.Replace(" ", String.Empty), lfft_units.SelectedValue.ToString().Replace(" ", String.Empty));
                        param.spd2 = DataConverters.ConsumptionUnits(param.spd2, lfft_units.Text.Replace(" ", String.Empty), lfft_units.SelectedValue.ToString().Replace(" ", String.Empty));
                        param.spd3 = DataConverters.ConsumptionUnits(param.spd3, lfft_units.Text.Replace(" ", String.Empty), lfft_units.SelectedValue.ToString().Replace(" ", String.Empty));
                        param.spd4 = DataConverters.ConsumptionUnits(param.spd4, lfft_units.Text.Replace(" ", String.Empty), lfft_units.SelectedValue.ToString().Replace(" ", String.Empty));
                        param.spd5 = DataConverters.ConsumptionUnits(param.spd5, lfft_units.Text.Replace(" ", String.Empty), lfft_units.SelectedValue.ToString().Replace(" ", String.Empty));
                    }
                    performanceChart.Items.Refresh();
                }
                break;

            default:
                return;
            }
        }