コード例 #1
0
        public void loadView()
        {
            stackPanel = new StackPanel();
            List <Recipe> recipes = new List <Recipe>();

            for (int i = 0; i < 7; i++)
            {
                Recipe bRecipe = mealWeek.getMeal(Meals.Breakfast, i);
                Recipe lRecipe = mealWeek.getMeal(Meals.Lunch, i);
                Recipe dRecipe = mealWeek.getMeal(Meals.Dinner, i);

                if (bRecipe.Name != "")
                {
                    for (int x = 0; x < bRecipe.Ingredients.Count; x++)
                    {
                        float amount = Kitchen_Database.Use_IngredientInInventory(bRecipe.Ingredients[x]);
                        if (amount < 0)
                        {
                            continue;
                        }
                        TextBlock textBlock = new TextBlock();
                        textBlock.Text       = bRecipe.Ingredients[x].Name + " (" + amount.ToString() + " " + bRecipe.Ingredients[x].Amount.UnitsOfMeasurement + ")";
                        textBlock.Background = Brushes.Transparent;
                        textBlock.FontWeight = FontWeights.Bold;
                        stackPanel.Children.Add(textBlock);
                    }
                }
                if (dRecipe.Name != "")
                {
                    for (int x = 0; x < lRecipe.Ingredients.Count; x++)
                    {
                        float amount = Kitchen_Database.Use_IngredientInInventory(lRecipe.Ingredients[x]);
                        if (amount < 0)
                        {
                            continue;
                        }
                        TextBlock textBlock = new TextBlock();
                        textBlock.Text       = lRecipe.Ingredients[x].Name + " (" + amount.ToString() + " " + lRecipe.Ingredients[x].Amount.UnitsOfMeasurement + ")";
                        textBlock.Background = Brushes.Transparent;
                        textBlock.FontWeight = FontWeights.Bold;
                        stackPanel.Children.Add(textBlock);
                    }
                }
                if (lRecipe.Name != "")
                {
                    for (int x = 0; x < dRecipe.Ingredients.Count; x++)
                    {
                        float amount = Kitchen_Database.Use_IngredientInInventory(dRecipe.Ingredients[x]);
                        if (amount < 0)
                        {
                            continue;
                        }
                        TextBlock textBlock = new TextBlock();
                        textBlock.Text       = dRecipe.Ingredients[x].Name + " (" + amount.ToString() + " " + dRecipe.Ingredients[x].Amount.UnitsOfMeasurement + ")";
                        textBlock.Background = Brushes.Transparent;
                        textBlock.FontWeight = FontWeights.Bold;
                        stackPanel.Children.Add(textBlock);
                    }
                }
            }
            Border border = new Border();

            border.Background      = Brushes.GhostWhite;
            border.BorderBrush     = Brushes.Gainsboro;
            border.BorderThickness = new Thickness(1);
            border.Margin          = new Thickness(0, 0, 10, 0);

            border.Child = stackPanel;

            Grid.SetColumn(border, 1);
            Grid.SetRow(border, 4);
            TheGrid.Children.Add(border);
        }
コード例 #2
0
        public void loadView()
        {
            Recipe temp;
            string tempName;

            for (int i = 0; i < 7; i++)
            {
                Border border = new Border();
                border.Background      = Brushes.GhostWhite;
                border.BorderBrush     = Brushes.Gainsboro;
                border.BorderThickness = new Thickness(1);
                border.Margin          = new Thickness(0, 0, 10, 0);
                border.Name            = "b" + (i + 1).ToString();

                StackPanel stackPanel = new StackPanel();
                stackPanel.Margin = new Thickness(5);

                //textblock for day of the week
                TextBlock day = new TextBlock();
                day.Text       = mealWeek.DaysOfWeek[i].ToString() + ":";
                day.Background = Brushes.Transparent;
                day.FontWeight = FontWeights.Bold;
                day.Margin     = new Thickness(0, 0, 0, 10);

                TextBlock breakfast = new TextBlock();
                breakfast.Text       = "Breakfast";
                breakfast.Background = Brushes.Transparent;
                breakfast.FontWeight = FontWeights.Bold;

                breakFastArray[i]             = new ComboBox();
                breakFastArray[i].ItemsSource = recipeNames;
                temp     = mealWeek.getMeal(Meals.Breakfast, i);
                tempName = temp.Name;
                if (recipeNames.Contains(tempName))
                {
                    breakFastArray[i].SelectedValue = tempName;
                }

                TextBlock lunch = new TextBlock();
                lunch.Text       = "Lunch";
                lunch.Background = Brushes.Transparent;
                lunch.FontWeight = FontWeights.Bold;

                lunchArray[i]             = new ComboBox();
                lunchArray[i].ItemsSource = recipeNames;
                temp     = mealWeek.getMeal(Meals.Lunch, i);
                tempName = temp.Name;
                if (recipeNames.Contains(tempName))
                {
                    lunchArray[i].SelectedValue = tempName;
                }

                TextBlock dinner = new TextBlock();
                dinner.Text       = "Dinner";
                dinner.Background = Brushes.Transparent;
                dinner.FontWeight = FontWeights.Bold;

                dinnerArray[i]             = new ComboBox();
                dinnerArray[i].ItemsSource = recipeNames;
                temp     = mealWeek.getMeal(Meals.Dinner, i);
                tempName = temp.Name;
                if (recipeNames.Contains(tempName))
                {
                    dinnerArray[i].SelectedValue = tempName;
                }

                stackPanel.Children.Add(day);
                stackPanel.Children.Add(breakfast);
                stackPanel.Children.Add(breakFastArray[i]);
                stackPanel.Children.Add(lunch);
                stackPanel.Children.Add(lunchArray[i]);
                stackPanel.Children.Add(dinner);
                stackPanel.Children.Add(dinnerArray[i]);

                border.Child = stackPanel;

                Grid.SetColumn(border, i + 2);
                Grid.SetRow(border, 4);

                TheGrid.Children.Add(border);
            }
        }