Пример #1
0
        public void DisplayFood(int foodId = -1)
        {
            displayedNutrient = null;
            if (foodId != -1)
            {
                displayedFoodItem = foodDescs.FirstOrDefault(p => p.id == foodId);
            }
            if (displayedFoodItem == null)
            {
                lblFoodDetail.Text = "Nothing selected";
                chkLock.Visible    = nudUnitsInPlan.Visible = label1.Visible = false;
                return;
            }
            lblFoodDetail.Text = "Food details:" + Environment.NewLine +
                                 "Full name: " + displayedFoodItem.longDesc + Environment.NewLine +
                                 "Group: " + foodGroups.First(p => p.id == displayedFoodItem.foodGroupId); //TODO: Add tags and stuff to foods

            //Only show the fields that link to the winning chromosome if this food is enabled
            chkLock.Visible = nudUnitsInPlan.Visible = label1.Visible = foodEnabled.Contains(displayedFoodItem.id) && solver != null;

            int count = 0;

            if (solver != null && solver.HasWinner)
            {
                solver.GetWinningFoods().TryGetValue(displayedFoodItem.id, out count);
            }
            nudUnitsInPlan.Value = count;
            chkLock.Checked      = foodLocked.Contains(displayedFoodItem.id);
            UpdateTable();
        }
Пример #2
0
        public void DisplayNutrient(ushort nutrientId)
        {
            displayedNutrient  = nutrients.FirstOrDefault(p => p.id == nutrientId);
            displayedFoodItem  = null;
            chkLock.Visible    = nudUnitsInPlan.Visible = label1.Visible = false;
            lblFoodDetail.Text = "Nutrient details:" + Environment.NewLine +
                                 "Name: " + displayedNutrient.name + Environment.NewLine +
                                 "Unit of measure: " + displayedNutrient.unitOfMeasure;

            UpdateTable();
        }