public bool Print(ConsoleMenu consoleMenu) { Console.Clear(); Console.WriteLine("Print"); Console.ReadKey(); return true; }
public bool MainMenu(ConsoleMenu consoleMenu) { for (int i = 0; i < consoleMenu.MenuItems.Count; i++) { consoleMenu.MenuItems[i].Visible = false; if ((1 == consoleMenu.MenuItems[i].Key.Length)) consoleMenu.MenuItems[i].Visible = true; } return true; }
public bool NextLevelMenu(ConsoleMenu consoleMenu) { string stringKey = string.Format("{0}.", consoleMenu.MenuItems[consoleMenu.SelectedIndex].Key); for (int i = 0; i < consoleMenu.MenuItems.Count; i++) { consoleMenu.MenuItems[i].Visible = false; if (consoleMenu.MenuItems[i].Key.Remove(consoleMenu.MenuItems[i].Key.Count() - 1) == stringKey) consoleMenu.MenuItems[i].Visible = true; } return true; }
public bool PrevLevelMenu(ConsoleMenu consoleMenu) { string thisActivString = consoleMenu.MenuItems[consoleMenu.SelectedIndex].Key; string stringKey = string.Format("{0}", consoleMenu.MenuItems[consoleMenu.SelectedIndex].Key.Remove(consoleMenu.MenuItems[consoleMenu.SelectedIndex].Key.Count() - 2)); for (int i = 0; i < consoleMenu.MenuItems.Count; i++) { consoleMenu.MenuItems[i].Visible = false; if ((stringKey.Length == consoleMenu.MenuItems[i].Key.Length) && (thisActivString[0] == consoleMenu.MenuItems[i].Key[0])) consoleMenu.MenuItems[i].Visible = true; } return true; }
static void Main(string[] args) { ConsoleMenu mainMenu = new ConsoleMenu( new ConsoleMenuItem[] { new ConsoleMenuItem() { Key = "1", Description = "Print hello world", Visible = true }, new ConsoleMenuItem() { Key = "2", Description = "Print goodbye world", Visible = true }, new ConsoleMenuItem() { Key = "3", Description = "Exit from menu", Visible = true } } ); mainMenu.NextMenuItemKey = ConsoleKey.DownArrow; mainMenu.PreviousMenuItemKey = ConsoleKey.UpArrow; mainMenu.SelectMenuItemKey = ConsoleKey.Enter; mainMenu.Display(); }
static public bool ArrayRepl(ConsoleMenu.ConsoleMenuItem[] arr) { for (int i = 0; i < arr.Length; i++) { for (int j = 0; j < arr.Length; j++) { if (i != j) { if (arr[i].Key == arr[j].Key) { return false; } } } } return true; }
static void Main(string[] args) { #region delegat /* FunctionHandlerWithTwoIntegerParametersThatReturnsVoid functionHandler; Calculator calc = new Calculator(); functionHandler = new FunctionHandlerWithTwoIntegerParametersThatReturnsVoid(calc.AddTwoIntegerParameters); functionHandler += calc.MultiplyWithTwoIntegerParameters; functionHandler += calc.SubstractWithTwoIntegerParameters; functionHandler += calc.DivideWithTwoIntegerParameters; functionHandler.Invoke(2, 3); functionHandler -= calc.SubstractWithTwoIntegerParameters; functionHandler.Invoke(2, 3); #endregion Console.WriteLine("What to do?"); Console.WriteLine("1. Add 2 and 3"); Console.WriteLine("2. Multiply 2 and 3"); ConsoleKeyInfo selected = Console.ReadKey(true); Calculator calc = new Calculator(); switch (selected.Key) { case ConsoleKey.NumPad1: functionHandler = new FunctionHandlerWithTwoIntegerParametersThatReturnsVoid(calc.AddTwoIntegerParameters); break; case ConsoleKey.NumPad2: functionHandler = new FunctionHandlerWithTwoIntegerParametersThatReturnsVoid(calc.MultiplyWithTwoIntegerParameters); break; default: functionHandler = new FunctionHandlerWithTwoIntegerParametersThatReturnsVoid(calc.MultiplyWithTwoIntegerParameters); break; } functionHandler.Invoke(2, 3); */ #endregion ConsoleMenu mainMenu = new ConsoleMenu( new ConsoleMenu.ConsoleMenuItem[] { new ConsoleMenu.ConsoleMenuItem() { Key = "1", Description = "Print hello world", Visible = true }, new ConsoleMenu.ConsoleMenuItem() { Key = "2", Description = "Print goodbye world", Visible = true }, new ConsoleMenu.ConsoleMenuItem() { Key = "3", Description = "Exit from menu", Visible = false }, new ConsoleMenu.ConsoleMenuItem() { Key = "4", Description = "Options", Visible = true } } ); mainMenu.NextMenuItemKey = ConsoleKey.DownArrow; mainMenu.PreviousMenuItemKey = ConsoleKey.UpArrow; mainMenu.SelectMenuItemKey = ConsoleKey.Enter; try { if (!OperatorArray.ArrayRepl(mainMenu.MenuItems)) throw new Exception("Одиковые ключи"); mainMenu.Display(); } catch (Exception e) { System.Console.WriteLine("Exception:{0}", e.Message); } }
public bool Exit(ConsoleMenu consoleMenu) { Console.Clear(); return false; }
public bool AddProduct(ConsoleMenu consoleMenu) { return true; }