示例#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();
             }
             SecondCar car = new SecondCar("", color, engine, "");
             carList.Add(car);
             foreach (SecondCar 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 GT configuration to the list
        /// </summary>
        private void addSecondCarConfigs()
        {
            SecondCar newCar = new SecondCar("", 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/amggt-big.jpg"));
        }
示例#3
0
        /// <summary>
        /// Adding chosen Mercedes AMG GT configuration to shopping cart
        /// </summary>
        private void addSecondCarToShoppingCart()
        {
            SecondCar car = new SecondCar("", color, engine, "", actual_price);

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