Пример #1
0
        private void searchButton_Click(object sender, EventArgs e)
        {
            List <int> results;
            //save the input from the user
            int    searchType  = SearchTypeBox.SelectedIndex;
            string searchEntry = SearchEntryBox.Text;



            if ((searchType == 0) || (searchType == 1) || (searchType == 2))
            {
                SearchFlowerLanguageController languageController = new SearchFlowerLanguageController();

                //calls the ctlr to get the searchList from the DBM, giving the searchType and Search Entry from the User
                results = languageController.getSearchList(searchType, searchEntry);

                for (int i = 0; i < results.Count; i++)
                {
                    Console.WriteLine(results[i]);
                }

                //if the results list is empty then print a no results found message to the user
                if (results.Count == 0)
                {
                    MessageBox.Show("No results have been found!");
                }
            }

            else
            {
                SearchFlowerPictureController pictureController = new SearchFlowerPictureController();

                //gets the image file path, now gotta pass it to the controller
                searchPicture = searchAddPicture(openFileDialog1.FileName);



                searchPicture = pictureController.ResizeImage(searchPicture, 50, 50);

                results = pictureController.getPictureSearchList(searchPicture);

                for (int i = 0; i < results.Count; i++)
                {
                    Console.WriteLine(results[i]);
                }

                //if the results list is empty then print a no results found message to the user
                if (results.Count == 0)
                {
                    MessageBox.Show("No results have been found!");
                }
            }



            //This will print the Int Id of the Flower in the console, meaning that the next use-case, display results,
            //will take this list and ask for the flower information and display them to the user in iteration 3
        }
Пример #2
0
        //DatabaseManager dbMg = new DatabaseManager();

        //Take in the raw flower data (not flower object), add the raw data to a flower object, and then
        //call the database manager for duplicate checking.
        public bool addFlower(string latinName, string englishName, string botanicalFamily, string flowerNote,
                              DateTime noteTimeDate, List <Image> pictures, List <DateTime> pictureTimeDate, List <string> photographers,
                              List <string> locations, List <string> pictureNotes, List <string> paths)
        {
            Note note = new Note(noteTimeDate, flowerNote);

            //have each picture in the list be converted into a sepereate RGB list
            SearchFlowerPictureController flowerPictureController = new SearchFlowerPictureController();

            ViewHistogramController viewHistogramController = new ViewHistogramController();

            //the bin list for each picture for ONE flower
            List <int[]> flowerBinList = new List <int[]>();

            //the single bin list for a pcit
            int[] singleBinList = new int[17];

            //the RGB list for each picture for a flower
            List <Tuple <int, int, int> > RGBList = new List <Tuple <int, int, int> >();

            Flower flower = new Flower(latinName, englishName, botanicalFamily, note);

            for (int i = 0; i < pictures.Count; i++)
            {
                //reisze the picuter
                pictures[i] = flowerPictureController.ResizeImage(pictures[i], 227, 171);

                //calls function to turn the picture into a RGBList of all the pixels in the picture
                RGBList = flowerPictureController.GetRGBpixelList(pictures[i]);

                //convert from RGB to bin list
                singleBinList = viewHistogramController.makeRGBList(RGBList);

                flower.pictureList.Add(new Picture(pictures[i], pictureTimeDate[i], photographers[i], locations[i], pictureNotes[i], paths[i], singleBinList));
            }



            return(DatabaseManager.storeFlowerInDB(flower));
        }