GUI桌面环境

This commit is contained in:
2026-03-01 17:03:49 +08:00
parent 545f40cf95
commit f0a9223520
162 changed files with 9170 additions and 135 deletions

View File

@@ -0,0 +1,71 @@
using CMLeonOS;
using CMLeonOS.Utils;
using CMLeonOS.Gui.SmoothMono;
using CMLeonOS.Gui.UILib;
using System;
using System.Drawing;
namespace CMLeonOS.Gui.Apps
{
internal class MemoryStatistics : Process
{
internal MemoryStatistics() : base("MemoryStatistics", ProcessType.Application) { }
AppWindow window;
WindowManager wm = ProcessManager.GetProcess<WindowManager>();
private int lastSecond;
private static int padding = 12;
private static int barHeight = 12;
private static Color barColour = Color.FromArgb(0, 155, 254);
private void Update()
{
window.Clear(Color.LightGray);
var statistics = MemoryStatisticsProvider.GetMemoryStatistics();
window.DrawString("Memory Statistics", Color.DarkBlue, padding, padding);
window.DrawString(string.Format(@"Total: {0} MB
Unavailable: {1} MB
Used: {2:d1} MB
Free: {3} MB
Percentage Used: {4:d1}%",
statistics.TotalMB,
statistics.UnavailableMB,
statistics.UsedMB,
statistics.FreeMB,
statistics.PercentUsed), Color.Black, padding, padding + FontData.Height + padding);
window.DrawFilledRectangle(0, window.Height - barHeight, window.Width, barHeight, Color.Black);
window.DrawFilledRectangle(0, window.Height - barHeight, (int)(window.Width * ((float)statistics.PercentUsed / 100f)), barHeight, barColour);
wm.Update(window);
}
public override void Start()
{
base.Start();
window = new AppWindow(this, 256, 256, 256, 192);
wm.AddWindow(window);
window.Title = "Memory Statistics";
window.Icon = AppManager.GetAppMetadata("Memory Statistics").Icon;
window.Closing = TryStop;
Update();
}
public override void Run()
{
int second = DateTime.Now.Second;
if (lastSecond != second)
{
lastSecond = second;
Update();
}
}
}
}