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; } } }
private void Setup() { ConsoleShef.Activate(); if (File.Exists("recipes.json")) { Recipe.ReadFromFile(); } }
private static void Setup() { ConsoleShef.Activate(); if (File.Exists("recipes.json")) { Recipe.ReadFromFile(); } System.Threading.Thread.Sleep(1000); }
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"); }
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; }
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); }
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; }
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; }
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(); }
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; }
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; }
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; }
private static void Teardown() { ConsoleShef.Disactivate(); Recipe.SaveToFile(); }
private static void MainMenuIntro() { ConsoleShef.ChangeMood("regular"); ConsoleShef.Say("Hello!"); ConsoleShef.Say("this is main menu"); }
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); } } }