You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.5 KiB
57 lines
1.5 KiB
// See https://aka.ms/new-console-template for more information
|
|
|
|
using ConsoleApp;
|
|
using Model;
|
|
using System.Text;
|
|
|
|
Console.WriteLine("Hello, World!\n\n");
|
|
|
|
|
|
// TESTS:
|
|
|
|
Stub stub = new Stub();
|
|
|
|
List<Recipe> recipes = stub.LoadRecipes();
|
|
List<RecipeCollection> recipeCollections = stub.LoadRecipeCollection();
|
|
|
|
RecipeCollection? allRecipe = recipeCollections.Find(x => x.Description.Equals("All"));
|
|
if (allRecipe == null)
|
|
throw new ArgumentException("Load AllRecipe in stub: can't find 'All'.");
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
ResearchMenuRecipe researchMenu = new ResearchMenuRecipe();
|
|
Recipe[] result = allRecipe.ResearchByName(sb.ToString());
|
|
researchMenu.UpdateDisplay(sb.ToString(), result);
|
|
|
|
ConsoleKeyInfo cki;
|
|
|
|
do
|
|
{
|
|
cki = Console.ReadKey(true);
|
|
|
|
switch (cki.Key)
|
|
{
|
|
case ConsoleKey.UpArrow:
|
|
researchMenu.SelectPrevioustLine();
|
|
break;
|
|
case ConsoleKey.DownArrow:
|
|
researchMenu.SelectNextLine();
|
|
break;
|
|
case ConsoleKey.Backspace:
|
|
if (sb.Length > 0)
|
|
{
|
|
sb.Remove(sb.Length - 1, 1);
|
|
result = allRecipe.ResearchByName(sb.ToString());
|
|
}
|
|
break;
|
|
default:
|
|
sb.Append(cki.KeyChar);
|
|
result = allRecipe.ResearchByName(sb.ToString());
|
|
break;
|
|
}
|
|
|
|
researchMenu.UpdateDisplay(sb.ToString(), result);
|
|
|
|
} while (cki.Key != ConsoleKey.Enter);
|
|
|
|
Console.WriteLine(researchMenu.ReturnSelected()); |