Esempio n. 1
0
 protected override void BeforeRun()
 {
     VGADriverII.Initialize(VGAMode.Pixel320x200DB);
     draw.FromByteArray(System.Graphics.Images.BootScreen);
     VGAGraphics.DrawImage(0, 0, draw);
     VGAGraphics.Display();
     draw.FromByteArray(System.Graphics.Images.Cursor);
 }
Esempio n. 2
0
 public static void Init()
 {
     VGADriverII.SetMode(VGAMode.Pixel320x200DB);
     GraphicsMode = true;
     MouseManager.ScreenHeight = 200;
     MouseManager.ScreenWidth  = 320;
     windows.Add(new DesktopWindow());
     windows[0].Show();
 }
Esempio n. 3
0
 public static void Run()
 {
     VGAGraphics.Clear(VGAColor.Black);
     //draw current window (windows are always fullscreen for now)
     if (!(windows.Count == 0))
     {
         windows[RunningIndex].Run();
     }
     //draw mouse
     VGAGraphics.DrawImage((int)MouseManager.X, (int)MouseManager.Y, VGAColor.Magenta, ImgCursor);
     VGADriverII.Display();
 }
Esempio n. 4
0
 public static void Run()
 {
     VGAGraphics.Clear(VGAColor.Black);
     foreach (var window in windows)
     {
         window.Draw();
     }
     if (windows.Count != 0)
     {
         windows[RunningIndex].Run();
     }
     //draw mouse
     VGAGraphics.DrawImage((int)MouseManager.X, (int)MouseManager.Y, VGAColor.Magenta, ImgCursor);
     VGADriverII.Display();
 }
Esempio n. 5
0
        protected override void BeforeRun()
        {
            Console.WriteLine("Cosmos loaded. Booting the kernel!");
            Console.WriteLine("Initializing update package.");
            //update.BeforeRun();
            Console.WriteLine("Initializing components.");
            Console.WriteLine("FS Driver");
            var fs = new Sys.FileSystem.CosmosVFS();

            Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs);
            Console.WriteLine("VGA Driver");
            VGADriverII.Initialize(VGAMode.Text80x25);
            Terminal.Clear();
            Modules.UC.username = "******";
        }
Esempio n. 6
0
 public static void Run()
 {
     VGADriverII.Clear(247);
     VGAGraphics.DrawString(0, 0, "Cosix Graphics Manager", VGAColor.Black, VGAFont.Font8x8);
     VGAGraphics.DrawFilledRect(300, 180, 20, 20, VGAColor.Red);
     VGAGraphics.DrawFilledRect((int)MouseManager.X, (int)MouseManager.Y, 2, 2, VGAColor.Blue);
     if (vstate == 2)
     {
         VGAGraphics.Display();
     }
     if ((MouseManager.X > 300) & (MouseManager.Y > 180) & (MouseManager.MouseState == MouseState.Left))
     {
         GoText();
         Terminal.TextColor = ConsoleColor.White;
         Terminal.BackColor = ConsoleColor.Black;
         Terminal.Clear();
     }
 }
Esempio n. 7
0
 public static void Init(bool db)
 {
     if (db)
     {
         VGADriverII.Initialize(VGAMode.Pixel320x200DB);
         vstate = 2;
     }
     else
     {
         VGADriverII.Initialize(VGAMode.Pixel320x200);
         vstate = 1;
     }
     MouseManager.ScreenHeight = 200;
     MouseManager.ScreenWidth  = 320;
     VGADriverII.Clear(223);
     if (vstate == 2)
     {
         VGADriverII.Display();
     }
 }
Esempio n. 8
0
 public static void Crash(Exception e)
 {
     if (Modules.CGM.VStateGet() == 0)
     {
         Terminal.Clear(ConsoleColor.DarkRed);
         Terminal.WriteLine("A fatal exception occured!");
         Terminal.WriteLine(e.ToString());
         Terminal.WriteLine("Please report this to the Cosix devs.");
         Terminal.DisableCursor();
         while (true)
         {
             if (Sys.KeyboardManager.ControlPressed)
             {
                 Terminal.BackColor = ConsoleColor.Black;
                 Terminal.Clear();
                 Terminal.EnableCursor();
                 break;
             }
             if (Sys.KeyboardManager.ShiftPressed)
             {
                 Restart();
             }
         }
     }
     else
     {
         VGADriverII.Clear(229);
         VGAGraphics.DrawString(0, 0, "A fatal exception occured!\n" + e.ToString() + "\nPlease report this to the Cosix devs.", VGAColor.White, VGAFont.Font8x8);
         if (Modules.CGM.VStateGet() == 2)
         {
             VGADriverII.Display();
         }
         while (true)
         {
         }
     }
 }
