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.
72 lines
1.9 KiB
72 lines
1.9 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
using Model;
|
|
|
|
namespace ConsoleApp
|
|
{
|
|
internal class ResearchMenuRecipe
|
|
{
|
|
internal string displayText = "";
|
|
public int CurrentLine
|
|
{
|
|
get => currentLine;
|
|
set
|
|
{
|
|
currentLine = value;
|
|
if (currentLine > maxLines)
|
|
{
|
|
currentLine = maxLines;
|
|
}
|
|
if (currentLine < 0)
|
|
{
|
|
currentLine = 0;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
private int currentLine = 0;
|
|
private int maxLines = 0;
|
|
private Recipe? currentSelected;
|
|
|
|
public void UpdateDisplay(string researchStr, Recipe[] researchResult)
|
|
{
|
|
maxLines = researchResult.Length - 1;
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.AppendLine("---------------------------------------------------------");
|
|
sb.AppendLine($" Research: {researchStr}");
|
|
sb.AppendLine("---------------------------------------------------------");
|
|
for (int i = 0; i < researchResult.Length; i++)
|
|
{
|
|
if (i == CurrentLine)
|
|
{
|
|
currentSelected = researchResult[i];
|
|
sb.Append($">");
|
|
}
|
|
sb.AppendLine($" [ {researchResult[i].Id} ]: {researchResult[i].Title} ");
|
|
}
|
|
Console.Clear();
|
|
Console.WriteLine(sb);
|
|
}
|
|
|
|
public int SelectNextLine()
|
|
{
|
|
return ++CurrentLine;
|
|
}
|
|
|
|
public int SelectPrevioustLine()
|
|
{
|
|
return --CurrentLine;
|
|
}
|
|
|
|
public Recipe? ReturnSelected()
|
|
{
|
|
return currentSelected;
|
|
}
|
|
}
|
|
}
|