public object Display() { textMenu.CursorPositionChanged = OnCursorPositionChanged; textMenu.Display(); if (IsExitVisible && textMenu.SelectedItem.Id == itemCount.ToString()) { IsExitSelected = true; } return(new ConsoleOptionsPageResult { SelectedIndex = textMenu.SelectedIndex.Value, SelectedText = textMenu.SelectedItem.Text }); }
private static void RunDemos() { bool exitWasRequested = false; TextMenu textMenu = new TextMenu(); textMenu.AddItems(new[] { new TextMenuItem { Id = "1", Text = "Default", Command = new DefaultCommand() }, new TextMenuItem { Id = "2", Text = "Custom Unlock Key", Command = new CustomUnlockKeyCommand() }, new TextMenuItem { Id = "3", Text = "Erasable Pause", Command = new ErasablePauseCommand() }, new TextMenuItem { Id = "4", Text = "Custom Margins", Command = new CustomMarginsCommand() }, new TextMenuItem { Id = "5", Text = "Custom Paddings", Command = new CustomPaddingsCommand() }, new TextMenuItem { Id = "6", Text = "Foreground Color", Command = new ForegroundColorCommand() }, new TextMenuItem { Id = "7", Text = "Background Color", Command = new BackgroundColorCommand() }, new TextMenuItem { Id = "0", Text = "Exit", Command = new ActionCommand(() => { exitWasRequested = true; }) } }); while (!exitWasRequested) { textMenu.Display(); } }