change nested class 'ConsoleMenu' to namespace 'Menu'
continuous-integration/drone/push Build is passing Details

pull/35/head
Alexandre AGOSTINHO 2 years ago
parent b2e6217d10
commit 1a2ecceb25

@ -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();
}
}
}

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp
namespace ConsoleApp.Menu
{
internal interface IMenuDisplay
{

@ -7,10 +7,8 @@ using System.Threading.Tasks;
using Model;
namespace ConsoleApp
namespace ConsoleApp.Menu
{
public partial class ConsoleMenu : Manager
{
/// <summary>
/// An utility to find a recipe.
/// </summary>
@ -124,5 +122,4 @@ namespace ConsoleApp
}
#endregion
}
}
}

@ -0,0 +1,52 @@
using ConsoleApp;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp.Menu
{
/// <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();
}
}

@ -1,6 +1,7 @@
// See https://aka.ms/new-console-template for more information
using ConsoleApp;
using ConsoleApp.Menu;
using Model;
using System.Text;
@ -21,8 +22,8 @@ if (allRecipe == null)
Manager manager = new Manager(allRecipe);
Console.WriteLine(ConsoleMenu.SearcherRecipe.ResearchOn(manager.AllRecipes));
Recipe? ret = SearcherRecipe.ResearchOn(allRecipe);
Console.WriteLine(ret);
// press any key to quit
Console.ReadKey();

Loading…
Cancel
Save