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.
69 lines
1.8 KiB
69 lines
1.8 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
using Model;
|
|
|
|
namespace ConsoleApp
|
|
{
|
|
internal class SearcherRecipe
|
|
{
|
|
public int CurrentLine
|
|
{
|
|
get => _currentLine;
|
|
set
|
|
{
|
|
_currentLine = value;
|
|
if (_currentLine > _maxLines)
|
|
{
|
|
_currentLine = _maxLines;
|
|
}
|
|
if (_currentLine < 0)
|
|
{
|
|
_currentLine = 0;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
|
|
public Recipe? CurrentSelected { get; private set; }
|
|
|
|
private int _currentLine = 0;
|
|
private int _maxLines = 0;
|
|
|
|
|
|
public void UpdateDisplay(string researchStr, RecipeCollection researchResult)
|
|
{
|
|
_maxLines = researchResult.Count - 1;
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.AppendLine("---------------------------------------------------------");
|
|
sb.AppendLine($" Research: {researchStr}");
|
|
sb.AppendLine("---------------------------------------------------------");
|
|
for (int i = 0; i < researchResult.Count; 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;
|
|
}
|
|
}
|
|
}
|