|
|
@ -13,6 +13,8 @@ namespace ConsoleApp.Menu
|
|
|
|
where T : notnull
|
|
|
|
where T : notnull
|
|
|
|
{
|
|
|
|
{
|
|
|
|
protected StringBuilder _screenDisplay;
|
|
|
|
protected StringBuilder _screenDisplay;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected List<Selector<T>> _allSelectors = new List<Selector<T>>();
|
|
|
|
protected List<Selector<T>> _selectList = new List<Selector<T>>();
|
|
|
|
protected List<Selector<T>> _selectList = new List<Selector<T>>();
|
|
|
|
|
|
|
|
|
|
|
|
public string Title { get; private set; }
|
|
|
|
public string Title { get; private set; }
|
|
|
@ -53,13 +55,48 @@ namespace ConsoleApp.Menu
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_selectList = selections.ToList();
|
|
|
|
_allSelectors = selections.ToList();
|
|
|
|
CurrentSelected = _selectList[0].Item;
|
|
|
|
_selectList = _allSelectors;
|
|
|
|
|
|
|
|
CurrentSelected = _allSelectors[0].Item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public abstract IMenu? Return();
|
|
|
|
public abstract IMenu? Return();
|
|
|
|
|
|
|
|
|
|
|
|
protected abstract List<Selector<T>> SearchInSelection();
|
|
|
|
protected virtual List<Selector<T>> SearchInSelection()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_allSelectors is null)
|
|
|
|
|
|
|
|
throw new Exception("Error: _allSelector is null.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return _allSelectors.FindAll(x =>
|
|
|
|
|
|
|
|
x.Line.ToLower().Contains(InputStr.ToString().ToLower()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void WriteMenuMode(ConsoleKeyInfo cki)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!WriteMode && cki.Key == ConsoleKey.R)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EnableWriteMode();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (WriteMode)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (cki.Key == ConsoleKey.Escape)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DisableWriteMode();
|
|
|
|
|
|
|
|
InputStr.Clear();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cki.Key == ConsoleKey.Backspace && InputStr.Length > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
InputStr.Remove(InputStr.Length - 1, 1);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InputStr.Append(cki.KeyChar);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Update()
|
|
|
|
public void Update()
|
|
|
|
{
|
|
|
|
{
|
|
|
|