Esempio n. 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();
             }
             ThirdCar car = new ThirdCar("", color, engine, "");
             carList.Add(car);
             foreach (ThirdCar 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);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Adding chosen Mercedes CLA Coupe configuration to the list
        /// </summary>
        private void addThirdCarConfigs()
        {
            ThirdCar newCar = new ThirdCar("", 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/clacoupe-big.jpg"));
        }
Esempio n. 3
0
        /// <summary>
        /// Adding chosen Mercedes CLA Coupe configuration to shopping cart
        /// </summary>
        private void addThirdCarToShoppingCart()
        {
            ThirdCar car = new ThirdCar("", color, engine, "", actual_price);

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