Exemple #1
0
        public static void CopySelection(string item, bool moveDown)
        {
            if (!selectionRegister.Contains(item))
            {
                selectionRegister.Add(item);
                ConsoleDisplay.RedrawSelectedFile();
                //move down if possible
                if (State.cursorPosY < ConsoleDisplay.files.Length - 1 && moveDown)
                {
                    State.cursorPosY++;
                    ConsoleDisplay.MoveDown();
                }

                Console.SetCursorPosition(0, Console.WindowTop);
                Console.Write("Added ");
                Console.ForegroundColor = ConsoleColor.Black; Console.BackgroundColor = ConsoleColor.Gray;
                Console.Write(Path.GetFileName(item));
                Console.ResetColor();
                Console.Write(" to Selection.");
            }
        }
Exemple #2
0
        public void StartReading()
        {
            ConsoleKeyInfo consoleKeyInfo;

            do
            {
                //maybe this is a fix? It works so far leave it for a bit
                //string[] directoryArray = CombineArrays( ConsoleDisplay.currentPath );
                string[] directoryArray = ConsoleDisplay.currentChunkFiles;

                if (!directoryArray.IsEmpty())
                {
                    State.selectedFile = directoryArray[State.cursorPosY];
                }

                //Read key to change cursor

                consoleKeyInfo = Console.ReadKey(true);
                switch (consoleKeyInfo.Key)
                {
                case ConsoleKey.UpArrow:
                    ConsoleDisplay.MoveUp();
                    ConsoleDisplay.Display();
                    break;

                case ConsoleKey.DownArrow:
                    ConsoleDisplay.MoveDown();
                    ConsoleDisplay.Display();
                    break;

                case ConsoleKey.RightArrow:
                {
                    //If it it's a folder allow press right key
                    FileAttributes attr = File.GetAttributes(State.selectedFile);

                    if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                    {
                        State.currentPath = State.selectedFile;
                        History.SetPointer();
                        ConsoleDisplay.Display();
                    }
                    else
                    {
                        AttemptOpenFile();
                    }
                }
                break;

                case ConsoleKey.LeftArrow:
                {
                    History.AddEntry();

                    //Set cursor to Parent folder
                    if (Directory.GetParent(State.currentPath) != null)
                    {
                        SetCursorToPreviousPosition();
                        State.currentPath = Directory.GetParent(State.currentPath).ToString();
                    }
                    ConsoleDisplay.Display();
                }
                break;
                }
                switch (consoleKeyInfo.KeyChar)
                {
                case 'k':
                    ConsoleDisplay.MoveUp();
                    break;

                case 'j':
                    ConsoleDisplay.MoveDown();
                    break;

                case 'l':
                {
                    //If it it's a folder allow press right key
                    FileAttributes attr = File.GetAttributes(State.selectedFile);

                    if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                    {
                        State.currentPath = State.selectedFile;
                        History.SetPointer();
                        ConsoleDisplay.Display();
                    }
                    else
                    {
                        AttemptOpenFile();
                    }
                }
                break;

                case 'h':
                {
                    History.AddEntry();
                    //Set cursor to Parent folder
                    if (Directory.GetParent(State.currentPath) != null)
                    {
                        SetCursorToPreviousPosition();
                        State.currentPath = Directory.GetParent(State.currentPath).ToString();
                    }
                    ConsoleDisplay.Display();
                }
                break;

                case '\t':
                {
                    Console.Clear();
                    Process          process   = new Process();
                    ProcessStartInfo startInfo = new ProcessStartInfo();
                    process.StartInfo          = startInfo;
                    startInfo.FileName         = "cmd";
                    startInfo.UseShellExecute  = true;
                    startInfo.WorkingDirectory = State.currentPath;
                    process.Start();
                    process.WaitForExit();
                    ConsoleDisplay.Display();
                }
                break;

                case ':':
                {
                    new InputBox().CommadMode();
                }
                break;

                case '/':
                {
                    new InputBox().SearchMode();
                }
                break;

                case '.':
                {
                    new InputBox().JumpToLetter();
                }
                break;

                case '\r':
                {
                    AttemptOpenFile();
                }
                break;

                case 'r':
                {
                    new InputBox().RenameFile();
                }
                break;

                case 's':
                {
                    new SelectionRegisterScreen();
                }
                break;

                case 'n':
                {
                    new InputBox().NewFile();
                }
                break;

                case 'N':
                {
                    new InputBox().NewFolder();
                }
                break;

                case 'd':
                {
                    if (State.selectedFile != State.currentPath)
                    {
                        State.isWatching = false;
                        Console.Clear();
                        new InputBox().DeleteFileWithPrompt(State.selectedFile);
                        Console.ReadKey(true);
                        State.isWatching = true;
                        ConsoleDisplay.Display();
                    }
                }
                break;

                case ' ':
                {
                    //Tools.SelectMultiple();
                    //or
                    //ConsoleDisplay.SelectMultpiple():
                }
                break;

                case 'q':
                {
                    Console.Clear();
                    File.WriteAllText(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar +
                                      "fileScoutDir", State.currentPath);
                    Environment.Exit(0);
                }
                break;

                case 'b':
                {
                    if (ConsoleDisplay.files.Length != 0)
                    {
                        State.cursorPosY = ConsoleDisplay.files.Length - 1;
                        ConsoleDisplay.Display();
                    }
                }
                break;

                case 't':
                {
                    State.cursorPosY = 0;
                    ConsoleDisplay.Display();
                }
                break;

                case 'i':
                {
                    new FileInfoScreen(State.selectedFile);
                }
                break;

                case 'y':
                {
                    if (Tools.selectionRegister.Contains(State.selectedFile))
                    {
                        Tools.RemoveFromSelectionRegister(State.selectedFile);
                        //move down if possible
                        if (State.cursorPosY < ConsoleDisplay.files.Length - 1)
                        {
                            State.cursorPosY++;
                            ConsoleDisplay.MoveDown();
                        }
                    }
                    else
                    {
                        Tools.CopySelection(State.selectedFile, true);
                    }
                }
                break;

                case 'Y':
                {
                    if (Tools.selectionRegister.Contains(State.currentPath))
                    {
                        Tools.RemoveFromSelectionRegister(State.currentPath);

                        Console.SetCursorPosition(0, Console.WindowTop);
                        Console.Write("Removed ");
                        Console.ForegroundColor = ConsoleColor.Black; Console.BackgroundColor = ConsoleColor.Gray;
                        Console.Write(Path.GetFileName(State.currentPath));
                        Console.ResetColor();
                        Console.Write(" from Selection.");
                    }
                    else
                    {
                        Tools.CopySelection(State.currentPath, false);
                    }
                }
                break;

                case 'p':
                {
                    Tools.PasteSelection();
                    ConsoleDisplay.Display();
                    Console.ReadKey(true);
                }
                break;

                case 'z':
                {
                    Tools.DebugWindow();
                }
                break;
                }
            }while (consoleKeyInfo.Key != ConsoleKey.Escape);
            Console.Clear();
            System.Environment.Exit(0);
        }