Пример #1
0
        public static void MainMenu()
        {
            while (true)
            {
                var chosenOption = Menu("main menu", 37, MainMenuIntro, new string[] { "Search Recipes", "Add Recipe", "Delete Recipe", "Edit Receipe", "Turn Hints Off", "Exit" });
                switch (chosenOption)
                {
                case 0:
                    ViewRecipe();
                    break;

                case 1:
                    AddRecipe();
                    break;

                case 2:
                    DeleteRecipe();
                    break;

                case 3:
                    EditRecipe();
                    break;

                case 4:
                    ConsoleShef.Disactivate();
                    break;

                case 5:
                case -1:
                    return;
                }
            }
        }
Пример #2
0
 private void Setup()
 {
     ConsoleShef.Activate();
     if (File.Exists("recipes.json"))
     {
         Recipe.ReadFromFile();
     }
 }
Пример #3
0
 private static void Setup()
 {
     ConsoleShef.Activate();
     if (File.Exists("recipes.json"))
     {
         Recipe.ReadFromFile();
     }
     System.Threading.Thread.Sleep(1000);
 }
Пример #4
0
 private static void Unfinished()
 {
     System.Threading.Thread.Sleep(100);
     ConsoleShef.ChangeMood("angry");
     ConsoleShef.Say("Didn't have time for that");
     ConsoleShef.ChangeMood("happy");
     ConsoleShef.Say("But i'm sure you will deal with it!");
     ConsoleShef.ChangeMood("regular");
 }
Пример #5
0
 private static void SearchMenuIntro()
 {
     if (_isTutorialPassed["Find"])
     {
         BlankScript();
         return;
     }
     ConsoleShef.ChangeMood("advicing");
     ConsoleShef.Say("Choose any available recipe from occured list and see it full information");
     ConsoleShef.ChangeMood("regular");
     _isTutorialPassed["Find"] = true;
 }
Пример #6
0
        private static Recipe SearchRecipes(string header = "Search Recipes")
        {
            Console.Clear();
            DrawHeader(header, 73);
            if (!_isTutorialPassed["Find"])
            {
                ConsoleShef.ChangeMood("surprized");
                ConsoleShef.Say("this is search menu");
                ConsoleShef.ChangeMood("puzzled");
                ConsoleShef.Say("Firstly, enter filter row by wich i will search recipes");
                ConsoleShef.Say("This can be the name of the whole recipe or it's particular ingredient");
            }
            Console.WriteLine("Please, enter name of recipe or name of ingredient:");
            var filter = Console.ReadLine().Trim().ToLower();

            Console.Write("Searching");
            for (int i = 0; i < 3; i++)
            {
                System.Threading.Thread.Sleep(500);
                Console.Write(".");
            }
            Console.WriteLine();
            var recipesList = Recipe.Recipes.Where(r => r.Name.ToLower().Contains(filter) ||
                                                   r.Ingredients.Select(i => i.Name.ToLower()).Contains(filter)).ToList();

            if (recipesList.Count == 0)
            {
                Console.WriteLine("-------------------------");
                Console.WriteLine("    No matches found!");
                Console.WriteLine("-------------------------");
                Console.WriteLine("Press any key to continue...");
                Console.ReadLine();
                return(null);
            }
            recipesList.OrderBy(e => e.Name).OrderBy(e => e.Proteins + e.Fats + e.Carbonohydrates);
            var recipesArray = new string[recipesList.Count];

            for (int i = 0; i < recipesList.Count; i++)
            {
                recipesArray[i] = recipesList[i].ToString();
            }
            int chosenRecipe = Menu("Search results", 73, SearchMenuIntro, recipesArray);

            if (chosenRecipe == -1)
            {
                return(null);
            }
            var recipe = recipesList[chosenRecipe];

            return(recipe);
        }
Пример #7
0
 private static void EditCaloriesIntro()
 {
     if (_isTutorialPassed["EditCalories"])
     {
         BlankScript();
         return;
     }
     System.Threading.Thread.Sleep(100);
     ConsoleShef.ChangeMood("puzzled");
     ConsoleShef.Say("here you can change Recipe calories");
     ConsoleShef.ChangeMood("regular");
     ConsoleShef.Say("to continue choose an option");
     _isTutorialPassed["EditCalories"] = true;
 }
Пример #8
0
 private static void EditMenuIntro()
 {
     if (_isTutorialPassed["Edit"])
     {
         BlankScript();
         return;
     }
     System.Threading.Thread.Sleep(100);
     ConsoleShef.ChangeMood("surprized");
     ConsoleShef.Say("in this menu you can edit your recipes");
     ConsoleShef.ChangeMood("regular");
     ConsoleShef.Say("to start choose an option");
     _isTutorialPassed["Edit"] = true;
 }
