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 }
//Stores the modified flower into the database by reciving the flower attributes //and editing the associated flower in the list. The edited flower is then sent //to the database manager to be saved. Used for testing without calling the GUI. public void modifyFlowerDirectly(int position, 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> picturePaths) { Flower flower = flowers[position]; flower.setLatinName(latinName); flower.setEnglishName(englishName); flower.setbotanicalFamily(botanicalFamily); flower.setNote(new Note(noteTimeDate, flowerNote)); flower.pictureList.Clear(); //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> >(); for (int i = 0; i < pictures.Count; i++) { //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); //currently got 1 RGB list flowerBinList.Add(singleBinList); flower.pictureList.Add(new Picture(pictures[i], pictureTimeDate[i], photographers[i], locations[i], pictureNotes[i], picturePaths[i], singleBinList)); } DatabaseManager.modifyFlower(flower); flowers[position] = flower; }
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 })); } } }
//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)); }
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 })); } }