Files
CMLeonOS/shell/Commands/TestGuiCommand.cs

86 lines
2.7 KiB
C#
Raw Normal View History

2026-02-05 13:15:17 +08:00
using System;
2026-02-05 20:26:36 +08:00
using System.Collections.Generic;
using System.Text;
2026-02-05 13:15:17 +08:00
using Sys = Cosmos.System;
2026-02-05 20:26:36 +08:00
using System.Drawing;
2026-02-05 13:15:17 +08:00
using Cosmos.System.Graphics;
2026-02-05 20:26:36 +08:00
using Microsoft.VisualBasic;
using Cosmos.System.Graphics.Fonts;
using Cosmos.System;
using Cosmos.HAL;
using Cosmos.System.FileSystem.VFS;
using Cosmos.System.FileSystem;
using System.IO;
2026-02-05 13:15:17 +08:00
namespace CMLeonOS.Commands
{
public static class TestGuiCommand
{
2026-02-05 20:26:36 +08:00
public static Canvas Screen;
public static Bitmap Wallpaper;
public static Mode display;
2026-02-05 13:15:17 +08:00
2026-02-05 20:26:36 +08:00
public static void DrawCursor()
{
if ((int)MouseManager.X >= 0 && (int)MouseManager.Y >= 0 && (int)MouseManager.X < Screen.Mode.Width && (int)MouseManager.Y < Screen.Mode.Height)
{
MouseManager.ScreenWidth = Screen.Mode.Width;
MouseManager.ScreenHeight = Screen.Mode.Height;
Screen.DrawFilledCircle(Color.FromArgb(75, 255, 255, 255), (int)MouseManager.X, (int)MouseManager.Y, 10);
}
}
2026-02-05 13:15:17 +08:00
2026-02-05 20:26:36 +08:00
public static void DrawBackground()
{
Screen.Clear(Color.Indigo);
}
2026-02-05 13:15:17 +08:00
2026-02-05 20:26:36 +08:00
public static void RunTestGui()
{
2026-02-05 13:15:17 +08:00
try
{
2026-02-05 20:26:36 +08:00
display = new Mode(1024, 768, ColorDepth.ColorDepth24);
Screen = FullScreenCanvas.GetFullScreenCanvas(display);
2026-02-05 13:15:17 +08:00
2026-02-05 20:26:36 +08:00
try
{
if (File.Exists(@"0:\system\wallpaper.bmp"))
{
Wallpaper = new Bitmap(File.ReadAllBytes(@"0:\system\wallpaper.bmp"));
}
else
{
Wallpaper = null;
}
}
catch
{
Wallpaper = null;
}
2026-02-05 13:15:17 +08:00
2026-02-05 20:26:36 +08:00
global::System.Console.WriteLine("Starting graphical mode...");
global::System.Console.WriteLine("Press ESC to return to shell.");
2026-02-05 13:15:17 +08:00
2026-02-05 20:26:36 +08:00
while (true)
{
Screen.Clear();
DrawBackground();
Screen.DrawString(DateTime.Now.ToString("H:mm") + ", Screen:" + Screen.Mode.Width + "x" + Screen.Mode.Height, PCScreenFont.Default, Color.White, 15, 10);
DrawCursor();
Screen.Display();
2026-02-05 13:15:17 +08:00
2026-02-05 20:26:36 +08:00
var key = global::System.Console.ReadKey(true);
if (key.Key == ConsoleKey.Escape)
{
break;
}
}
2026-02-05 13:15:17 +08:00
}
catch (Exception e)
{
2026-02-05 20:26:36 +08:00
global::System.Console.WriteLine("Exception occurred: " + e.Message);
2026-02-05 13:15:17 +08:00
}
}
}
}