Esempio n. 9
0
 public static void GoText()
 {
     VGADriverII.Initialize(VGAMode.Text90x60);
     vstate = 0;
 }
Esempio n. 10
0
 protected override void Run()
 {
     VGADriverII.Clear(206);
     VGAGraphics.DrawImage((int)Sys.MouseManager.X, (int)Sys.MouseManager.Y, draw);
     VGADriverII.Display();
 }
Esempio n. 11
0
        protected override void BeforeRun()
        {
            try
            {
                VGADriverII.Initialize(VGAMode.Text90x60);
                Console.WriteLine("Hold shift for boot options...");
                for (int i = 0; i < 1000000; i++)
                {
                    if (true)
                    {
                    }
                }
                Console.Clear();
                if (Sys.KeyboardManager.ShiftPressed)
                {
                    while (true)
                    {
                        Console.WriteLine("VesaOS Boot Menu");
                        Console.WriteLine("1) Boot normally");
                        Console.WriteLine("2) Safe mode");
                        Console.WriteLine("3) Safe mode with networking");
                        Console.WriteLine("4) Safe mode with filesystem");
                        Console.WriteLine();
                        Console.Write("Select one: ");
                        ConsoleKeyInfo kcki = Console.ReadKey();
                        string         k    = kcki.KeyChar.ToString();
                        if (k == "1")
                        {
                            break;
                        }
                        if (k == "2")
                        {
                            BootMode = 1;
                            break;
                        }
                        if (k == "3")
                        {
                            BootMode = 2;
                            break;
                        }
                        if (k == "4")
                        {
                            BootMode = 3;
                            break;
                        }
                    }
                }
                mDebugger.Send("VesaOS is starting!");
                //ProcessMemory = Cosmos.Core.Memory.Heap.Alloc(((Cosmos.Core.CPU.GetAmountOfRAM() * 1024) * 1024) / 2);
                //ProcessMemorySize = (int)(Cosmos.Core.CPU.GetAmountOfRAM() * 1024 * 1024 / 2);
                pidstack.Add(0);
                Terminal.BackColor = ConsoleColor.DarkGreen;
                Terminal.ClearSlow(ConsoleColor.DarkGreen);
                Terminal.SetCursorPos(39, 30);
                Terminal.Write("VesaOS");

                /*Console.WriteLine("VesaOSPE is starting...");
                 * Console.WriteLine("Initializing ramdisk...");
                 * ramdisk = new VirtualPartition();
                 * BootFinished?.Invoke();*/
                //Console.WriteLine("Initializing filesystem...");
                if (BootMode == 0 || BootMode == 3)
                {
                    mDebugger.Send("Filesystem init");
                    Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs);
                    Terminal.ClearSlow(ConsoleColor.DarkGreen);
                    Terminal.SetCursorPos(39, 30);
                    Terminal.Write("VesaOS");
                    mDebugger.Send("Checking drive 0 is accessible...");
                    try
                    {
                        fs.GetDirectoryListing(@"0:\");
                    }
                    catch (Exception)
                    {
                        mDebugger.Send("WARNING: Could not access drive 0!");
                    }
                    mDebugger.Send("Reading registry...");
                    //config = new Core.Registry.IniFile("0:\\config.ini");
                }
                if (BootMode == 0)
                {
                    if (true) //config.GetBoolean("Boot", "NetworkEnabled")
                    {
                        mDebugger.Send("Initializing network...");
                        VesaOS.System.Network.NTPClient.Init();
                    }
                }
                if (BootMode == 2)
                {
                    VesaOS.System.Network.NTPClient.Init();
                }
                if (BootMode == 0 || BootMode == 3)
                {
                    if (!true) //config.GetBoolean("Setup", "SetupCompleted")
                    {
                        /*System.Graphics.WindowManager.Init();
                         * System.Graphics.Window OOBE = new Apps.VesaOOBE();
                         * System.Graphics.WindowManager.ShowWindow(OOBE);
                         * while (true) { System.Graphics.WindowManager.Run(); }*/
                        Terminal.BackColor = ConsoleColor.Black;
                        Terminal.ClearSlow(ConsoleColor.Black);
                        Apps.VesaOOBEText.UserAccountSetup();
                    }
                }
                mDebugger.Send("Initializing shell...");
                Terminal.InitHistory();
                //Console.WriteLine("Starting services...");
                //StartService("ukms");
                //Console.WriteLine("Boot finished.");
                pidstack.Add(1);
                Terminal.BackColor = ConsoleColor.Black;
                Terminal.ClearSlow(ConsoleColor.Black);

                /*Console.Write("Username: "******"Password: "******"Username: "******"Password: ");
                 *  psk = Console.ReadLine();
                 * }*/
            }
            catch (Exception e)
            {
                Crash(e);
            }
        }
