working on MasterManager

pull/48/head
Alexandre AGOSTINHO 2 years ago
parent b6729c5f68
commit 9eef461a44

@ -3,7 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ConsoleApp.Menu.Core;
namespace ConsoleApp.Menu
{
internal class ConnectionMenu : Entry

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp.Menu
namespace ConsoleApp.Menu.Core
{
internal abstract partial class Entry
{

@ -3,8 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp.Menu
using ConsoleApp.Menu.Core;
namespace ConsoleApp.Menu.Core
{
/// <summary>
/// Define an Entry menu.

@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp.Menu
namespace ConsoleApp.Menu.Core
{
/// <summary>
/// Define a console menu with element selection.

@ -7,7 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp.Menu
namespace ConsoleApp.Menu.Core
{
/// <summary>
/// Define a selection menu.
@ -44,7 +44,7 @@ namespace ConsoleApp.Menu
{
_currentLine = value;
if (_currentLine <= 0) _currentLine = 0;
else if (_currentLine >= _selectList.Count) _currentLine = _selectList.Count-1;
else if (_currentLine >= _selectList.Count) _currentLine = _selectList.Count - 1;
}
}
@ -75,7 +75,7 @@ namespace ConsoleApp.Menu
/// </summary>
/// <param name="title">The title of the menu.</param>
/// <param name="selections">The selections of the menu.</param>
protected Menu(string title, params Selector<T>[] selections ) : this(title)
protected Menu(string title, params Selector<T>[] selections) : this(title)
{
if (selections == null || selections.Length == 0)
{

@ -3,8 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp.Menu
namespace ConsoleApp.Menu.Core
{
/// <summary>
/// Define a Plain text menu.
@ -36,16 +36,16 @@ namespace ConsoleApp.Menu
public StringBuilder InputStr { get; set; }
public void DisableWriteMode()
{
// Plain text does not need to do anything for this.
{
// Plain text does not need to do anything for this.
}
public void EnableWriteMode()
{
// Plain text does not need to do anything for this.
{
// Plain text does not need to do anything for this.
}
public void SelectNext()
{
// Plain text does not need to do anything for this.
{
// Plain text does not need to do anything for this.
}
public void SelectPrevious()
{

@ -7,7 +7,7 @@ using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp.Menu
namespace ConsoleApp.Menu.Core
{
/// <summary>
/// The selector of a menu.
@ -22,7 +22,8 @@ namespace ConsoleApp.Menu
/// <summary>
/// The string that are displayed on the menu.
/// </summary>
public string Line {
public string Line
{
get => _line;
private set
{
@ -57,7 +58,7 @@ namespace ConsoleApp.Menu
{
if (other == null) return false;
if (other == this) return true;
return other.Line.Equals(this.Line);
return other.Line.Equals(Line);
}
public override bool Equals(object? obj)

@ -5,7 +5,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ConsoleApp.Menu.Core;
namespace ConsoleApp.Menu
{
/// <summary>

@ -4,7 +4,7 @@ using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using ConsoleApp.Menu.Core;
using Model;
namespace ConsoleApp.Menu

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ConsoleApp.Menu.Core;
namespace ConsoleApp
{
@ -23,7 +24,7 @@ namespace ConsoleApp
/// <summary>
/// Each menu called are push in this stack. Then, to return back, we pop this stack to retrive the previous menu.
/// </summary>
public Stack<Menu.IMenu> MenuCallStack { get; set; }
public Stack<IMenu> MenuCallStack { get; set; }
#endregion
#region Constructors
@ -32,11 +33,11 @@ namespace ConsoleApp
/// </summary>
/// <param name="dataManager">The data manager needed by the menus inside.</param>
/// <param name="firstMenu">The starting menu, the first that will be push on the call stack.</param>
public MenuManager(DataManager dataManager, Menu.IMenu firstMenu)
public MenuManager(DataManager dataManager, IMenu firstMenu)
{
DataManager = dataManager;
MenuCallStack = new Stack<Menu.IMenu>();
MenuCallStack = new Stack<IMenu>();
MenuCallStack.Push(firstMenu);
}
@ -55,7 +56,7 @@ namespace ConsoleApp
public void Loop()
{
ConsoleKeyInfo cki;
Menu.IMenu menuOnHead;
IMenu menuOnHead;
do
{
menuOnHead = MenuCallStack.Peek();
@ -72,7 +73,7 @@ namespace ConsoleApp
menuOnHead.SelectPrevious();
break;
case ConsoleKey.Enter:
Menu.IMenu? retMenu = menuOnHead.Return();
IMenu? retMenu = menuOnHead.Return();
if (retMenu is null) MenuCallStack.Pop();
else MenuCallStack.Push(retMenu);
break;

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.Managers
{
public class MasterManager
{
public static User? CurrentConnectedUser;
public static RecipeCollection? Recipes;
public static List<User>? Users;
public DataManager DataMgr { get; private set; }
public MasterManager(IDataManager dataManager)
{
DataMgr = new DataManager(dataManager);
Recipes = DataMgr.GetRecipes("all recipes");
Users = DataMgr.GetUsers();
CurrentConnectedUser = null;
}
public bool LogIn(string mail, string password)
{
if (Users is null)
throw new ArgumentNullException();
User user = (User)(from u in Users
where u.Mail == mail
select u);
}
}
}

@ -131,7 +131,6 @@ namespace Model
#endregion
#region Constructors
/// <summary>
@ -159,7 +158,5 @@ namespace Model
#endregion
}
}

Loading…
Cancel
Save