Beispiel #1
0
        public void MenuDelete_Click(object sender, EventArgs e)
        {
            if (parent.flpCurrent == MainForm.flpItems.Custom)
            {
                string fp = JsonFunctions.GetFilepath(CustomForm.foodFile);
                CustomForm.RemoveCustomFood(fp, food);
                parent.PopulateResults(CustomForm.GetCustomFood(fp), edit, rightClick);
            }
            else if (parent.flpCurrent == MainForm.flpItems.Eaten)
            {
                List <User> users     = FoodForm.GetAllUsers();
                User        user      = users.Find(x => x.id == parent.currentUser.id);
                int         i         = users.IndexOf(user);
                int         foodIndex = user.food_eaten.FindIndex(x => x.item_id == food.item_id);
                if (foodIndex != -1)
                {
                    user.food_eaten.RemoveAt(foodIndex);
                    user.eaten_cal = user.EatenCal();

                    users[i] = user;
                    JsonFunctions.WriteJSON(users, JsonFunctions.GetFilepath(UserForm.filename));

                    parent.currentUser = user;
                    parent.SetCalories();
                    parent.PopulateResults(user.food_eaten, edit, rightClick);
                }
            }
            else if (parent.flpCurrent == MainForm.flpItems.Search)
            {
                return;
            }
        }
Beispiel #2
0
        public void MenuEdit_Click(object sender, EventArgs e)
        {
            ShowCustomForm();
            string fp = JsonFunctions.GetFilepath(CustomForm.foodFile);

            parent.PopulateResults(CustomForm.GetCustomFood(fp), edit, rightClick);
        }
Beispiel #3
0
        private void btnShowCustom_Click(object sender, EventArgs e)
        {
            List <Food> customFood = CustomForm.GetCustomFood(JsonFunctions.GetFilepath(CustomForm.foodFile));

            PopulateResults(customFood, false, true);

            flpCurrent = flpItems.Custom;
            UpdateSourceLabel();
        }