Ejemplo n.º 1
0
 public Main1(Main2 w1)
 {
     wnd1 = w1;
     InitializeComponent();
     try
     {
         using (FileStream fs = new FileStream(@"../../input.txt", FileMode.OpenOrCreate, FileAccess.Read))
         {
             string[]     data;
             CustomCars   crs;
             StreamReader sr = new StreamReader(fs, Encoding.Default);
             while (!sr.EndOfStream)
             {
                 data = sr.ReadLine().Split(' ');
                 crs  = new CustomCars(data[0], data[1], int.Parse(data[2]), data[3], int.Parse(data[4]));
                 cars.Add(crs);
             }
             sr.Close();
             fs.Close();
         }
     }catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     RefreshCarsTXT();
     foreach (CustomCars crs in cars)
     {
         carList.Items.Add(crs);
     }
 }
Ejemplo n.º 2
0
 private void addFinalCar_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         CustomCars crs = new CustomCars(newbrand.Text, newcarcase.Text, int.Parse(newcapacity.Text), newgearbox.Text, int.Parse(newmaxspeed.Text));
         wnd.cars.Add(crs);
         wnd.carList.Items.Add(crs);
         wnd.RefreshCarsTXT();
     }
     catch
     {
         MessageBox.Show("Ошибка ввода данных!");
     }
     this.Close();
 }