From 82751e1a3beba1d52b48c9674f2a1a1b33d8dc25 Mon Sep 17 00:00:00 2001 From: Tarxos Date: Sun, 28 Aug 2022 16:36:09 +0300 Subject: [PATCH 1/4] add project with refactored console menu --- SimpleCMenu.sln | 13 +- SimpleConsoleMenu/Menu.cs | 181 +++++++++++++++++++++ SimpleConsoleMenu/SimpleConsoleMenu.csproj | 9 + 3 files changed, 201 insertions(+), 2 deletions(-) create mode 100644 SimpleConsoleMenu/Menu.cs create mode 100644 SimpleConsoleMenu/SimpleConsoleMenu.csproj diff --git a/SimpleCMenu.sln b/SimpleCMenu.sln index 0bafe94..0f8441b 100644 --- a/SimpleCMenu.sln +++ b/SimpleCMenu.sln @@ -1,10 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25123.0 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32819.101 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCMenu", "SimpleCMenu\SimpleCMenu.csproj", "{15368273-1C43-4939-977F-0C198643CF42}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleConsoleMenu", "SimpleConsoleMenu\SimpleConsoleMenu.csproj", "{61FB74BD-D547-4B8E-BB15-C409F74DE782}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,8 +17,15 @@ Global {15368273-1C43-4939-977F-0C198643CF42}.Debug|Any CPU.Build.0 = Debug|Any CPU {15368273-1C43-4939-977F-0C198643CF42}.Release|Any CPU.ActiveCfg = Release|Any CPU {15368273-1C43-4939-977F-0C198643CF42}.Release|Any CPU.Build.0 = Release|Any CPU + {61FB74BD-D547-4B8E-BB15-C409F74DE782}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61FB74BD-D547-4B8E-BB15-C409F74DE782}.Debug|Any CPU.Build.0 = Debug|Any CPU + {61FB74BD-D547-4B8E-BB15-C409F74DE782}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61FB74BD-D547-4B8E-BB15-C409F74DE782}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {76E8BADE-17FB-4DF9-A7C8-32438D9A06D5} + EndGlobalSection EndGlobal diff --git a/SimpleConsoleMenu/Menu.cs b/SimpleConsoleMenu/Menu.cs new file mode 100644 index 0000000..0fbe71a --- /dev/null +++ b/SimpleConsoleMenu/Menu.cs @@ -0,0 +1,181 @@ +namespace SimpleConsoleMenu; + +public class Menu +{ + private readonly List _menuItemList; + + private int _cursor; + private bool _isExit; + + public Menu(string cursorText = "->") + { + _menuItemList = new(); + _cursor = 0; + + CursorText = cursorText; + CursorColor = ConsoleColor.Yellow; + HeaderColor = ConsoleColor.Blue; + ForeColor = ConsoleColor.White; + MenuItemColor = ConsoleColor.White; + SubTitleColor = ConsoleColor.White; + } + + public Menu? ParentMenu { get; set; } + + public string Header { get; set; } = string.Empty; + public string SubTitle { get; set; } = string.Empty; + public string CursorText { get; set; } + public ConsoleColor CursorColor { get; set; } + public ConsoleColor HeaderColor { get; set; } + public ConsoleColor ForeColor { get; set; } + public ConsoleColor MenuItemColor { get; set; } + public ConsoleColor SubTitleColor { get; set; } + + /// + /// Show menu in console and handle use input, will not return until user use Escape key + /// + public void ShowMenu() + { + Console.CursorVisible = false; + ReprintWithHeader(); + _isExit = false; + // TODO: this is bad, may generate loop inside many loops in menu tree + while (!_isExit) + { + UpdateMenu(); + } + } + + /// + /// Add menu item + /// + /// print text in menu + /// behavior that will be invoked on execute menu item + /// + public bool AddMenuItem(string text, Action action) + { + _menuItemList.Add(new(_menuItemList.Count, text, action)); + return true; + } + + /// + /// Will open parent menu if it exist + /// + /// Throw if parent menu not registered + public void Back() + { + if (ParentMenu is null) throw new InvalidOperationException("You not register parent menu"); + + HideMenu(); + ParentMenu?.ShowMenu(); + } + + /// + /// Exit from menu loop + /// + public void Close() + { + // TODO: fix this: on close open parent menu + ParentMenu?.Close(); + HideMenu(); + } + + private void HideMenu() => _isExit = true; + + private void DrawHeader() + { + Console.ForegroundColor = HeaderColor; + Console.WriteLine(Header); + Console.ForegroundColor = ForeColor; + } + + private void DrawWithHeader() + { + DrawHeader(); + Draw(); + } + + private void Draw() + { + Console.WriteLine(SubTitle); + + for (var i = 0; i < _menuItemList.Count; i++) + { + if (i == _cursor) + { + Console.ForegroundColor = CursorColor; + Console.Write(CursorText + " "); + Console.WriteLine(_menuItemList[i].Text); + Console.ForegroundColor = ForeColor; + continue; + } + + Console.Write(new string(' ', CursorText.Length + 1)); + Console.WriteLine(_menuItemList[i].Text); + } + } + + private static void Clear() => Console.Clear(); + + private void ReprintWithoutHeader() + { + Clear(); + DrawHeader(); + } + + private void ReprintWithHeader() + { + Clear(); + DrawWithHeader(); + } + + private void UpdateMenu() + { + switch (Console.ReadKey(true).Key) + { + case ConsoleKey.UpArrow: + if (_cursor > 0) + { + _cursor--; + ReprintWithHeader(); + } + break; + case ConsoleKey.DownArrow: + if (_cursor < _menuItemList.Count - 1) + { + _cursor++; + ReprintWithHeader(); + } + break; + case ConsoleKey.Escape: + Back(); + break; + case ConsoleKey.Enter: + ExecuteMenuItem(); + break; + } + } + + private void ExecuteMenuItem() + { + ReprintWithoutHeader(); + Console.CursorVisible = true; + _menuItemList[_cursor].Action(); + Console.CursorVisible = false; + ReprintWithHeader(); + } + + private class MenuItem + { + public int Id { get; } + public string Text { get; } + public Action Action { get; } + + public MenuItem(int id, string text, Action action) + { + Id = id; + Text = text; + Action = action; + } + } +} \ No newline at end of file diff --git a/SimpleConsoleMenu/SimpleConsoleMenu.csproj b/SimpleConsoleMenu/SimpleConsoleMenu.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/SimpleConsoleMenu/SimpleConsoleMenu.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + From d2df9879806b99d39f8d5821a9238b5de99af880 Mon Sep 17 00:00:00 2001 From: Tarxos Date: Sun, 28 Aug 2022 16:41:36 +0300 Subject: [PATCH 2/4] add net 6 sample project --- Sample/Program.cs | 43 +++++++++++++++++++++++++++++++++++++++++++ Sample/Sample.csproj | 14 ++++++++++++++ SimpleCMenu.sln | 6 ++++++ 3 files changed, 63 insertions(+) create mode 100644 Sample/Program.cs create mode 100644 Sample/Sample.csproj diff --git a/Sample/Program.cs b/Sample/Program.cs new file mode 100644 index 0000000..ff94518 --- /dev/null +++ b/Sample/Program.cs @@ -0,0 +1,43 @@ +using SimpleConsoleMenu; + +string headerText = " __ __ _____ _ " + + Environment.NewLine + " | \\/ | / ____| | | " + + Environment.NewLine + " | \\ / | ___ _ __ _ _ | (___ _ _ ___| |_ ___ _ __ ___" + + Environment.NewLine + " | |\\/| |/ _ \\ '_ \\| | | | \\___ \\| | | / __| __/ _ \\ '_ ` _ \\" + + Environment.NewLine + " | | | | __/ | | | |_| | ____) | |_| \\__ \\ || __/ | | | | |" + + Environment.NewLine + " |_| |_|\\___|_| |_|\\__,_| |_____/ \\__, |___/\\__\\___|_| |_| |_|" + + Environment.NewLine + " __/ | " + + Environment.NewLine + " |___/ "; + + +Console.Clear(); + +// Setup the menu +Menu mainMenu = new (); + +Menu subMenu1 = new ("==>"); +subMenu1.SubTitle = "---------------- Secret Menu -----------------"; +subMenu1.AddMenuItem("backToMain", subMenu1.Back); +subMenu1.ParentMenu = mainMenu; + +mainMenu.Header = headerText; +subMenu1.Header = mainMenu.Header; + +mainMenu.SubTitle = "-------------------- Menu ----------------------"; +mainMenu.AddMenuItem("Hello World!", HelloWorld); +mainMenu.AddMenuItem("Secret Menu", subMenu1.ShowMenu); +mainMenu.AddMenuItem("Exit", Exit); +// Display the menu +mainMenu.ShowMenu(); + + +static void Exit() +{ + Environment.Exit(0); +} + +static void HelloWorld() +{ + Console.WriteLine("Hello World!"); + Console.ReadKey(true); +} \ No newline at end of file diff --git a/Sample/Sample.csproj b/Sample/Sample.csproj new file mode 100644 index 0000000..52c6cbc --- /dev/null +++ b/Sample/Sample.csproj @@ -0,0 +1,14 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + diff --git a/SimpleCMenu.sln b/SimpleCMenu.sln index 0f8441b..1d4ebab 100644 --- a/SimpleCMenu.sln +++ b/SimpleCMenu.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCMenu", "SimpleCMenu\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleConsoleMenu", "SimpleConsoleMenu\SimpleConsoleMenu.csproj", "{61FB74BD-D547-4B8E-BB15-C409F74DE782}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "Sample\Sample.csproj", "{E687D971-7479-4F51-9C1E-FF6ED063B2DE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {61FB74BD-D547-4B8E-BB15-C409F74DE782}.Debug|Any CPU.Build.0 = Debug|Any CPU {61FB74BD-D547-4B8E-BB15-C409F74DE782}.Release|Any CPU.ActiveCfg = Release|Any CPU {61FB74BD-D547-4B8E-BB15-C409F74DE782}.Release|Any CPU.Build.0 = Release|Any CPU + {E687D971-7479-4F51-9C1E-FF6ED063B2DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E687D971-7479-4F51-9C1E-FF6ED063B2DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E687D971-7479-4F51-9C1E-FF6ED063B2DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E687D971-7479-4F51-9C1E-FF6ED063B2DE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 5c0abbb2705f818be84b5a30a5a86dc3ef6a827e Mon Sep 17 00:00:00 2001 From: Tarxos Date: Sun, 28 Aug 2022 16:46:47 +0300 Subject: [PATCH 3/4] remove old netframewrok project --- SimpleCMenu.sln | 6 - SimpleCMenu/App.config | 6 - SimpleCMenu/Menu/ConsoleMenu.cs | 188 ------------------------- SimpleCMenu/Menu/MenuItem.cs | 31 ---- SimpleCMenu/Program.cs | 55 -------- SimpleCMenu/Properties/AssemblyInfo.cs | 36 ----- SimpleCMenu/SimpleCMenu.csproj | 62 -------- 7 files changed, 384 deletions(-) delete mode 100644 SimpleCMenu/App.config delete mode 100644 SimpleCMenu/Menu/ConsoleMenu.cs delete mode 100644 SimpleCMenu/Menu/MenuItem.cs delete mode 100644 SimpleCMenu/Program.cs delete mode 100644 SimpleCMenu/Properties/AssemblyInfo.cs delete mode 100644 SimpleCMenu/SimpleCMenu.csproj diff --git a/SimpleCMenu.sln b/SimpleCMenu.sln index 1d4ebab..edc2d46 100644 --- a/SimpleCMenu.sln +++ b/SimpleCMenu.sln @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32819.101 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCMenu", "SimpleCMenu\SimpleCMenu.csproj", "{15368273-1C43-4939-977F-0C198643CF42}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleConsoleMenu", "SimpleConsoleMenu\SimpleConsoleMenu.csproj", "{61FB74BD-D547-4B8E-BB15-C409F74DE782}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "Sample\Sample.csproj", "{E687D971-7479-4F51-9C1E-FF6ED063B2DE}" @@ -15,10 +13,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {15368273-1C43-4939-977F-0C198643CF42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {15368273-1C43-4939-977F-0C198643CF42}.Debug|Any CPU.Build.0 = Debug|Any CPU - {15368273-1C43-4939-977F-0C198643CF42}.Release|Any CPU.ActiveCfg = Release|Any CPU - {15368273-1C43-4939-977F-0C198643CF42}.Release|Any CPU.Build.0 = Release|Any CPU {61FB74BD-D547-4B8E-BB15-C409F74DE782}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {61FB74BD-D547-4B8E-BB15-C409F74DE782}.Debug|Any CPU.Build.0 = Debug|Any CPU {61FB74BD-D547-4B8E-BB15-C409F74DE782}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/SimpleCMenu/App.config b/SimpleCMenu/App.config deleted file mode 100644 index 88fa402..0000000 --- a/SimpleCMenu/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/SimpleCMenu/Menu/ConsoleMenu.cs b/SimpleCMenu/Menu/ConsoleMenu.cs deleted file mode 100644 index 0859483..0000000 --- a/SimpleCMenu/Menu/ConsoleMenu.cs +++ /dev/null @@ -1,188 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace SimpleCMenu.Menu -{ - public class ConsoleMenu - { - #region Public var - - public ConsoleMenu ParentMenu { get; set; } - - public string Header { get; set; } - public string SubTitle { get; set; } - public string CursorText { get; set; } - public ConsoleColor CursorColor { get; set; } - public ConsoleColor HeaderColor { get; set; } - public ConsoleColor ForeColor { get; set; } - public ConsoleColor MenuItemColor { get; set; } - public ConsoleColor SubTitleColor { get; set; } - - #endregion - - #region Private var - - private List menuItemList; - - private int cursor; - private bool exit; - - #endregion - - #region Constructor - - public ConsoleMenu(string cursorText = "->") - { - menuItemList = new List(); - cursor = 0; - - this.CursorText = cursorText; - CursorColor = ConsoleColor.Yellow; - HeaderColor = ConsoleColor.Blue; - ForeColor = ConsoleColor.White; - MenuItemColor = ConsoleColor.White; - SubTitleColor = ConsoleColor.White; - } - - #endregion - - #region Public methods - - public bool addMenuItem(int id, string text, Action action) - { - // check if it dosen't already exists - if (!menuItemList.Any(item => item.ID == id)) - { - menuItemList.Add(new MenuItem(id, text, action)); - return true; - } - return false; - } - - public bool removeMenuItem(int id) - { - throw new NotImplementedException(); - } - - #endregion - - #region Public Virtual methods - - public virtual void drawHeader() - { - Console.ForegroundColor = HeaderColor; - Console.WriteLine(Header); - Console.ForegroundColor = ForeColor; - } - - public virtual void drawWithHeader() - { - drawHeader(); - draw(); - } - - public virtual void draw() - { - Console.WriteLine(SubTitle); - - for (int i = 0; i < menuItemList.Count; i++) - { - if (i == cursor) - { - Console.ForegroundColor = CursorColor; - Console.Write(CursorText + " "); - Console.WriteLine(menuItemList[i].Text); - Console.ForegroundColor = ForeColor; - } - else - { - Console.Write(new string(' ', (CursorText.Length + 1))); - Console.WriteLine(menuItemList[i].Text); - } - } - } - - public virtual void clear() - { - Console.Clear(); - } - - public virtual void clearWithoutHeader() - { - Console.Clear(); - drawHeader(); - } - - public virtual void showMenu() - { - Console.CursorVisible = false; - Console.Clear(); - drawWithHeader(); - exit = false; - while (!exit) - { - updateMenu(); - } - } - - public virtual void hideMenu() - { - exit = true; - } - - public virtual void updateMenu() - { - switch (Console.ReadKey(true).Key) - { - case ConsoleKey.UpArrow: - { - if (cursor > 0) - { - cursor--; - Console.Clear(); - drawWithHeader(); - } - } - break; - case ConsoleKey.DownArrow: - { - if (cursor < (menuItemList.Count - 1)) - { - cursor++; - Console.Clear(); - drawWithHeader(); - } - } - break; - case ConsoleKey.Escape: - { - if (ParentMenu != null) - { - - hideMenu(); - } - } - break; - case ConsoleKey.Enter: - { - Console.Clear(); - drawHeader(); - Console.CursorVisible = true; - menuItemList[cursor].Action(); - Console.CursorVisible = false; - Console.Clear(); - drawWithHeader(); - } - break; - default: - { - // Unsuported key. Do nothing.... - } - break; - } - } - - #endregion - } -} diff --git a/SimpleCMenu/Menu/MenuItem.cs b/SimpleCMenu/Menu/MenuItem.cs deleted file mode 100644 index 374f8ad..0000000 --- a/SimpleCMenu/Menu/MenuItem.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -namespace SimpleCMenu.Menu -{ - public class MenuItem - { - #region Properties - - public int ID { get; set; } - public string Text { get; set; } - public Action Action { get; set; } - - #endregion - - #region Constructors - - public MenuItem() - { - - } - - public MenuItem(int id, string text, Action action) - { - this.ID = id; - this.Text = text; - this.Action = action; - } - - #endregion - } -} diff --git a/SimpleCMenu/Program.cs b/SimpleCMenu/Program.cs deleted file mode 100644 index a57d481..0000000 --- a/SimpleCMenu/Program.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; - -using SimpleCMenu.Menu; - -namespace SimpleCMenu -{ - class Program - { - static void Main(string[] args) - { - string headerText = " __ __ _____ _ " + - Environment.NewLine + " | \\/ | / ____| | | " + - Environment.NewLine + " | \\ / | ___ _ __ _ _ | (___ _ _ ___| |_ ___ _ __ ___" + - Environment.NewLine + " | |\\/| |/ _ \\ '_ \\| | | | \\___ \\| | | / __| __/ _ \\ '_ ` _ \\" + - Environment.NewLine + " | | | | __/ | | | |_| | ____) | |_| \\__ \\ || __/ | | | | |" + - Environment.NewLine + " |_| |_|\\___|_| |_|\\__,_| |_____/ \\__, |___/\\__\\___|_| |_| |_|" + - Environment.NewLine + " __/ | " + - Environment.NewLine + " |___/ "; - - - Console.Clear(); - - // Setup the menu - ConsoleMenu mainMenu = new ConsoleMenu(); - - ConsoleMenu subMenu1 = new ConsoleMenu("==>"); - subMenu1.SubTitle = "---------------- Secret Menu -----------------"; - subMenu1.addMenuItem(0, "backToMain", subMenu1.hideMenu); - subMenu1.ParentMenu = mainMenu; - - mainMenu.Header = headerText; - subMenu1.Header = mainMenu.Header; - - mainMenu.SubTitle = "-------------------- Menu ----------------------"; - mainMenu.addMenuItem(0, "Hello World!", HelloWorld); - mainMenu.addMenuItem(1, "Secret Menu", subMenu1.showMenu); - mainMenu.addMenuItem(2, "Exit", Exit); - // Display the menu - mainMenu.showMenu(); - - } - - - public static void Exit() - { - Environment.Exit(0); - } - - public static void HelloWorld() - { - Console.WriteLine("Hello World!"); - Console.ReadKey(true); - } - } -} diff --git a/SimpleCMenu/Properties/AssemblyInfo.cs b/SimpleCMenu/Properties/AssemblyInfo.cs deleted file mode 100644 index 2625288..0000000 --- a/SimpleCMenu/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SimpleCMenu")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Premier Tech Ltd")] -[assembly: AssemblyProduct("SimpleCMenu")] -[assembly: AssemblyCopyright("Copyright © Premier Tech Ltd 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("15368273-1c43-4939-977f-0c198643cf42")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SimpleCMenu/SimpleCMenu.csproj b/SimpleCMenu/SimpleCMenu.csproj deleted file mode 100644 index a976821..0000000 --- a/SimpleCMenu/SimpleCMenu.csproj +++ /dev/null @@ -1,62 +0,0 @@ - - - - - Debug - AnyCPU - {15368273-1C43-4939-977F-0C198643CF42} - Exe - Properties - SimpleCMenu - SimpleCMenu - v4.5.2 - 512 - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From cafaf57380ec9a6d79e7c8389186cf3908d8322a Mon Sep 17 00:00:00 2001 From: Tarxos Date: Sun, 28 Aug 2022 16:48:00 +0300 Subject: [PATCH 4/4] update readme --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index cc3824d..5117b0a 100644 --- a/README.md +++ b/README.md @@ -8,18 +8,18 @@ a simple and customisable c# console menu system // Setup the menu ConsoleMenu mainMenu = new ConsoleMenu(); -ConsoleMenu subMenu1 = new ConsoleMenu("==>"); +Menu subMenu1 = new ("==>"); subMenu1.SubTitle = "---------------- Secret Menu -----------------"; -subMenu1.addMenuItem(0, "backToMain", subMenu1.hideMenu); +subMenu1.AddMenuItem("backToMain", subMenu1.Back); subMenu1.ParentMenu = mainMenu; mainMenu.Header = headerText; subMenu1.Header = mainMenu.Header; mainMenu.SubTitle = "-------------------- Menu ----------------------"; -mainMenu.addMenuItem(0, "Hello World!", HelloWorld); -mainMenu.addMenuItem(1, "Secret Menu", subMenu1.showMenu); -mainMenu.addMenuItem(2, "Exit", Exit); +mainMenu.AddMenuItem("Hello World!", HelloWorld); +mainMenu.AddMenuItem("Secret Menu", subMenu1.ShowMenu); +mainMenu.AddMenuItem("Exit", Exit); // Display the menu -mainMenu.showMenu(); +mainMenu.ShowMenu(); ```