/// <summary> /// if we have any menu items with menu keys that differ only by case, then this is a case sensitive menu, otherwise the menu items will be case insensitive. /// </summary> public Menu(IConsole menuConsole, string title, ConsoleKey quit, int width, params MenuItem[] menuActions) { lock (_locker) { CaseSensitive = CaseForMenuItems(menuActions) == Case.Sensitive; Title = title; Keyboard = Keyboard ?? new Keyboard(); _menuConsole = menuConsole; QuitKey = quit.ToKeypress(); _width = width; NumMenus = menuActions.Length; for (int i = 0; i < menuActions.Length; i++) { var item = menuActions[i]; var key = item.Key; if (key.HasValue) { _keyBindings.Add(key.Value, i); } _menuItems.Add(i, item); } if (menuActions == null || menuActions.Length == 0) { throw new ArgumentOutOfRangeException(nameof(menuActions), "Must provide at least one menu action"); } _height = menuActions.Length + 4; _window = Window.OpenInline(_menuConsole, 2, _width, _height, Theme.Foreground, Theme.Background, K.Clipping); } }