Example #1
0
        public void FourthCommandImpl()
        {
            if (EntryText.Length > 0)
            {
                if (EntryText.Length >= 1 && EntryText[0] == '0')
                {
                    EntryText = string.Empty;
                    return;
                }
                else
                {
                    float AmountFromEntry;
                    if (float.TryParse(EntryText, out AmountFromEntry))
                    {
                        MealToDisplay mealToDisplay = ChangeRatioMealToDisplay.ChangeRatioMealToDisplayMethod(_mealToDisplay, AmountFromEntry / 100);
                        mealToDisplay.command = _mainPageViewModel.ButtonClickCommand;

                        var numbersoFButtonPosition = GetButtonPosition.GetButtonPositionMethod(mealToDisplay.ButtonName);

                        switch (numbersoFButtonPosition.Item1)
                        {
                        case 1:
                        {
                            _mainPageViewModel.FirstMealCollection.Add(mealToDisplay);
                            break;
                        }

                        case 2:
                        {
                            _mainPageViewModel.SecondMealCollection.Add(mealToDisplay);
                            break;
                        }

                        case 3:
                        {
                            _mainPageViewModel.ThirdMealCollection.Add(mealToDisplay);
                            break;
                        }

                        case 4:
                        {
                            _mainPageViewModel.FourthMealCollection.Add(mealToDisplay);
                            break;
                        }

                        case 5:
                        {
                            _mainPageViewModel.FifthMealCollection.Add(mealToDisplay);
                            break;
                        }
                        }

                        _mainPageViewModel.SaveCollections();

                        Application.Current.MainPage.Navigation.PushAsync(new MainPage(_mainPageViewModel.DaysDifference));
                    }
                }
            }
        }
Example #2
0
 private void ButtonClickCommandImpl(object parameter)
 {
     if (parameter is string ButtonName)
     {
         if (!String.IsNullOrWhiteSpace(ButtonName))
         {
             DeleteMeal.DeleteMealMethod(this, ButtonName);
             var numbersoFButtonPosition = GetButtonPosition.GetButtonPositionMethod(ButtonName);
         }
     }
 }
Example #3
0
        public void FristCommandImpl()
        {
            MealToDisplay mealToDisplay = ChangeRatioMealToDisplay.ChangeRatioMealToDisplayMethod(_mealToDisplay, 0.5f);

            mealToDisplay.command = _mainPageViewModel.ButtonClickCommand;

            var numbersoFButtonPosition = GetButtonPosition.GetButtonPositionMethod(mealToDisplay.ButtonName);

            switch (numbersoFButtonPosition.Item1)
            {
            case 1:
            {
                _mainPageViewModel.FirstMealCollection.Add(mealToDisplay);
                break;
            }

            case 2:
            {
                _mainPageViewModel.SecondMealCollection.Add(mealToDisplay);
                break;
            }

            case 3:
            {
                _mainPageViewModel.ThirdMealCollection.Add(mealToDisplay);
                break;
            }

            case 4:
            {
                _mainPageViewModel.FourthMealCollection.Add(mealToDisplay);
                break;
            }

            case 5:
            {
                _mainPageViewModel.FifthMealCollection.Add(mealToDisplay);
                break;
            }
            }

            _mainPageViewModel.SaveCollections();

            Application.Current.MainPage.Navigation.PushAsync(new MainPage(_mainPageViewModel.DaysDifference));
        }
Example #4
0
        public void RenameMealsInCollection(ObservableCollection <MealToDisplay> mealToDisplays)
        {
            if (mealToDisplays == null)
            {
                return;
            }

            int length = mealToDisplays.Count;

            if (length > 0)
            {
                for (int i = 0; i < length; i++)
                {
                    var numbersoFButtonPosition = GetButtonPosition.GetButtonPositionMethod(mealToDisplays[i].ButtonName);

                    mealToDisplays[i].ButtonName = "btn_" + numbersoFButtonPosition.Item1.ToString() + "_" + (i + 1).ToString();
                }
            }
        }
Example #5
0
        public static void DeleteMealMethod(MainPageViewModel mainPageViewModel, string ButtonName)
        {
            var numbersoFButtonPosition = GetButtonPosition.GetButtonPositionMethod(ButtonName);

            int MealNumber       = numbersoFButtonPosition.Item1;
            int FoodInMealNumber = numbersoFButtonPosition.Item2;

            switch (MealNumber)
            {
            case 1:
            {
                mainPageViewModel.FirstMealCollection.RemoveAt(FoodInMealNumber - 1);
                mainPageViewModel.RenameMealsInCollection(mainPageViewModel.FirstMealCollection);
                if (mainPageViewModel.FirstMealHeight > 80)
                {
                    mainPageViewModel.FirstMealHeight -= 80;
                }
                break;
            }

            case 2:
            {
                mainPageViewModel.SecondMealCollection.RemoveAt(FoodInMealNumber - 1);
                mainPageViewModel.RenameMealsInCollection(mainPageViewModel.SecondMealCollection);
                if (mainPageViewModel.SecondMealHeight > 80)
                {
                    mainPageViewModel.SecondMealHeight -= 80;
                }
                break;
            }

            case 3:
            {
                mainPageViewModel.ThirdMealCollection.RemoveAt(FoodInMealNumber - 1);
                mainPageViewModel.RenameMealsInCollection(mainPageViewModel.ThirdMealCollection);
                if (mainPageViewModel.ThirdMealHeight > 80)
                {
                    mainPageViewModel.ThirdMealHeight -= 80;
                }
                break;
            }

            case 4:
            {
                mainPageViewModel.FourthMealCollection.RemoveAt(FoodInMealNumber - 1);
                mainPageViewModel.RenameMealsInCollection(mainPageViewModel.FourthMealCollection);
                if (mainPageViewModel.FourthMealHeight > 80)
                {
                    mainPageViewModel.FourthMealHeight -= 80;
                }

                break;
            }

            case 5:
            {
                mainPageViewModel.FifthMealCollection.RemoveAt(FoodInMealNumber - 1);
                mainPageViewModel.RenameMealsInCollection(mainPageViewModel.FifthMealCollection);
                if (mainPageViewModel.FifthMealHeight > 80)
                {
                    mainPageViewModel.FifthMealHeight -= 80;
                }
                break;
            }
            }

            SetDetailInformationForEachMeal.SetDetailInformationForEachMealMethod(mainPageViewModel);
            mainPageViewModel.SaveCollections();
            mainPageViewModel.CalculateMacros();
        }