hsamza

Cosmos OS code

Aug 12th, 2025 (edited)
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.20 KB | None | 0 0
  1. using Cosmos.Core;
  2. using Cosmos.Core.IOGroup;
  3. using Cosmos.System;
  4. using Cosmos.System.Graphics;
  5. using Cosmos.System.Graphics.Fonts;
  6. using System;
  7. using System.Drawing;
  8. using System.Reflection;
  9. using Sys = Cosmos.System;
  10.  
  11. namespace CosmosOS
  12. {
  13.     public class Kernel : Sys.Kernel
  14.     {
  15.         Canvas canvas;
  16.         Pen pen;
  17.         int buttonx = 512;
  18.         int buttony = 384;
  19.         int bwidth = 100;
  20.         int bheight = 50;
  21.  
  22.         public static Color[] Colors = new Color[]
  23.         {
  24.             Color.Blue, Color.Green, Color.Red, Color.DarkMagenta,
  25.             Color.Purple, Color.Yellow, Color.Orange
  26.         };
  27.  
  28.         protected override void BeforeRun()
  29.         {
  30.             System.Threading.Thread.Sleep(500);
  31.             canvas = FullScreenCanvas.GetFullScreenCanvas();
  32.  
  33.            
  34.  
  35.            
  36.  
  37.             pen = new Pen(Color.White);
  38.             canvas.Display();
  39.         }
  40.  
  41.         public bool IsClicked()
  42.         {
  43.             return MouseManager.MouseState == MouseState.Left &&
  44.                    MouseManager.X >= buttonx && MouseManager.X <= buttonx + bwidth &&
  45.                    MouseManager.Y >= buttony && MouseManager.Y <= buttony + bheight;
  46.         }
  47.  
  48.         protected override void Run()
  49.         {
  50.             int index = 0;
  51.  
  52.             while (true)
  53.             {
  54.                 canvas.Clear(Colors[index]);
  55.                 canvas.DrawFilledRectangle(pen, new Sys.Graphics.Point(buttonx, buttony), bwidth, bheight);
  56.                 canvas.DrawPoint(pen, MouseManager.X, MouseManager.Y);
  57.                 canvas.DrawString("CosmosOS 2.0 booted up on i386.", PCScreenFont.Default, pen, 10, 10);
  58.  
  59.                 canvas.Display();
  60.                 if (IsClicked())
  61.                 {
  62.                     index++;
  63.                     if (index == 6)
  64.                     {
  65.                         index = 0;
  66.                     }
  67.                     continue
  68.                     ;
  69.                 }
  70.                
  71.                
  72.                 index = (index + 1) % Colors.Length;
  73.                 System.Threading.Thread.Sleep(500);
  74.                
  75.  
  76.                 System.Threading.Thread.Sleep(50);
  77.             }
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment