コード例 #1
0
        private void ExecuteKeyboard(EventTranscriptionParameter <KeyEventArgs> parameter)
        {
            var args = parameter.EventArgs;

            parameter.EventArgs.Handled = true;

            if (parameter.EventArgs.KeyboardDevice.IsKeyDown(Key.LeftCtrl) && parameter.EventArgs.KeyboardDevice.IsKeyDown(Key.T))
            {
                AddNewDirectoryView();
            }
            else if (parameter.EventArgs.KeyboardDevice.IsKeyDown(Key.LeftCtrl) && parameter.EventArgs.KeyboardDevice.IsKeyDown(Key.W))
            {
                ExecuteCloseTab(ActiveView);
            }
            else if (args.KeyboardDevice.IsKeyDown(Key.LeftCtrl))
            {
                args.Handled = false;
            }
            else if (parameter.EventArgs.Key == Key.Enter && ActiveView.SelectedItem != null && ActiveView.SelectedItem.IsDirectory)
            {
                ActiveView.LoadSelectedDirectory();
            }
            else if (parameter.EventArgs.Key == Key.Enter && ActiveView.SelectedItem != null && ActiveView.SelectedItem.IsMoveUp && !PathExt.IsDriveRoot(ActiveView.FullPath))
            {
                ActiveView.MoveUp();
            }
            else if (parameter.EventArgs.Key == Key.Back && ActiveView.SearchText.IsNotNullAndNotEmpty())
            {
                ActiveView.SearchText = ActiveView.SearchText.Remove(ActiveView.SearchText.Length - 1);
            }
            else if (parameter.EventArgs.Key == Key.Back && !PathExt.IsDriveRoot(ActiveView.FullPath))
            {
                ActiveView.MoveUp();
            }
            else if (parameter.EventArgs.Key == Key.Enter && ActiveView.IsOneFileSelected)
            {
                ActiveView.ExecuteFile(ActiveView.SelectedItem);
            }
            else
            {
                char keyID = Utility.ConvertKeyToChar(parameter.EventArgs.Key);
                if (keyID != char.MinValue)
                {
                    if (char.IsLetterOrDigit(keyID))
                    {
                        ActiveView.SearchText = ActiveView.SearchText + keyID.ToString();
                    }
                    else if (parameter.EventArgs.Key == Key.Space)//TODO: Handle space
                    {
                        ActiveView.SearchText = ActiveView.SearchText + " ";
                    }
                }
                else
                {
                    parameter.EventArgs.Handled = false;
                }
            }
        }