Example #1
0
        public void DisplayRecipe(Cocktail cocktail)
        {
            FieldInfo[] fields      = typeof(Cocktail).GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
            var         ingredients = fields.Where(x => x.Name.Contains("StrIngredient") && x.GetValue(cocktail).ToString() != "")
                                      .ToList();
            var measurements = fields.Where(x => x.Name.Contains("StrMeasure") && x.GetValue(cocktail).ToString() != "")
                               .ToList();

            var instructions = "Ingredients:\n\n";

            for (var i = 0; i < ingredients.Count; i++)
            {
                instructions += ingredients[i].GetValue(cocktail) + " " + measurements[i].GetValue(cocktail) + "\n";
            }

            drinkTitleLbl.Text  = cocktail.StrDrink;
            ingredientsLbl.Text = instructions;
            recipeLbl.Text      = "Instructions:\n\n" + cocktail.StrInstructions;
            cocktailImg.Source  = ImageSource.FromUri(new Uri(cocktail.StrDrinkThumb));
        }
Example #2
0
        public MainPage()
        {
            InitializeComponent();
            Resources.Add(StyleSheet.FromAssemblyResource(
                              typeof(MainPage).GetTypeInfo().Assembly,
                              "MixoLogy.Assets.styles.css"));

            _cocktails = Cocktail.LoadCocktailsCollection();
            CreateGrid(_cocktails);
            var button = new Button
            {
                Text              = "Load More",
                BackgroundColor   = Color.HotPink,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Margin            = new Thickness(5, 5, 5, 40)
            };

            button.Clicked += LoadMore;
            stackLayout.Children.Add(button);
        }