Exemplo n.º 1
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            Find findObj = new Find();
            SearchWindow searchWindow = new SearchWindow();
            if (searchWindow.ShowDialog() == true)
            {
                List<Recipe> refindRecipes = new List<Recipe>();

                foreach (var recipe in recipes.MasterRecipesList)
                {
                    string recipeString;
                    List<string> keywords = new List<string>();
                    string rawtext = searchWindow.RequestKeywords;
                    keywords = rawtext.Split(',').ToList();
                    RecipeToString recipeToString = new RecipeToString();
                    recipeString = recipeToString.Convert(recipe);

                    if (findObj.KeywordMatcher(keywords, recipeString))
                    {
                        refindRecipes.Add(recipe);
                    }
                }

                List<string> refinedRecipeTitles = (from rec in refindRecipes
                    select rec.Title).ToList();
                recipeListBox.DataContext = refinedRecipeTitles;
            }
        }