Exemple #1
0
        public static IngredientData[] shoppingListToIngredientData(ItemCollection list)
        {
            IngredientData[] ingredientData = new IngredientData[list.Count];

            for (int i = 0; i < list.Count; i++)
            {
                ShoppingListItem item = (ShoppingListItem)list.GetItemAt(i);
                ingredientData[i] = new IngredientData(item.Index, item.Amount);
            }

            return(ingredientData);
        }
        private void setTooltipIngredients()
        {
            string text = "Składniki: \n";

            for (int i = 0; i < this.Ingredients.Length; i++)
            {
                IngredientData ingredient = this.Ingredients[i];
                int            amount     = ingredient.Amount;
                Ingredient     details    = ingredient.getDetails();

                text += string.Format("{0} x {1} ({2} kcal, {3} zł)\n", amount, details.IngredientName, details.Calories, details.Price);
            }

            this.ToolTip = text;
        }
        public static DishListItem fromIngredient(int i)
        {
            Ingredient  ingredient = MainWindow.INGREDIENTS[i];
            int         calories   = ingredient.Calories;
            double      price      = ingredient.Price;
            BitmapImage image      = Utils.getImageByName(ingredient.ImageName);

            IngredientData[] data = new IngredientData[1];
            data[0] = new IngredientData(i, 1);

            DishListItem ingredientListItem = new DishListItem(ingredient.IngredientName, calories, price, data, image);

            ingredientListItem.ToolTip = null;
            return(ingredientListItem);
        }