|
|
|
@ -1,62 +0,0 @@
|
|
|
|
|
using ConsoleApp;
|
|
|
|
|
using Model;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace ConsoleApp
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Define multiple type of menu
|
|
|
|
|
/// <br/>See:
|
|
|
|
|
/// <br/>- <see cref="SelectMenu{T}"/>
|
|
|
|
|
/// <br/>- <see cref="SearcherRecipe"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class ConsoleMenu : Manager
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// An abstract class that define the components of a selection-type menu.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T">The return type of the currently selected item</typeparam>
|
|
|
|
|
public abstract class SelectMenu<T> : IMenuDisplay
|
|
|
|
|
{
|
|
|
|
|
protected int _currentLine = 0;
|
|
|
|
|
protected int _maxLines = 0;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The currently selected item.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public T? CurrentSelected { get; protected set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The current line selected in the menu.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int CurrentLine
|
|
|
|
|
{
|
|
|
|
|
get => _currentLine;
|
|
|
|
|
protected set
|
|
|
|
|
{
|
|
|
|
|
_currentLine = value;
|
|
|
|
|
if (_currentLine > _maxLines)
|
|
|
|
|
{
|
|
|
|
|
_currentLine = _maxLines;
|
|
|
|
|
}
|
|
|
|
|
if (_currentLine < 0)
|
|
|
|
|
{
|
|
|
|
|
_currentLine = 0;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int SelectNextLine() { return ++CurrentLine; }
|
|
|
|
|
public int SelectPrevioustLine() { return --CurrentLine; }
|
|
|
|
|
|
|
|
|
|
public abstract void UpdateDisplay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|