Add project files.
This commit is contained in:
59
CarManagerV2/MainForm.cs
Normal file
59
CarManagerV2/MainForm.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
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<Car> cars = new List<Car>();
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
SafeManager.initializeFile("cars.csv");
|
||||
cars = SafeManager.readCars("cars.csv");
|
||||
refreshCars(cars);
|
||||
}
|
||||
|
||||
private void refreshCars(List<Car> 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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user