Esempio n. 12
0
        protected override void BeforeRun()
        {
            try
            {
                mDebugger.Send("VesaOS is starting!");
                pidstack.Add(0);
                VGADriverII.Initialize(VGAMode.Text90x60);
                Terminal.BackColor = ConsoleColor.DarkGreen;
                Terminal.ClearSlow(ConsoleColor.DarkGreen);
                Terminal.SetCursorPos(39, 30);
                Terminal.Write("VesaOS");

                /*Console.WriteLine("VesaOSPE is starting...");
                 * Console.WriteLine("Initializing ramdisk...");
                 * ramdisk = new VirtualPartition();
                 * BootFinished?.Invoke();*/
                //Console.WriteLine("Initializing filesystem...");
                mDebugger.Send("Filesystem init");
                Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs);
                Terminal.ClearSlow(ConsoleColor.DarkGreen);
                Terminal.SetCursorPos(39, 30);
                Terminal.Write("VesaOS");
                mDebugger.Send("Checking drive 0 is accessible...");
                try
                {
                    fs.GetDirectoryListing(@"0:\");
                }
                catch (Exception)
                {
                    mDebugger.Send("WARNING: Could not access drive 0!");
                }
                mDebugger.Send("Reading registry...");
                config = new Core.Registry.IniFile("0:\\config.ini");
                if (config.GetBoolean("Boot", "NetworkEnabled"))
                {
                    mDebugger.Send("Initializing network...");
                    VesaOS.System.Network.NTPClient.Init();
                }
                if (!config.GetBoolean("Setup", "SetupCompleted"))
                {
                    /*System.Graphics.WindowManager.Init();
                     * System.Graphics.Window OOBE = new Apps.VesaOOBE();
                     * System.Graphics.WindowManager.ShowWindow(OOBE);
                     * while (true) { System.Graphics.WindowManager.Run(); }*/
                    Terminal.BackColor = ConsoleColor.Black;
                    Terminal.ClearSlow(ConsoleColor.Black);
                    Apps.VesaOOBEText.UserAccountSetup();
                }
                mDebugger.Send("Initializing shell...");
                Terminal.InitHistory();
                //Console.WriteLine("Starting services...");
                //StartService("ukms");
                //Console.WriteLine("Boot finished.");
                pidstack.Add(1);
                Terminal.BackColor = ConsoleColor.Black;
                Terminal.ClearSlow(ConsoleColor.Black);

                /*Console.Write("Username: "******"Password: "******"Username: "******"Password: ");
                 *  psk = Console.ReadLine();
                 * }*/
            }
            catch (Exception e)
            {
                Crash(e);
            }
        }
