/*Constructor that's called from the Form1 (AddCar) that takes * in the car the user has selected, and opens sends it over to * this form before opening this form. This constructor will then * assign the details of the CarToBeDisplayed Object to the UI * objects of this form such as the picture box.*/ public CarDetails(CarToBeDisplayed display) { displayed = display; InitializeComponent(); }
/*Function that's called by The AddCar button which launches * the car Details form with all the information from the car.*/ public void OpenCarDetails(Car car) { CarToBeDisplayed displayed = detailsToBeDisplayed(car); CarDetails details = new CarDetails(displayed); details.Show(); }
/*Function that gets all the details for the car, including the * image for the car, and all the cars details.*/ public CarToBeDisplayed detailsToBeDisplayed(Car car) { //The information that we will return to the user, CarToBeDisplayed displayed = new CarToBeDisplayed(); //getting the car printer so we can get the cars that need printing. CarPrinter printer = new CarPrinter(); /*Setting the header and details to be the printers equivelent.*/ displayed.carDetails = printer.printcar(car, Properties.Settings.Default.ImperialOrMetric); displayed.carHeader = printer.carHeader(car); try { //Getting the carbadge class so we send the image url to the class. CarBadge badge = new CarBadge(); displayed.imageURL = badge.getBadge(car.Manufacturer); } catch (Exception error) { Console.WriteLine(error.ToString()); } return(displayed); }