private void populateRecipes() { // PivotItem pvt; int i = 0; if(recipeFinalList.Count == 0) { PivotItem pivotItem = new PivotItem(); pivotItem.Header = "No Results"; TextBlock txtTitle = new TextBlock(); txtTitle.Text = "No Results Found"; txtTitle.Margin = new Thickness(10, 10, 10, 10); pivotItem.Content = txtTitle; pvtRecipes.Items.Add(pivotItem); } foreach(Model.Recipef2f recipe in recipeFinalList) { PivotItem pivotItem = new PivotItem(); pivotItem.Header = recipe.Title; Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); Image img = new Image(); img.Source = new BitmapImage(new Uri(recipe.ImageUrl)); img.SetValue(Grid.ColumnProperty, 0); grid.Children.Add(img); Image favorite = new Image(); favorite.Name = "favoriteSymbol" + i.ToString(); BitmapImage starImage = new BitmapImage(); starImage.UriSource = new Uri("https://image.freepik.com/free-icon/favorites-star-outlined-symbol_318-69168.png"); favorite.Source = starImage; favorite.HorizontalAlignment = HorizontalAlignment.Right; favorite.VerticalAlignment = VerticalAlignment.Top; favorite.Width = 15; favorite.Height = 15; favorite.Tapped += Favorite_Tapped; ; favorite.SetValue(Grid.ColumnProperty, 1); i++; StackPanel stk = new StackPanel(); stk.SetValue(Grid.ColumnProperty, 1); stk.Name = "recipeStk"; stk.Children.Add(favorite); TextBlock txtTitle= new TextBlock(); txtTitle.Text = "Title: " + recipe.Title; txtTitle.Margin = new Thickness(10, 10, 10, 10); txtTitle.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtTitle); TextBlock txtRecipeId = new TextBlock(); txtRecipeId.Text = "RecipeId: " + recipe.RecipeId; txtRecipeId.Margin = new Thickness(10,10,10,10); txtRecipeId.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtRecipeId); TextBlock txtIngredientsList = new TextBlock(); txtIngredientsList.Text = "Ingredients: " + recipe.IngredientsList; txtIngredientsList.Margin = new Thickness(10, 10, 10, 10); txtIngredientsList.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtIngredientsList); TextBlock txtSocialRank = new TextBlock(); txtSocialRank.Text = "Social Rank: " + recipe.SocialRank.ToString(); txtSocialRank.Margin = new Thickness(10, 10, 10, 10); txtSocialRank.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtSocialRank); TextBlock txtPublisher = new TextBlock(); txtPublisher.Text = "Publisher: " + recipe.Publisher; txtPublisher.Margin = new Thickness(10, 10, 10, 10); txtPublisher.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtPublisher); TextBlock txtPublisherUrl = new TextBlock(); txtPublisherUrl.Text = "Publisher URL: " + recipe.PublisherUrl; txtPublisherUrl.Margin = new Thickness(10, 10, 10, 10); txtPublisherUrl.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtPublisherUrl); TextBlock txtSourceUrl = new TextBlock(); txtSourceUrl.Text = "Source URL: " + recipe.SourceUrl; txtSourceUrl.Margin = new Thickness(10, 10, 10, 10); txtSourceUrl.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtSourceUrl); TextBlock txtF2fUrl = new TextBlock(); txtF2fUrl.Text = "F2F URL: " + recipe.F2fUrl; txtF2fUrl.Margin = new Thickness(10, 10, 10, 10); txtF2fUrl.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtF2fUrl); grid.Children.Add(stk); pivotItem.Content = grid; pvtRecipes.Items.Add(pivotItem); } }
private void populateRecipes() { // PivotItem pvt; if(listRecipes.Count == 0 && listf2fRecipe.Count == 0) { PivotItem pivotItem = new PivotItem(); pivotItem.Header ="Favorites"; TextBlock txtTitle = new TextBlock(); txtTitle.Text = "No Favorites at this Point"; txtTitle.Margin = new Thickness(10, 10, 10, 10); txtTitle.SetValue(Grid.ColumnProperty, 1); pivotItem.Content = txtTitle; pvtFavorites.Items.Add(pivotItem); } int yummly = 0; int i = 0; foreach (Model.ResponseYummly recipe in listRecipes) { PivotItem pivotItem = new PivotItem(); pivotItem.Name = "yummly" + yummly.ToString(); yummly++; pivotItem.Header = recipe.RecipeName; Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); Image img = new Image(); img.Source = new BitmapImage(new Uri(recipe.ImageUrl)); img.SetValue(Grid.ColumnProperty, 0); grid.Children.Add(img); Image favorite = new Image(); favorite.Name = "favoriteSymbol" + i.ToString(); i++; BitmapImage starImage = new BitmapImage(); starImage.UriSource = new Uri("http://images.all-free-download.com/images/graphiclarge/favorite_icon_55521.jpg"); favorite.Source = starImage; favorite.HorizontalAlignment = HorizontalAlignment.Right; favorite.VerticalAlignment = VerticalAlignment.Top; favorite.Width = 15; favorite.Height = 15; favorite.Tapped += Favorite_Tapped; favorite.SetValue(Grid.ColumnProperty, 1); StackPanel stk = new StackPanel(); stk.Name = "recipeStk"; stk.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(favorite); TextBlock txtTitle = new TextBlock(); txtTitle.Text = "Title: " + recipe.RecipeName; txtTitle.Margin = new Thickness(10, 10, 10, 10); txtTitle.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtTitle); TextBlock txtRecipeId = new TextBlock(); txtRecipeId.Text = "RecipeId: " + recipe.Id; txtRecipeId.Margin = new Thickness(10, 10, 10, 10); txtRecipeId.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtRecipeId); TextBlock txtIngredientsList = new TextBlock(); txtIngredientsList.Text = "Ingredients: " + recipe.Ingredients.Replace("\",", "\n"); txtIngredientsList.Margin = new Thickness(10, 10, 10, 10); txtIngredientsList.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtIngredientsList); TextBlock txtSocialRank = new TextBlock(); txtSocialRank.Text = "Social Rank: " + recipe.Rating.ToString(); txtSocialRank.Margin = new Thickness(10, 10, 10, 10); txtSocialRank.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtSocialRank); TextBlock txtPublisher = new TextBlock(); txtPublisher.Text = "Publisher: " + recipe.SourceDisplayName; txtPublisher.Margin = new Thickness(10, 10, 10, 10); txtPublisher.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtPublisher); TextBlock txtTotalTime = new TextBlock(); txtTotalTime.Text = "Total Time (seconds): " + recipe.TotalTime.ToString(); txtTotalTime.Margin = new Thickness(10, 10, 10, 10); txtTotalTime.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtTotalTime); TextBlock txtCourse = new TextBlock(); txtCourse.Text = "Courses: " + recipe.Course; txtCourse.Margin = new Thickness(10, 10, 10, 10); txtCourse.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtCourse); TextBlock txtCusine = new TextBlock(); txtCusine.Text = "Cuisine: " + recipe.Cuisine; txtCusine.Margin = new Thickness(10, 10, 10, 10); txtCusine.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtCusine); TextBlock txtFlavors = new TextBlock(); txtFlavors.Text = "Flavors: " + recipe.Flavors.Replace(",\"", "\n"); txtFlavors.Margin = new Thickness(10, 10, 10, 10); txtFlavors.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtFlavors); grid.Children.Add(stk); pivotItem.Content = grid; pvtFavorites.Items.Add(pivotItem); } int f2f = 0; foreach (Model.Recipef2f recipe in listf2fRecipe) { PivotItem pivotItem = new PivotItem(); pivotItem.Name = "f2f" + f2f.ToString(); f2f++; pivotItem.Header = recipe.Title; Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); Image img = new Image(); img.Source = new BitmapImage(new Uri(recipe.ImageUrl)); img.SetValue(Grid.ColumnProperty, 0); grid.Children.Add(img); Image favorite = new Image(); favorite.Name = "favoriteSymbol" + i.ToString(); i++; BitmapImage starImage = new BitmapImage(); starImage.UriSource = new Uri("http://images.all-free-download.com/images/graphiclarge/favorite_icon_55521.jpg"); favorite.Source = starImage; favorite.HorizontalAlignment = HorizontalAlignment.Right; favorite.VerticalAlignment = VerticalAlignment.Top; favorite.Width = 15; favorite.Height = 15; favorite.Tapped += Favorite_Tapped; favorite.SetValue(Grid.ColumnProperty, 1); StackPanel stk = new StackPanel(); stk.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(favorite); TextBlock txtTitle = new TextBlock(); txtTitle.Text = "Title: " + recipe.Title; txtTitle.Margin = new Thickness(10, 10, 10, 10); txtTitle.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtTitle); TextBlock txtRecipeId = new TextBlock(); txtRecipeId.Text = "RecipeId: " + recipe.RecipeId; txtRecipeId.Margin = new Thickness(10, 10, 10, 10); txtRecipeId.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtRecipeId); TextBlock txtIngredientsList = new TextBlock(); txtIngredientsList.Text = "Ingredients: " + recipe.IngredientsList; txtIngredientsList.Margin = new Thickness(10, 10, 10, 10); txtIngredientsList.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtIngredientsList); TextBlock txtSocialRank = new TextBlock(); txtSocialRank.Text = "Social Rank: " + recipe.SocialRank.ToString(); txtSocialRank.Margin = new Thickness(10, 10, 10, 10); txtSocialRank.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtSocialRank); TextBlock txtPublisher = new TextBlock(); txtPublisher.Text = "Publisher: " + recipe.Publisher; txtPublisher.Margin = new Thickness(10, 10, 10, 10); txtPublisher.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtPublisher); TextBlock txtPublisherUrl = new TextBlock(); txtPublisherUrl.Text = "Publisher URL: " + recipe.PublisherUrl; txtPublisherUrl.Margin = new Thickness(10, 10, 10, 10); txtPublisherUrl.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtPublisherUrl); TextBlock txtSourceUrl = new TextBlock(); txtSourceUrl.Text = "Source URL: " + recipe.SourceUrl; txtSourceUrl.Margin = new Thickness(10, 10, 10, 10); txtSourceUrl.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtSourceUrl); TextBlock txtF2fUrl = new TextBlock(); txtF2fUrl.Text = "F2F URL: " + recipe.F2fUrl; txtF2fUrl.Margin = new Thickness(10, 10, 10, 10); txtF2fUrl.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtF2fUrl); grid.Children.Add(stk); pivotItem.Content = grid; pvtFavorites.Items.Add(pivotItem); } }
private void populateRecipes() { // PivotItem pvt; int i = 0; if (listRecipes.Count == 0) { PivotItem pivotItem = new PivotItem(); pivotItem.Header = "No Results"; TextBlock txtTitle = new TextBlock(); txtTitle.Text = "No Results Found"; txtTitle.Margin = new Thickness(10, 10, 10, 10); pivotItem.Content = txtTitle; pvtRecipes.Items.Add(pivotItem); } foreach (Model.ResponseYummly recipe in listRecipes) { PivotItem pivotItem = new PivotItem(); pivotItem.Header = recipe.RecipeName; Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); Image img = new Image(); img.Source = new BitmapImage(new Uri(recipe.ImageUrl)); img.SetValue(Grid.ColumnProperty, 0); grid.Children.Add(img); Image favorite = new Image(); favorite.Name = "favoriteSymbol"+i.ToString(); BitmapImage starImage = new BitmapImage(); starImage.UriSource = new Uri("https://image.freepik.com/free-icon/favorites-star-outlined-symbol_318-69168.png"); favorite.Source = starImage; favorite.HorizontalAlignment = HorizontalAlignment.Right; favorite.VerticalAlignment = VerticalAlignment.Top; favorite.Width = 15; favorite.Height = 15; favorite.Tapped += Favorite_Tapped; favorite.SetValue(Grid.ColumnProperty, 1); i++; //grid.Children.Add(favorite); StackPanel stk = new StackPanel(); stk.Name = "recipeStk"; stk.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(favorite); TextBlock txtTitle = new TextBlock(); txtTitle.Text = "Title: " + recipe.RecipeName; txtTitle.Margin = new Thickness(10, 10, 10, 10); txtTitle.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtTitle); TextBlock txtRecipeId = new TextBlock(); txtRecipeId.Text = "RecipeId: " + recipe.Id; txtRecipeId.Margin = new Thickness(10, 10, 10, 10); txtRecipeId.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtRecipeId); TextBlock txtIngredientsList = new TextBlock(); txtIngredientsList.Text = "Ingredients: " + recipe.Ingredients.Replace("\",","\n"); txtIngredientsList.Margin = new Thickness(10, 10, 10, 10); txtIngredientsList.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtIngredientsList); TextBlock txtSocialRank = new TextBlock(); txtSocialRank.Text = "Social Rank: " + recipe.Rating.ToString(); txtSocialRank.Margin = new Thickness(10, 10, 10, 10); txtSocialRank.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtSocialRank); TextBlock txtPublisher = new TextBlock(); txtPublisher.Text = "Publisher: " + recipe.SourceDisplayName; txtPublisher.Margin = new Thickness(10, 10, 10, 10); txtPublisher.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtPublisher); TextBlock txtTotalTime = new TextBlock(); txtTotalTime.Text = "Total Time (seconds): " + recipe.TotalTime.ToString(); txtTotalTime.Margin = new Thickness(10, 10, 10, 10); txtTotalTime.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtTotalTime); TextBlock txtCourse = new TextBlock(); txtCourse.Text = "Courses: " + recipe.Course; txtCourse.Margin = new Thickness(10, 10, 10, 10); txtCourse.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtCourse); TextBlock txtCusine = new TextBlock(); txtCusine.Text = "Cuisine: " + recipe.Cuisine; txtCusine.Margin = new Thickness(10, 10, 10, 10); txtCusine.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtCusine); TextBlock txtFlavors = new TextBlock(); txtFlavors.Text = "Flavors: " + recipe.Flavors.Replace(",\"", "\n"); txtFlavors.Margin = new Thickness(10, 10, 10, 10); txtFlavors.SetValue(Grid.ColumnProperty, 1); stk.Children.Add(txtFlavors); grid.Children.Add(stk); pivotItem.Content = grid; pvtRecipes.Items.Add(pivotItem); } }