Esempio n. 13
0
        public static void Call(string cmdfull)
        {
            string[] cmdsplit = cmdfull.Split(" ");
            string   cmd      = cmdsplit[0];

            Kernel.RunInit();
            switch (cmd)
            {
            case "":
                break;

            case "help":
                Commands.Help.Main();
                break;

            case "ver":
                Commands.Ver.Main();
                break;

            case "crash":
                Kernel.Crash(new Exception("Manual crash!"));
                break;

            case "mode":
                try
                {
                    switch (cmdsplit[1])
                    {
                    case "0":
                        VGADriverII.SetMode(VGAMode.Text80x25);
                        Terminal.Clear();
                        break;

                    case "1":
                        VGADriverII.SetMode(VGAMode.Text80x50);
                        Terminal.Clear();
                        break;

                    case "2":
                        VGADriverII.SetMode(VGAMode.Text90x60);
                        Terminal.Clear();
                        break;

                    case "3":
                        Modules.CGM.Init(true);
                        VGADriverII.Clear(247);
                        break;

                    default:
                        break;
                    }
                }
                catch { }
                break;

            case "mill":
                Windmill.Windmill runner = new Windmill.Windmill(4096);
                for (; !runner.program[runner.index].Equals(0);)
                {
                    runner.RunNext();
                }
                break;

            case "miv":
                if (1 < cmdsplit.Length)
                {
                    Kernel.file = cmdsplit[1];
                    if (File.Exists(cmdsplit[1]))
                    {
                        File.WriteAllText(@"0:\" + Kernel.file, MIV.miv(File.ReadAllText(cmdsplit[1])));
                    }
                    else
                    {
                        File.WriteAllText(@"0:\" + Kernel.file, MIV.miv(null));
                    }
                }
                else
                {
                    MIV.StartMIV();
                }
                break;

            case "dir":
                string[] filePaths = Directory.GetFiles(@"0:\");
                var      drive     = new DriveInfo("0");
                Terminal.WriteLine("Volume in drive 0 is " + $"{drive.VolumeLabel}");
                Terminal.WriteLine("Directory of " + @"0:\");
                Terminal.WriteLine("\n");
                for (int i = 0; i < filePaths.Length; ++i)
                {
                    string path = filePaths[i];
                    Terminal.WriteLine(System.IO.Path.GetFileName(path));
                }
                foreach (var d in System.IO.Directory.GetDirectories(@"0:\"))
                {
                    var dir     = new DirectoryInfo(d);
                    var dirName = dir.Name;

                    Terminal.WriteLine(dirName + " <DIR>");
                }
                Terminal.WriteLine("\n");
                Terminal.WriteLine("        " + $"{drive.TotalSize}" + " bytes");
                Terminal.WriteLine("        " + $"{drive.AvailableFreeSpace}" + " bytes free");
                break;

            case "power":
                Commands.Power.Main(cmdsplit);
                break;

            case "elev":
                Modules.UC.Elevate();
                break;

            case "login":
                Modules.UC.username = cmdsplit[1];
                break;

            case "clear":
                Terminal.Clear();
                break;

            default:
                Terminal.WriteLine("cash: Command not found");
                break;
            }
            Kernel.ProgramStop();
        }
Esempio n. 14
0
        /// <summary>
        /// Process a command
        /// </summary>
        /// <param name="g">The Console.</param>
        /// <param name="cmd">The Command</param>
        public static void ProcessCommand(IGuiConsole g, string cmd)
        {
            if (cmd.ToLower().StartsWith("help"))
            {
                new Help().Execute(g, cmd);
            }
            else if (cmd.ToLower().StartsWith("clear"))
            {
                g.Clear();
            }
            else if (cmd.ToLower().StartsWith("about"))
            {
                g.WriteLine(Kernel.KernelVersion);
            }
            else if (cmd.ToLower().StartsWith("ls"))
            {
                new LsCommand().Execute(g, cmd);
            }
            else if (cmd.ToLower().StartsWith("dir"))
            {
                new LsCommand().Execute(g, cmd);
            }
            else if (cmd.ToLower().StartsWith("cd"))
            {
                string NewName = cmd.Replace("cd ", "");
                var    fs      = g.CurrentDIR;
                if (Directory.Exists(fs + @"\" + NewName))
                {
                    g.CurrentDIR = fs + NewName + @"\";
                }
                else if (NewName == "..")
                {
                    g.CurrentDIR = Directory.GetParent(fs).FullName;
                }
                else if (NewName == "/" | NewName == @"\")
                {
                    g.CurrentDIR = Directory.GetDirectoryRoot(fs);
                }
                else if (NewName.Length == 2)
                {
                    if (NewName[1] == ':')
                    {
                        if (Directory.Exists(NewName + @"\"))
                        {
                            g.CurrentDIR = NewName + @"\";
                        }
                        else
                        {
                            g.WriteLine("ERROR: Dirrectory " + NewName + @"\" + " Does not exist.");
                        }
                    }
                    else
                    {
                        g.WriteLine("ERROR: Dirrectory " + fs + @"\" + NewName + " Does not exist.");
                    }
                }
                else
                {
                    g.WriteLine("ERROR: Dirrectory " + fs + @"\" + NewName + " Does not exist.");
                }
            }
            else if (cmd.ToLower().StartsWith("shutdown"))
            {
                Cosmos.System.Power.Shutdown();
            }
            else if (cmd.ToLower().StartsWith("reboot"))
            {
                Cosmos.System.Power.Reboot();
            }
            else if (cmd.ToLower().StartsWith("mkdir"))
            {
                new mkdir().Execute(g, cmd);
            }
            else if (cmd.ToLower().StartsWith("cat"))
            {
                new cat().Execute(g, cmd);
            }
            else if (cmd.ToLower().StartsWith("beep"))
            {
                System.Console.Beep();
            }
            else if (cmd.ToLower().StartsWith("edit"))
            {
                new edit().Execute(g, cmd);
            }
            else if (cmd.ToLower().StartsWith("crash"))
            {
                throw new System.Exception("Crash command executed.");
            }
            else if (cmd.ToLower().StartsWith("mode"))
            {
                var args = cmd.ToLower().Split();

                if (args.Length == 1 | args.Length == 0)
                {
                    g.WriteLine("Invaild Usage. Use mode help for help.");
                }
                else if (args.Length == 2)
                {
                    if (args[1] == "text")
                    {
                        if (IsGUI == true)
                        {
                            if (g.term is Window window)
                            {
                                DesktopManager.CloseWindow(window);
                            }
                            IsGUI = false;
                            //Switch over to text terminal.
                            g = new TextTerm
                            {
                                term = new TextTerm()
                            };
                            Display.Disable();
                            VGADriverII.SetMode(VGAMode.Text80x25);
                            g.WriteLine("Now in text mode!");
                            g.Write(g.CurrentDIR);
                            while (IsGUI == false)
                            {
                                var input = g.ReadLine();
                                ProcessCommand(g, input);
                                g.Write(g.CurrentDIR);
                            }
                        }
                        else
                        {
                            g.WriteLine("ERROR: Already in text mode");
                        }
                    }
                    else if (args[1] == "gui")
                    {
                        if (!IsGUI)
                        {
                            IsGUI = true;
                            Display.Init();
                            UiMouse.Init();
                            g.term = new GuiConsole(new Terminal(), 80);
                            DesktopManager.OpenWindow(new Taskbar());
                        }
                        else
                        {
                            g.WriteLine("ERROR: Already in GUI mode");
                        }
                    }
                    else if (args[1] == "help")
                    {
                        g.WriteLine("Mode command line usage");
                        g.WriteLine("======================");
                        g.WriteLine("mode <DisplayMode>");
                        g.WriteLine("Display Modes: ");
                        g.WriteLine("GUI - Switches over to GUI mode");
                        g.WriteLine("TEXT - Switches over to Text mode");
                    }
                    else
                    {
                        g.WriteLine("Invaild Usage. Use \"mode help\" for help.");
                    }
                }
                g.WriteLine("[DEBUG] args length: " + args.Length);
                foreach (var item in args)
                {
                    g.WriteLine(item);
                }
            }
            else if (cmd.ToLower().StartsWith("exit"))
            {
                if (IsGUI)
                {
                    if (g.term is Window window)
                    {
                        DesktopManager.CloseWindow(window);
                    }
                }
                else
                {
                    g.WriteLine("Exit cannot be used on a text session. Please use gui mode to use exit command.");
                }
            }
            else if (cmd.ToLower().StartsWith("setup"))
            {
                if (IsGUI)
                {
                    DesktopManager.OpenWindow(new SetupWindow());
                }
                else
                {
                    IsGUI = true;

                    Display.Init();
                    UiMouse.Init();
                    DesktopManager.OpenWindow(new SetupWindow());
                    Display.Render();
                }
            }
            else if (string.IsNullOrEmpty(cmd))
            {
            }
            else
            {
                g.WriteLine($"\"{cmd}\" is not recognized as an internal command,operable program.");
            }
        }