示例#1
0
        public void Update(ConsoleKeyInfo key)
        {
            switch (key.Key)
            {
            case ConsoleKey.UpArrow:
            case ConsoleKey.DownArrow:
                if (Modal == null)
                {
                    FocusedPanel.Update(key);
                }
                else
                {
                    Modal.ListView.Update(key);
                    Modal.ListView.Render();
                }
                break;

            case ConsoleKey.Enter:
                if (Modal == null)
                {
                    goto default;
                }
                else
                {
                    FileSystemInfo fileSystemInfo = Modal.ListView.SelectedItem.Item;

                    if (fileSystemInfo is FileInfo file)
                    {
                        Process.Start(file.FullName);
                        FocusedPanel.Current = new DirectoryInfo(Path.GetPathRoot(fileSystemInfo.FullName));
                    }
                    else
                    {
                        FocusedPanel.Current = new DirectoryInfo(fileSystemInfo.FullName);
                    }

                    Modal = null;
                    RefreshScreen();
                }
                break;

            case ConsoleKey.Escape:
                if (Modal != null)
                {
                    Modal = null;
                    RefreshScreen();
                }
                break;

            default:
                ActionPerformerArgs args = new ActionPerformerArgs(key, this);
                ActionPerformer = ActionPerformer.GetActionPerformer(args);
                ActionPerformer.Do(args);
                break;
            }
        }