Example #1
0
        private void button1_Click_3(object sender, EventArgs e)
        {
            //makes the object, and calls the constructor in the controller to make the new gui object and show it

            SearchFlowerLanguageController searchFlowerController = new SearchFlowerLanguageController();

            searchFlowerController.constructSearchGUI();
        }
        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
        }
Example #3
0
        private void searchButton_Click(object sender, EventArgs e)
        {
            viewResultsList.Items.Clear();


            SearchFlowerLanguageController search = new SearchFlowerLanguageController();
            string        userInput          = searchBox.Text;
            int           selectedSearchType = searchTypeBox.SelectedIndex;
            List <Flower> flowerInfo         = new List <Flower>();

            if ((selectedSearchType == 0) || (selectedSearchType == 1) || (selectedSearchType == 2))
            {
                List <int> foundFlowers = search.getSearchList(selectedSearchType, userInput);

                foreach (int value in foundFlowers)
                {
                    flowerInfo.Add(DatabaseManager.getFlowerById(value));
                }

                foreach (var Flower in flowerInfo)
                {
                    string latinName   = Flower.getEnglishName();
                    string englishName = Flower.getLatinName();
                    string BotFamily   = Flower.getBotanicalFamily();
                    string id          = Flower.getID().ToString();

                    viewResultsList.Items.Add(new ListViewItem(new string[] { "", latinName, englishName, BotFamily, id }));
                }
            }

            else
            {
                //Image searchPicture;
                //searchPicture = openFileDialog

                //List<int> foundFlowers = pictureSearchCtlr.getPictureSearchList()
            }
        }
        public SearchFlowerGUI(SearchFlowerLanguageController controller)
        {
            InitializeComponent();

            searchController = controller;
        }