Exemple #1
0
        private void OnCalculator(object sender, RoutedEventArgs e)
        {
            double          fuel     = double.Parse(viewModel.Fuel);
            double          distance = double.Parse(viewModel.Distance);
            FuelEconomyType ecoType  = viewModel.SelectFuelEconomyType;
            double          result   = 0;

            switch (ecoType.Id)
            {
            case "lpk":
                result = fuel / (distance / 100);
                break;

            case "mpg":
                result = distance / fuel;
                break;
            }
            viewModel.Result = result.ToString();
        }
Exemple #2
0
        private void InitializeFuelEcoTypes()
        {
            var t1 = new FuelEconomyType
            {
                Id           = "lpk",
                Text         = "L/100 km",
                DistanceText = "Distance (kilometers)",
                FuelText     = "Fuel used (liters)"
            };
            var t2 = new FuelEconomyType
            {
                Id           = "mpg",
                Text         = "Miles per gallon",
                DistanceText = "Distance (miles)",
                FuelText     = "Fuel used (gallons)"
            };

            this.fuelEconTypes = new List <FuelEconomyType>()
            {
                t1, t2
            };
        }