Code cleanup

This commit is contained in:
Stone_Red
2026-06-18 23:57:37 +02:00
parent ba5d670d1a
commit 6f58eefb66
3 changed files with 23 additions and 31 deletions
+9 -17
View File
@@ -37,24 +37,16 @@ public partial class Kernel : Sys.Kernel
new StopRemoteDesktopCommand()
]);
// Xml serializer test
Console.WriteLine("[Kernel] Testing XML serialization...");
Thread.Sleep(1000);
System.Drawing.Point point = new(10, 20);
string xml = $"<Point><X>{point.X}</X><Y>{point.Y}</Y></Point>";
Console.WriteLine("[Kernel] XML Serialization Test: " + xml);
Console.WriteLine("[TCP Server] Starting...");
Console.WriteLine("Starting...");
INetworkDevice? device = NetworkManager.PrimaryDevice;
if (device == null)
{
Console.WriteLine("[ERROR] No network device.");
Console.WriteLine("No network device.");
return;
}
Console.WriteLine("[TCP Server] Waiting for link...");
Console.WriteLine("Waiting for network link...");
int attempts = 0;
while (!device.LinkUp && attempts < 30)
{
@@ -64,29 +56,29 @@ public partial class Kernel : Sys.Kernel
if (!device.Ready)
{
Console.WriteLine("[ERROR] Device not ready.");
Console.WriteLine("Network device not ready.");
return;
}
Console.WriteLine("[TCP Server] Initializing network stack...");
Console.WriteLine("Initializing network stack...");
NetworkStack.Initialize();
Console.WriteLine("[TCP Server] Running DHCP...");
Console.WriteLine("Requesting IP via DHCP...");
DHCPClient dhcp = new DHCPClient();
if (dhcp.SendDiscoverPacket() == -1)
{
Console.WriteLine("[ERROR] DHCP failed.");
Console.WriteLine("DHCP discover failed.");
return;
}
IPConfig? config = NetworkConfigManager.Get(device);
if (config?.IPAddress == null)
{
Console.WriteLine("[ERROR] No IP from DHCP.");
Console.WriteLine("Failed to obtain IP address.");
return;
}
Console.WriteLine("[TCP Server] IP: " + config.IPAddress);
Console.WriteLine("IP: " + config.IPAddress);
Sys.Graphics.Canvas canvas = Sys.Graphics.FullScreenCanvas.GetFullScreenCanvas();
+12 -12
View File
@@ -86,35 +86,35 @@ internal sealed class RemoteDesktopProcess() : Process("Remote Desktop Server")
server.ListenTo("MouseMove", async (payload) =>
{
var msg = DeserializeMouseMove(payload);
WindowManager.EnqueueMouseEvent(MouseEvent.Move(msg.X, msg.Y));
(int X, int Y) = DeserializeMouseMove(payload);
WindowManager.EnqueueMouseEvent(MouseEvent.Move(X, Y));
});
server.ListenTo("MouseDown", async (payload) =>
{
var msg = DeserializeMouseButton(payload);
WindowManager.EnqueueMouseEvent(MouseEvent.ButtonDown(msg.X, msg.Y, ParseButton(msg.Button)));
(int X, int Y, string Button) = DeserializeMouseButton(payload);
WindowManager.EnqueueMouseEvent(MouseEvent.ButtonDown(X, Y, ParseButton(Button)));
});
server.ListenTo("MouseUp", async (payload) =>
{
var msg = DeserializeMouseButton(payload);
WindowManager.EnqueueMouseEvent(MouseEvent.ButtonUp(msg.X, msg.Y, ParseButton(msg.Button)));
(int X, int Y, string Button) = DeserializeMouseButton(payload);
WindowManager.EnqueueMouseEvent(MouseEvent.ButtonUp(X, Y, ParseButton(Button)));
});
server.ListenTo("MouseWheel", async (payload) =>
{
var msg = DeserializeMouseWheel(payload);
WindowManager.EnqueueMouseEvent(MouseEvent.Wheel(msg.X, msg.Y, msg.Delta));
(int X, int Y, int Delta) = DeserializeMouseWheel(payload);
WindowManager.EnqueueMouseEvent(MouseEvent.Wheel(X, Y, Delta));
});
server.ListenTo("KeyEvent", async (payload) =>
{
var msg = DeserializeKeyEvent(payload);
ConsoleKeyEx key = (ConsoleKeyEx)msg.Key;
char keyChar = msg.KeyChar.Length > 0 ? msg.KeyChar[0] : '\0';
(int Key, string KeyChar, bool Shift, bool Alt, bool Control, bool Pressed) = DeserializeKeyEvent(payload);
ConsoleKeyEx key = (ConsoleKeyEx)Key;
char keyChar = KeyChar.Length > 0 ? KeyChar[0] : '\0';
KeyEvent keyEvent = new(keyChar, key, msg.Shift, msg.Alt, msg.Control, msg.Pressed ? KeyEvent.KeyEventType.Make : KeyEvent.KeyEventType.Break);
KeyEvent keyEvent = new(keyChar, key, Shift, Alt, Control, Pressed ? KeyEvent.KeyEventType.Make : KeyEvent.KeyEventType.Break);
WindowManager.EnqueueKeyEvent(keyEvent);
});
}
+2 -2
View File
@@ -97,7 +97,7 @@ public static class CanvasExtensions
for (int cy = 0; cy < height; cy++)
{
int startY = cy * targetHeight / height;
int endY = ((cy + 1) * targetHeight + height - 1) / height;
int endY = (((cy + 1) * targetHeight) + height - 1) / height;
for (int cx = 0; cx < width; cx++)
{
@@ -106,7 +106,7 @@ public static class CanvasExtensions
if (font.ConvertByteToBitAddress(byteValue, (cx % 8) + 1))
{
int startX = cx * targetWidth / width;
int endX = ((cx + 1) * targetWidth + width - 1) / width;
int endX = (((cx + 1) * targetWidth) + width - 1) / width;
for (int sy = startY; sy < endY; sy++)
{