Пример #1
0
 private void addToShoppingList(object sender, RoutedEventArgs e)
 {
     try
     {
         if (this.colorComboBox.SelectedItem != null && this.engineComboBox.SelectedItem != null)
         {
             using (StreamReader f = new StreamReader("shopping_cart.txt"))
             {
                 file = f.ReadToEnd();
             }
             FirstCar car = new FirstCar("", color, engine, "");
             carList.Add(car);
             foreach (FirstCar fc in carList)
             {
                 file += car.brand + ", " + car.name + ", " + car.engine + ", " + car.color + "\n";
             }
             using (StreamWriter ff = new StreamWriter("shopping_cart.txt"))
             { ff.Write(file); }
             MessageBox.Show("Car configuration had been added to the shopping cart. \nGo there to your list!");
             carList.Remove(car);
         }
         else
         {
             MessageBox.Show("You need to choose both the engine type and color before adding to shopping cart!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #2
0
        /// <summary>
        /// Adding chosen Mercedes AMG A45 configuration to the list
        /// </summary>
        private void addFirstCarConfigs()
        {
            FirstCar newCar = new FirstCar("", Options.Color.blue, Options.Engine.Default, 0);

            car_price[0]         = newCar.prices[0];
            car_price[1]         = newCar.prices[1];
            car_price[2]         = newCar.prices[2];
            this.carImage.Source = new BitmapImage(new Uri(@"pack://application:,,,/ProjectApp;component/amga454matic-big.jpg"));
        }
Пример #3
0
        /// <summary>
        /// Adding chosen Mercedes AMG A45 configuration to shopping cart
        /// </summary>
        private void addFirstCarToShoppingCart()
        {
            FirstCar car = new FirstCar("", color, engine, "", actual_price);

            carList1.Add(car);
            foreach (FirstCar fc in carList1)
            {
                file += car.brand + ", " + car.name + ", " + car.engine + ", " + car.color + ", " + car.price + "$\n";
            }
            carList1.Remove(car);
        }