Exemplo n.º 1
0
        private void OnInputKeyUp(object sender, KeyEventArgs e)
        {
            var hasCtrl = e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control);

            if (e.Key == Key.Enter)
            {
                if (hasCtrl)
                {
                    ViewModel.OnContinuation();
                }
                else
                {
                    ViewModel.OnSubmit();
                }

                ViewModel.ResetHistoryCycle();
            }

            if (hasCtrl && e.Key == Key.R)
            {
                ViewModel.SendLast();
            }

            if (hasCtrl && e.Key == Key.D)
            {
                ViewModel.AddFavouritesCommand.Execute(null);
            }

            if (hasCtrl && e.Key == Key.Z)
            {
                ViewModel.Send(Char.ToString((char)26), "Ctrl + Z");
                return;
            }

            if (hasCtrl && e.Key == Key.E)
            {
                ViewModel.Send(Char.ToString((char)27), "Ctrl + Esc");
                return;
            }

            if (e.Key == Key.Escape)
            {
                ViewModel.ClearText();
            }


            if (!CommandInput.IsDropDownOpen && !hasCtrl && (e.Key == Key.Up || e.Key == Key.Down))
            {
                ViewModel.CycleHistory(e.Key == Key.Up);
                CommandInput.CursorToEnd();
            }

            if (hasCtrl && e.Key == Key.Up)
            {
                var index = LogView.SelectedIndex == -1 ? LogView.Items.Count - 1 : LogView.SelectedIndex;
                LogView.SelectedItem = ViewModel.Log[index];
                var item = LogView.ItemContainerGenerator.ContainerFromIndex(index) as ListViewItem;
                item?.Focus();
            }
        }
Exemplo n.º 2
0
        private void OnInputKeyDown(object sender, KeyEventArgs e)
        {
            var hasCtrl = e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control);

            if (e.Key == Key.Tab)
            {
                ViewModel.AutoCompleteText();
                CommandInput.CursorToEnd();
                e.Handled = true;
            }
        }