예제 #1
0
 public void HandleInput(ConsoleKeyInfo input)
 {
     if (m_traverser.Handles(input))
     {
         m_traverser.Handle(input);
     }
     else if (input.Key == ConsoleKey.Enter)
     {
         Viewer.Pop();
         var action = m_actions[m_traverser.Current];
         action.Action();
         LogService.Log($"Ran action {action.Title} on {m_title}.");
     }
     else if (input.Key == ConsoleKey.Escape || input.Key == ConsoleKey.Backspace)
     {
         Viewer.Pop();
     }
 }
예제 #2
0
        public void HandleInput(ConsoleKeyInfo input)
        {
            if (m_traverser.Handles(input))
            {
                m_traverser.Handle(input);
            }
            else if (m_textHandler.Handles(input))
            {
                m_textHandler.Handle(input);
                UpdateCurrentItems();
            }
            else if (input.Key == ConsoleKey.Escape)
            {
                m_textHandler.Clear();
                UpdateCurrentItems();
                LogService.Clear();
            }
            else if (input.Key == ConsoleKey.Tab)
            {
                LogService.Clear();
                Program.Reset();
            }
            else if (input.Key == ConsoleKey.Enter && m_currentItems.Count > 0)
            {
                var item    = m_currentItems[m_traverser.Current];
                var actions = m_currentItems[m_traverser.Current].ActionsFactory();
                if (actions.Length == 1)
                {
                    actions[0].Action();
                }
                else
                {
                    Viewer.Push(new ActionSelectionViewModel(item, actions));
                }

                m_textHandler.Clear();
                UpdateCurrentItems();
            }
        }
예제 #3
0
 public void HandleInput(ConsoleKeyInfo input)
 {
     if (m_traverser.Handles(input))
     {
         m_traverser.Handle(input);
     }
     else if (m_textHandler.Handles(input))
     {
         m_textHandler.Handle(input);
         UpdateCurrentItems();
     }
     else if (input.Key == ConsoleKey.Escape)
     {
         m_textHandler.Clear();
         UpdateCurrentItems();
     }
     else if (input.Key == ConsoleKey.Enter)
     {
         Viewer.Push(new ActionSelectionViewModel(m_currentItems[m_traverser.Current]));
         UpdateCurrentItems();
     }
 }
예제 #4
0
 public void HandleInput(ConsoleKeyInfo input)
 {
     if (m_traverser.Handles(input))
     {
         m_traverser.Handle(input);
     }
     else if (input.Key == ConsoleKey.Enter)
     {
         SelectAction(m_traverser.Current);
     }
     else if (input.Key == ConsoleKey.Escape || input.Key == ConsoleKey.Backspace)
     {
         Viewer.Pop();
     }
     else if (char.IsLetterOrDigit(input.KeyChar))
     {
         var hasMatch = m_actionMapping.TryGetValue(input.KeyChar, out var action);
         if (hasMatch)
         {
             SelectAction(action);
         }
     }
 }
예제 #5
0
 public void HandleInput(ConsoleKeyInfo input)
 {
     if (m_traverser.Handles(input))
     {
         m_traverser.Handle(input);
     }
     else if (input.Key == ConsoleKey.Enter)
     {
         SelectAction(m_traverser.Current);
     }
     else if (input.Key == ConsoleKey.Escape || input.Key == ConsoleKey.Backspace)
     {
         Viewer.Pop();
     }
     else if (char.IsNumber(input.KeyChar))
     {
         var isNumber = int.TryParse(input.KeyChar + "", out var index);
         if (!isNumber || index > m_actions.Length || index <= 0)
         {
             return;
         }
         SelectAction(index - 1);
     }
 }