protected virtual void OnChosen()
 {
     if (Chosen != null)
     {
         Chosen.Invoke();
     }
 }
Esempio n. 2
0
        private void HandleInput(IMenuItemInfo[] options, ref int selected)
        {
            var key = Console.ReadKey(true).Key;

            switch (key)
            {
            case ConsoleKey.UpArrow:
                if (selected <= 0)
                {
                    selected = options.GetUpperBound(0);
                }
                else
                {
                    selected--;
                }
                break;

            case ConsoleKey.DownArrow:
                if (selected >= options.GetUpperBound(0))
                {
                    selected = 0;
                }
                else
                {
                    selected++;
                }
                break;

            case ConsoleKey.Backspace:
            case ConsoleKey.Escape:
                Back?.Invoke(this, EventArgs.Empty);
                selected = -1;
                break;

            case ConsoleKey.Enter:
                Chosen?.Invoke(this, new MenuItemInfoEventArgs(options[selected]));
                selected = -1;
                break;
            }
        }
Esempio n. 3
0
 protected virtual void OnChosen(MenuItem i_MenuItem)
 {
     Chosen?.Invoke(i_MenuItem);
 }
 private EventHandler InitializeButtonClickHandler(string choice)
 => (sender, args) => Chosen?.Invoke(null, choice);
Esempio n. 5
0
 internal void OnChosen()
 {
     Chosen?.Invoke(this);
 }