using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace CarManagerV2 { public partial class MainForm : Form { List cars = new List(); public MainForm() { InitializeComponent(); SafeManager.initializeFile("cars.csv"); cars = SafeManager.readCars("cars.csv"); refreshCars(cars); } private void refreshCars(List cars) { flpCars.Controls.Clear(); foreach (Car car in cars) { CarCard card = new CarCard(); card.CarName = $"{car.Make} {car.Model}"; card.CarDetails = $"{car.Year}, {car.Mileage} km, ${car.Price}"; card.CarImage = ImageManager.GetImage(car); card.CardClicked += (s, e) => { CarDetailsForm detailsForm = new CarDetailsForm(car); detailsForm.FormClosed += (s2, e2) => { // refresh cars cars = SafeManager.readCars("cars.csv"); refreshCars(cars); }; detailsForm.ShowDialog(); }; flpCars.Controls.Add(card); } } private void CarDetailsForm_Load(object sender, EventArgs e) { } private void MainForm_Load(object sender, EventArgs e) { } } }