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 }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { SearchFlowerPictureController pictureSearchCtlr = new SearchFlowerPictureController(); //make flower list List <Flower> flowerInfo = new List <Flower>(); openFileDialog.ShowDialog(); if (openFileDialog.FileName != "") { //grab the image Image searchPic = Image.FromFile(openFileDialog.FileName); searchPictureBox.Image = searchPic; searchPictureBox.Visible = true; dragDropLabel.Visible = false; dragDropLinkLabel.Location = new Point(348, 80); //do the search for the flower list using a picture List <int> foundFlowers = pictureSearchCtlr.getPictureSearchList(searchPic); //get the found flowers from the search foreach (int value in foundFlowers) { flowerInfo.Add(DatabaseManager.getFlowerById(value)); } //display the found flowers to the GUI 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 })); } } }
private void imageSearchPanel_DragDrop(object sender, DragEventArgs e) { String[] imageDrops = (String[])e.Data.GetData(DataFormats.FileDrop, true); Image searchPic = Image.FromFile(imageDrops[0]); SearchFlowerPictureController pictureSearchCtlr = new SearchFlowerPictureController(); //make flower list List <Flower> flowerInfo = new List <Flower>(); searchPictureBox.Image = searchPic; searchPictureBox.Visible = true; dragDropLabel.Visible = false; dragDropLinkLabel.Location = new Point(348, 80); //do the search for the flower list using a picture List <int> foundFlowers = pictureSearchCtlr.getPictureSearchList(searchPic); //get the found flowers from the search foreach (int value in foundFlowers) { flowerInfo.Add(DatabaseManager.getFlowerById(value)); } //display the found flowers to the GUI 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 })); } }