Beispiel #1
0
        protected override void Run()
        {
            //code for the command line
            if (RealH == "true")
            {
                Console.Write("Limited Mode> ");
            }
            else
            {
                Console.Write(username + "| " + current_directory + "> ");
            }
            var input = Console.ReadLine().ToLower();

            shell = input;
            //misc commands
            if (input.StartsWith("echo "))
            {
                var text = Kernel.shell.Substring(5);

                Console.WriteLine(text);
            }

            else if (input == "cls")
            {
                Console.Clear();
            }



            //info amd help
            else if (input == "cmd")
            {
                //lists all commands
                if (RealH == "false")
                {
                    Console.WriteLine("");
                    Console.BackgroundColor = ConsoleColor.Gray;
                    Console.ForegroundColor = ConsoleColor.Black;
                    Console.WriteLine("|List of Commands/Apps on Limited Mode|");
                    Bcolor();
                    Console.WriteLine("");

                    Console.WriteLine("Info/help Commands:");
                    Bcolor();
                    Console.WriteLine(" cmd - Shows all commands");
                    Console.WriteLine(" about - about the Operating System");
                    Console.WriteLine(" new - New Features in Build");

                    Console.WriteLine("Misc Commands:");
                    Bcolor();
                    Console.WriteLine(" cls - Clears the screen");
                    Console.WriteLine(" echo - Repeats Text Given");

                    Console.WriteLine("Programs:");
                    Bcolor();
                    Console.WriteLine(" time - tells the time");
                    Console.WriteLine(" piano - Piano Program");
                    Console.WriteLine(" calc - Simple calculator");

                    Console.WriteLine("Games:");
                    Bcolor();
                    Console.WriteLine(" numguess - A Number Guessing Game");
                    Console.WriteLine(" snake - A Classic Game of Snake");

                    Console.WriteLine("Power Commands:");
                    Bcolor();
                    Console.WriteLine(" shutdown - Powers off your computer");
                    Console.WriteLine(" restart - Restarts your computer");
                    Console.WriteLine("");
                }
                else
                {
                    Console.WriteLine("");
                    Console.BackgroundColor = ConsoleColor.Gray;
                    Console.ForegroundColor = ConsoleColor.Black;
                    Console.WriteLine("|List of Commands/Apps|");
                    Bcolor();
                    Console.WriteLine("");

                    Console.WriteLine("Info/help Commands:");
                    Bcolor();
                    Console.WriteLine(" cmd - Shows all commands");
                    Console.WriteLine(" about - about the Operating System");
                    Console.WriteLine(" new - New Features in Build");

                    Console.WriteLine("Misc Commands:");
                    Bcolor();
                    Console.WriteLine(" cls - Clears the screen");
                    Console.WriteLine(" echo - Repeats Text Given");

                    Console.WriteLine("File System:");
                    Bcolor();
                    Console.WriteLine(" drive - Displays drive info");
                    Console.WriteLine(" dir - displays all files and sub-dirs in directory");
                    Console.WriteLine(" mkdir - Makes a Directory");
                    Console.WriteLine(" rmdir - Removes a Directory");
                    Console.WriteLine(" cd - Changes current directory");
                    Console.WriteLine(" type - Quickly Types out file content (use MIV to view files)");
                    Console.WriteLine(" del - deletes specified file");
                    Console.WriteLine(" copy - copies a file to the location given");
                    Console.WriteLine(" move - moves a file to the location given");
                    Console.WriteLine(" format - Formats the drive");
                    Console.WriteLine("Press any key to Continue...");
                    Console.ReadKey();

                    Console.WriteLine("Programs:");
                    Bcolor();
                    Console.WriteLine(" time - tells the time");
                    Console.WriteLine(" piano - Piano Program");
                    Console.WriteLine(" mkcal - Creates a calender");
                    Console.WriteLine(" chkcal - checks for a calender");
                    Console.WriteLine(" calc - Simple calculator");
                    Console.WriteLine(" MIV - Text Editor");

                    Console.WriteLine("Games:");
                    Bcolor();
                    Console.WriteLine(" numguess - A Number Guessing Game");
                    Console.WriteLine(" snake - A Classic Game of Snake");

                    Console.WriteLine("Power Commands:");
                    Bcolor();
                    Console.WriteLine(" shutdown - Powers off your computer");
                    Console.WriteLine(" restart - Restarts your computer");
                    Console.WriteLine("");
                }
            }

            else if (input == "about")
            {
                //about the OS
                Console.BackgroundColor = ConsoleColor.Gray;
                Console.ForegroundColor = ConsoleColor.Black;
                Console.WriteLine("PC Info:");
                Bcolor();
                Console.WriteLine("Ram:" + Cosmos.Core.CPU.GetAmountOfRAM() + "MB");

                Console.BackgroundColor = ConsoleColor.Gray;
                Console.ForegroundColor = ConsoleColor.Black;
                Console.WriteLine("\nOS Info:");
                Bcolor();
                Console.WriteLine("Sia OS 1.2");
                Console.WriteLine("Built on 4/13/2021.");
                Console.WriteLine("Sia OS is Created by Evyn Vega.");
                Console.WriteLine("Cosmos belongs to the COSMOS Project.");
                //Console.WriteLine("Some code in the project is not mine and some are from the Cobalt and Aura \nProjects.");
            }

            else if (input == "new")
            {
                Console.BackgroundColor = ConsoleColor.Gray;
                Console.ForegroundColor = ConsoleColor.Black;
                Console.WriteLine("|Whats New in 1.2?|\n");
                Bcolor();
                Console.WriteLine("Features and Additions");
                Console.WriteLine("- Snake Game.");
                Console.WriteLine("- Dir command has switches /w(default) /l(list).");
                Console.WriteLine("- Piano 2.0 (More keys).");
                Console.WriteLine("- About command can now tell CPU info.");
                Console.WriteLine("Change Log:");
                Console.WriteLine("- Dir command defaults to the wide format.");
                Console.WriteLine("- Color Personalization Removed");
                Console.WriteLine("- You can now exit out and go into Limited mode at anytime at prompt");
            }

            //File System Commands
            else if (input.StartsWith("cd "))
            {
                if (RealH == "false")
                {
                    chngdir.cd();
                }
                else
                {
                    RH.RError();
                }
            }

            else if (input.StartsWith("mkdir "))
            {
                if (RealH == "false")
                {
                    mkd.mkdir();
                }
                else
                {
                    RH.RError();
                }
            }

            else if (input.StartsWith("rmdir "))
            {
                if (RealH == "false")
                {
                    rmd.rmdir();
                }
                else
                {
                    RH.RError();
                }
            }

            //dir regular. I am to lazy and too dumb to make it work into one thing.
            else if (input == "dir")
            {
                if (RealH == "false")
                {
                    Files.dir();
                }
                else
                {
                    RH.RError();
                }
            }
            //dir option
            else if (input.StartsWith("dir "))
            {
                if (RealH == "false")
                {
                    Files.diropt();
                }
                else
                {
                    RH.RError();
                }
            }

            else if (input == "drive")
            {
                if (RealH == "false")
                {
                    DRV.drives();
                }
                else
                {
                    RH.RError();
                }
            }

            else if (input == "miv")
            {
                if (RealH == "false")
                {
                    MIV.StartMIV();
                }
                else
                {
                    RH.RError();
                }
            }

            else if (input.StartsWith("type "))
            {
                if (RealH == "false")
                {
                    open.type();
                }
                else
                {
                    RH.RError();
                }
            }

            else if (input.StartsWith("del "))
            {
                if (RealH == "false")
                {
                    dl.del();
                }
                else
                {
                    RH.RError();
                }
            }

            else if (input.StartsWith("copy "))
            {
                if (RealH == "false")
                {
                    cpy.copy();
                }
                else
                {
                    RH.RError();
                }
            }

            else if (input.StartsWith("move "))
            {
                if (RealH == "false")
                {
                    mv.move();
                }
                else
                {
                    RH.RError();
                }
            }

            else if (input == "format")
            {
                if (RealH == "false")
                {
                    frm.format();
                }
                else
                {
                    RH.RError();
                }
            }

            // Misc Applications
            else if (input == "time")
            {
                if (time == "12hour")
                {
                    Console.WriteLine(DateTime.UtcNow);
                }
                else
                {
                    Console.WriteLine(DateTime.Now);
                }
            }

            else if (input == "mkcal")
            {
                Calender.mkcal();
            }

            else if (input == "chkcal")
            {
                if (RealH == "false")
                {
                    try
                    {
                        Console.Write("What day do you want to check for (Example: 1-1-2020): ");
                        var day = Console.ReadLine().ToLower();
                        if (File.Exists(day + ".cal"))
                        {
                            Console.BackgroundColor = ConsoleColor.Black;
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine("You have a Calender! Type 'open " + day + ".cal' to veiw it.");
                            Console.ResetColor();
                        }
                        else
                        {
                            Console.WriteLine("You have no calenders for that day");
                        }
                    }
                    catch (Exception Ex)
                    {
                        Console.WriteLine("Woah Sia OS just ran into a issue, here's some details.");
                        Console.WriteLine(Ex.ToString());
                    }
                }
                else
                {
                    RH.RError();
                }
            }

            else if (input == "piano")
            {
                Console.WriteLine("Cat Piano ver 1.0");
                Console.WriteLine("Press any key to continue");

                Piano.Pian();
            }

            else if (input == "calc")
            {
                Calculator.Calc();
            }

            else if (input == "setup")
            {
                if (RealH == "false")
                {
                    Setup.SetupStart();
                }
                else
                {
                    RH.RError();
                }
            }

            //Games (I stole lmao)
            else if (input == "numguess")
            {
                try
                {
                    Random random = new Random();

                    int returnValue = random.Next(1, 100);
                    int Guess       = 0;
                    int numGuesses  = 0;

                    Console.WriteLine("I am thinking of a number between 1-100.  Can you guess what it is?");

                    while (Guess != returnValue)
                    {
                        Guess = Convert.ToInt32(Console.Read());
                        string line = Console.ReadLine();   // Get string from user
                        if (!int.TryParse(line, out Guess)) // Try to parse the string as an integer
                        {
                            Console.WriteLine("Not an integer!");
                        }
                        else
                        {
                            numGuesses++;
                            if (Guess < returnValue)
                            {
                                Console.WriteLine("No, the number I am thinking of is higher than " + Guess + " .  Can you guess what it is?");
                            }
                            if (Guess > returnValue)
                            {
                                Console.WriteLine("No, the number I am thinking of is lower than " + Guess + " .  Can you guess what it is");
                            }
                        }
                    }
                    Console.WriteLine("Well done! The answer was " + returnValue + ".\nYou took " + numGuesses + " guesses.");
                }
                catch (Exception Ex)
                {
                    Console.WriteLine("Woah Sia OS just ran into a issue, here's some details.");
                    Console.WriteLine(Ex.ToString());
                }
            }

            else if (input == "snake")
            {
                SnakeGame.Init();
            }

            //Power
            else if (input == "shutdown")
            {
                int sec = 10;
                while (sec > 0)
                {
                    Console.WriteLine("Thank You for using Sia OS. Your computer will shutdown in  " + sec + " seconds, or press any key to shutdown now.");
                    sec--;
                    WaitSeconds(1);

                    if (System.Console.KeyAvailable == true)
                    {
                        Cosmos.System.Power.Shutdown();
                    }
                    else if (sec == 0)
                    {
                        Cosmos.System.Power.Shutdown();
                    }
                    Console.Clear();
                }
            }

            else if (input == "restart")
            {
                Sys.Power.Reboot();
            }

            //Limit mode stuff
            else if (input == "rhoff")
            {
                RealH = "false";

                Console.WriteLine("Real Hardware/Limited Mode Disabled");
            }

            else if (input == "rhon")
            {
                RealH = "true";
                Console.WriteLine("Real Hardware/Limited Mode enabled");
            }

            else if (input == "ison")
            {
                Console.WriteLine("Is in Real Harware/Limited Mode?: " + RealH);
            }

            //if a unknown command is typed then nothing because you deserve nothing because you are nothing to anyone.
            else
            {
            }
        }
