コード例 #1
0
        public Listed DefaultForm1ToLoad()
        {
            CarListReader reader = new CarListReader();

            Listed list = new Listed();

            /*Setting the cars in JSON reader to be that of the most recent year.*/
            JsonReader json = new JsonReader();

            /*Getting the list of cars from json.*/
            list.Cars = json.getCars();

            list.Manufacturers = reader.GetManufacturers(list.Cars);

            list.searchedManufacturers = list.Manufacturers;

            list.LatestFileYear = json.getMostRecent();

            return(list);
        }
コード例 #2
0
        /*When the Confirm year button is pressed we want to change
         * the contents of the boxes to be the cars of the year chosen e.g.
         * from 2017 to 2015.*/
        private void ConfirmYearButton_Click(object sender, EventArgs e)
        {
            //if the user has selected a year.
            if (YearBox.SelectedIndex != -1)
            {
                //the year that the user has selected.
                string     selectedYear = YearBox.SelectedItem.ToString();
                JsonReader json         = new JsonReader(selectedYear);
                carList.Cars = json.getCars();

                carList.Manufacturers = listReader.GetManufacturers(carList.Cars);

                carList.searchedManufacturers = carList.Manufacturers;

                //setting the year to be the year that was selected.
                year = selectedYear;

                drawListBox(json);
            }
        }
コード例 #3
0
ファイル: Compare.cs プロジェクト: joshua-cross/CarCoster
        /*Function that takes in:
         *   a. The ListBox of the year that we want to display.
         *   b. The Listed object we wish to update with the new cars.
         *   c. The ListBox we wish to update with the new manufacturers.
         * and switches the Listed object to display the specific years cars.*/
        private void SwitchingYear(ListBox year, Listed list, ListBox toUpdate)
        {
            //if the user has selected a year.
            if (year.SelectedIndex != -1)
            {
                CarListReader listReader = new CarListReader();

                //the year that the user has selected.
                string selectedYear = year.SelectedItem.ToString();

                JsonReader json = new JsonReader(selectedYear);
                list.Cars = json.getCars();

                list.Manufacturers = listReader.GetManufacturers(list.Cars);

                list.searchedManufacturers = list.Manufacturers;

                listBoxes.PopulateListBoxWithManufacturers(toUpdate, list.Manufacturers);
                //setting the year to be the year that was selected.
                //year = selectedYear;

                //drawListBox(json);
            }
        }