示例#1
0
 protected override void Run()
 {
     try
     {
         if (GraphicsSubsystemUtil.IsGraphicsSubsystemRunning)
         {
             GraphicsSubsystemUtil.Redraw();
         }
         else
         {
             cmd = Console.ReadLine().Split(' ');
             RunCommand(cmd);
         }
     }
     catch (Exception e)
     {
         mDebugger.Send("Exception occurred: " + e.Message);
         mDebugger.Send(e.Message);
         Stop();
     }
 }
示例#2
0
        public void RunCommand(string[] cmd)
        {
            FileSystemUtils.CheckForFileinsertOperator(cmd, out bool containsWriteOp);

            if (containsWriteOp)
            {
                return;
            }

            switch (cmd[0])
            {
            case "ls":
            case "dir":
                FileSystemUtils.Dir(currentPath, cmd);
                break;

            case "cat":
                FileSystemUtils.Cat(cmd[1]);
                break;

            case "touch":
                FileSystemUtils.Touch(cmd[1]);
                break;

            case "mkdir":
                FileSystemUtils.Mkdir(cmd[1]);
                break;

            case "help":
                for (int i = 0; i < supportedCommands.Length; i++)
                {
                    Console.Write($"{supportedCommands[i]}\t");
                }
                Console.Write('\n');
                break;

            case "exit":
                EnvironmentUtils.Exit();
                break;

            case "startx":
                Console.WriteLine("Are you sure you want to change to graphical mode? (Y/N)");
                string isSure = Console.ReadLine();
                if (isSure.ToUpper() != "Y")
                {
                    return;
                }
                Console.WriteLine("For cursor mode press 1, for shape mode press 2");
                string choice = Console.ReadLine();
                switch (choice)
                {
                case "1":
                    GraphicsSubsystemUtil.StartGraphicalMode(System.Drawing.Color.Wheat);
                    GraphicsSubsystemUtil.EnableCursor();
                    break;

                case "2":
                    GraphicsSubsystemUtil.StartGraphicalMode(System.Drawing.Color.Wheat);
                    break;

                default:
                    Console.WriteLine("Invalid choice. :/\nBack to console mode. ");
                    break;
                }
                break;

            default:
                if (cmd[0] != "")
                {
                    Console.WriteLine("Command not recognized");
                }
                break;
            }
        }