Пример #9
0
 static void Main(string[] args)
 {
     try
     {
         Setup();
         MenuManager.MainMenu();
     }
     catch (Exception)
     {
         Console.Clear();
         ConsoleShef.ChangeMood("dead");
         ConsoleShef.Say("I'm terribly sorry, but some unknown error ocured!");
     }
     Teardown();
 }
Пример #10
0
        private static void AddMenuIntro()
        {
            if (_isTutorialPassed["Add"])
            {
                BlankScript();
                return;
            }
            System.Threading.Thread.Sleep(100);
            ConsoleShef.ChangeMood("surprized");
            ConsoleShef.Say("here you can add new recipe");
            ConsoleShef.ChangeMood("puzzled");
            ConsoleShef.Say("Simply follow given below instructions.");
            ConsoleShef.ChangeMood("sad");
            ConsoleShef.Say("it's really hard to mess things up here");
            ConsoleShef.ChangeMood("regular");

            _isTutorialPassed["Add"] = true;
        }
Пример #11
0
        private static void DeleteMenuIntro()
        {
            if (_isTutorialPassed["Delete"])
            {
                BlankScript();
                return;
            }
            System.Threading.Thread.Sleep(100);
            ConsoleShef.ChangeMood("surprized");
            ConsoleShef.Say("here you can delete recipe");
            ConsoleShef.ChangeMood("puzzled");
            ConsoleShef.Say("Rules are all the same with search menu");
            ConsoleShef.ChangeMood("regular");
            ConsoleShef.Say("After choosing recipe type confirm to approve its deletion");
            ConsoleShef.ChangeMood("happy");
            ConsoleShef.Say("Easy,right?");
            ConsoleShef.ChangeMood("regular");

            _isTutorialPassed["Delete"] = true;
        }
Пример #12
0
        private static void MainMenuIntro()
        {
            if (_isTutorialPassed["Main"])
            {
                BlankScript();
                return;
            }

            ConsoleShef.ChangeMood("happy");
            ConsoleShef.Say("Hello!");
            ConsoleShef.ChangeMood("surprized");
            ConsoleShef.Say("this is main menu");
            ConsoleShef.ChangeMood("puzzled");
            ConsoleShef.Say("You can navigate with arrows on your keyboard");
            ConsoleShef.Say("Press Enter to select an option, or press esc to quit menu");
            ConsoleShef.ChangeMood("regular");
            ConsoleShef.Say("This rules are same for all menues");
            ConsoleShef.ChangeMood("doubtful");
            ConsoleShef.Say("if I annoy you way too much you can always turn my hints off.");
            ConsoleShef.ChangeMood("regular");
            _isTutorialPassed["Main"] = true;
        }
Пример #13
0
 private static void Teardown()
 {
     ConsoleShef.Disactivate();
     Recipe.SaveToFile();
 }
Пример #14
0
 private static void MainMenuIntro()
 {
     ConsoleShef.ChangeMood("regular");
     ConsoleShef.Say("Hello!");
     ConsoleShef.Say("this is main menu");
 }
Пример #15
0
        private static int Menu(string header, int menuWidth, PlayScript script, params string[] options)
        {
            Console.Clear();
            int  chosen         = 0;
            bool scriptisPlayed = false;

            while (true)
            {
                Console.SetCursorPosition(0, 0);
                DrawHeader(header, menuWidth);
                ConsoleShef.ChangeMood("regular");

                foreach (var option in options)
                {
                    if (option == options[chosen])
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write(TableBuilder.AlignCentre(option, menuWidth));
                        Console.ForegroundColor = ConsoleColor.White;
                    }
                    else
                    {
                        Console.Write(TableBuilder.AlignCentre(option, menuWidth));
                    }
                    Console.SetCursorPosition(0, Console.CursorTop + 1);
                }
                if (!scriptisPlayed)
                {
                    script();
                    scriptisPlayed = true;
                }

                switch (Console.ReadKey(true).Key)
                {
                case ConsoleKey.Enter:
                    Console.Clear();
                    return(chosen);

                case ConsoleKey.UpArrow:
                    if (chosen == 0)
                    {
                        chosen = options.Length - 1;
                    }
                    else
                    {
                        chosen--;
                    }
                    break;

                case ConsoleKey.DownArrow:
                    if (chosen == options.Length - 1)
                    {
                        chosen = 0;
                    }
                    else
                    {
                        chosen++;
                    }
                    break;

                case ConsoleKey.Escape: return(-1);
                }
            }
        }