Beispiel #1
0
        /// <summary>
        /// This method traverses the menu structure and executes the shortcut option.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="shortcut">The shortcut id.</param>
        protected void ShortcutInvoke(ConsoleMenuContext context, string shortcut)
        {
            if (context == null || string.IsNullOrEmpty(shortcut))
            {
                return;
            }

            context.Options?.ForEach((o) => ShortcutInvoke(o, shortcut));
        }
Beispiel #2
0
        /// <summary>
        /// This is the main constructor for the menu.
        /// </summary>
        /// <param name="title">The page title.</param>
        /// <param name="options">The child options for the menu.</param>
        public ConsoleMenu(
            string title
            , params ConsoleOption[] options
            )
        {
            Context     = new ConsoleMenuContext(options);
            ContextInfo = new ConsoleInfoContext();

            Context.Title        = title;
            Context.ConsoleTitle = title;
            Context.Subtitle     = "Please select from the following options";

            Context.EscapeText    = "Press escape to exit";
            Context.EscapeWrapper = true;

            Context.Indent1 = 3;
            Context.Indent2 = 6;

            CustomInfo = new Dictionary <string, ConsoleInfoContext>();
        }