Beispiel #2
0
 public static void mkcal()
 {
     if (Kernel.RealH == "false")
     {
         try
         {
             Console.Write("What day is this for? (Example: 1-1-2020): ");
             var    finput  = Console.ReadLine().ToLower();
             string calName = finput + ".cal";
             var    dir     = Directory.GetCurrentDirectory();
             var    file    = (calName);
             Console.Write("12:00 AM: ");
             var twea = Console.ReadLine().ToLower();
             Console.Write("1:00 : ");
             var onea = Console.ReadLine().ToLower();
             Console.Write("2:00 : ");
             var twoa = Console.ReadLine().ToLower();
             Console.Write("3:00 : ");
             var thra = Console.ReadLine().ToLower();
             Console.Write("4:00 : ");
             var fora = Console.ReadLine().ToLower();
             Console.Write("5:00 : ");
             var fiva = Console.ReadLine().ToLower();
             Console.Write("6:00 : ");
             var sixa = Console.ReadLine().ToLower();
             Console.Write("7:00 : ");
             var seva = Console.ReadLine().ToLower();
             Console.Write("8:00 : ");
             var eita = Console.ReadLine().ToLower();
             Console.Write("9:00 : ");
             var nina = Console.ReadLine().ToLower();
             Console.Write("10:00 : ");
             var tena = Console.ReadLine().ToLower();
             Console.Write("11:00 : ");
             var elva = Console.ReadLine().ToLower();
             Console.Write("12:00 PM: ");
             var twep = Console.ReadLine().ToLower();
             Console.Write("1:00 : ");
             var onep = Console.ReadLine().ToLower();
             Console.Write("2:00 : ");
             var twop = Console.ReadLine().ToLower();
             Console.Write("3:00 : ");
             var thrp = Console.ReadLine().ToLower();
             Console.Write("4:00 : ");
             var forp = Console.ReadLine().ToLower();
             Console.Write("5:00 : ");
             var fivp = Console.ReadLine().ToLower();
             Console.Write("6:00 : ");
             var sixp = Console.ReadLine().ToLower();
             Console.Write("7:00 : ");
             var sevp = Console.ReadLine().ToLower();
             Console.Write("8:00 : ");
             var eitp = Console.ReadLine().ToLower();
             Console.Write("9:00 : ");
             var ninp = Console.ReadLine().ToLower();
             Console.Write("10:00 : ");
             var tenp = Console.ReadLine().ToLower();
             Console.Write("11:00 : ");
             var elvp = Console.ReadLine().ToLower();
             if (File.Exists(dir + "\\" + file))
             {
                 File.Delete(dir + "\\" + file);
             }
             using (FileStream fs = File.Create(dir + "\\" + file))
             {
                 //12am
                 Byte[] title = new UTF8Encoding(true).GetBytes("Calender for " + finput + " ");
                 fs.Write(title, 0, title.Length);
                 Byte[] twa = new UTF8Encoding(true).GetBytes("12:00 AM :" + twea + "\n");
                 fs.Write(twa, 0, twa.Length);
                 Byte[] ona = new UTF8Encoding(true).GetBytes("1:00 :" + onea + "\n");
                 fs.Write(ona, 0, ona.Length);
                 Byte[] toa = new UTF8Encoding(true).GetBytes("2:00 :" + twoa + "\n");
                 fs.Write(toa, 0, toa.Length);
                 Byte[] tra = new UTF8Encoding(true).GetBytes("3:00 :" + thra + "\n");
                 fs.Write(tra, 0, tra.Length);
                 Byte[] foa = new UTF8Encoding(true).GetBytes("4:00 :" + fora + "\n");
                 fs.Write(foa, 0, foa.Length);
                 Byte[] fia = new UTF8Encoding(true).GetBytes("5:00 :" + fiva + "\n");
                 fs.Write(fia, 0, fia.Length);
                 Byte[] sia = new UTF8Encoding(true).GetBytes("6:00 :" + sixa + "\n");
                 fs.Write(sia, 0, sia.Length);
                 Byte[] sea = new UTF8Encoding(true).GetBytes("7:00 :" + seva + "\n");
                 fs.Write(sea, 0, sea.Length);
                 Byte[] eia = new UTF8Encoding(true).GetBytes("8:00 :" + eita + "\n");
                 fs.Write(eia, 0, eia.Length);
                 Byte[] nia = new UTF8Encoding(true).GetBytes("9:00 :" + nina + "\n");
                 fs.Write(nia, 0, nia.Length);
                 Byte[] tea = new UTF8Encoding(true).GetBytes("10:00 :" + tena + "\n");
                 fs.Write(tea, 0, tea.Length);
                 Byte[] ela = new UTF8Encoding(true).GetBytes("11:00 :" + elva + "\n");
                 fs.Write(ela, 0, ela.Length);
                 //12pm
                 Byte[] twp = new UTF8Encoding(true).GetBytes("12:00 PM :" + twep + "\n");
                 fs.Write(twp, 0, twp.Length);
                 Byte[] onp = new UTF8Encoding(true).GetBytes("1:00 :" + onep + "\n");
                 fs.Write(onp, 0, onp.Length);
                 Byte[] top = new UTF8Encoding(true).GetBytes("2:00 :" + twop + "\n");
                 fs.Write(top, 0, top.Length);
                 Byte[] trp = new UTF8Encoding(true).GetBytes("3:00 :" + thrp + "\n");
                 fs.Write(trp, 0, trp.Length);
                 Byte[] fop = new UTF8Encoding(true).GetBytes("4:00 :" + forp + "\n");
                 fs.Write(fop, 0, fop.Length);
                 Byte[] fip = new UTF8Encoding(true).GetBytes("5:00 :" + fivp + "\n");
                 fs.Write(fip, 0, fip.Length);
                 Byte[] sip = new UTF8Encoding(true).GetBytes("6:00 :" + sixp + "\n");
                 fs.Write(sip, 0, sip.Length);
                 Byte[] sep = new UTF8Encoding(true).GetBytes("7:00 :" + sevp + "\n");
                 fs.Write(sep, 0, sep.Length);
                 Byte[] eip = new UTF8Encoding(true).GetBytes("8:00 :" + eitp + "\n");
                 fs.Write(eip, 0, eip.Length);
                 Byte[] nip = new UTF8Encoding(true).GetBytes("9:00 :" + ninp + "\n");
                 fs.Write(nip, 0, nip.Length);
                 Byte[] tep = new UTF8Encoding(true).GetBytes("10:00 :" + tenp + "\n");
                 fs.Write(tep, 0, tep.Length);
                 Byte[] elp = new UTF8Encoding(true).GetBytes("11:00 :" + elvp + "\n");
                 fs.Write(elp, 0, elp.Length);
             }
             Console.WriteLine("Calender Made!");
         }
         catch (Exception Ex)
         {
             Console.WriteLine("Woah Sia OS just ran into a issue, here's some details.");
             Console.WriteLine(Ex.ToString());
         }
     }
     else
     {
         RH.RError();
     }
 }