コード例 #1
0
ファイル: Overview.cs プロジェクト: joshua-cross/CarCoster
        /*Fucntion that calls the CarBadge classes getBadge function.*/
        private void setImage(string man)
        {
            //setting the image to be the badge of the car.
            CarBadge badge = new CarBadge();
            string   url   = badge.getBadge(man);

            Badge.Image    = Image.FromFile(url);
            Badge.SizeMode = PictureBoxSizeMode.StretchImage;
        }
コード例 #2
0
        /*Function that takes in:
         * a. the ListBox for the model.
         * b. the manufactuerer selected from the ManufacturerBox.
         * c. the current Listed object.
         * d. the pictureBox we want to update with the selected manufacturers logo.
         * then returns all the cars from this selected manufacturer.*/
        public Listed ManufactuerSelected(ListBox ModelBox, string manufacturer, Listed carList, PictureBox LogoBox)
        {
            CarListReader listReader = new CarListReader();

            /*If the item is not all then do the following*/
            if (!manufacturer.Equals("All"))
            {
                /*Getting the models*/
                //contstructor that takes in a manufactorer and searches the array for cars that match the manufactorer.
                carList.CarsFromManufacturer = listReader.searchCars(carList.Cars, manufacturer);

                /*As we've only just drew the list of models we should assume that
                 * the CurrentCars is the CarsFromManufacturer*/
                carList.CurrentCars = carList.CarsFromManufacturer;

                carList.CurrentCarsWithoutRestrictions = carList.CurrentCars;

                /*Loading the manufacturers logo in the form.*/
                CarBadge badge = new CarBadge();
                string   url   = badge.getBadge(manufacturer);
                try
                {
                    LogoBox.Image    = Image.FromFile(url);
                    LogoBox.SizeMode = PictureBoxSizeMode.StretchImage;
                } catch (Exception error)
                {
                    Console.WriteLine(error.ToString());
                }
                PopulateListBoxWithCarsDetails(ModelBox, carList.CarsFromManufacturer);
            }
            else
            {
                /*As we've selected all, just set the manufacturers to each available car in the
                 * Listed object.*/
                carList.CarsFromManufacturer           = carList.Cars;
                carList.CurrentCars                    = carList.CarsFromManufacturer;
                carList.CurrentCarsWithoutRestrictions = carList.CurrentCars;

                PopulateListBoxWithCarsDetails(ModelBox, carList.CarsFromManufacturer);
            }

            /*Returning the carList after updating the carLists CarsFromManufacturer*/
            return(carList);
        }
コード例 #3
0
        /*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);
        }