mirror of
https://github.com/Stone-Red-Code/RemSox.git
synced 2026-09-04 00:56:19 +02:00
Code cleanup
This commit is contained in:
@@ -37,24 +37,16 @@ public partial class Kernel : Sys.Kernel
|
|||||||
new StopRemoteDesktopCommand()
|
new StopRemoteDesktopCommand()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Xml serializer test
|
Console.WriteLine("Starting...");
|
||||||
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...");
|
|
||||||
|
|
||||||
INetworkDevice? device = NetworkManager.PrimaryDevice;
|
INetworkDevice? device = NetworkManager.PrimaryDevice;
|
||||||
if (device == null)
|
if (device == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("[ERROR] No network device.");
|
Console.WriteLine("No network device.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("[TCP Server] Waiting for link...");
|
Console.WriteLine("Waiting for network link...");
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
while (!device.LinkUp && attempts < 30)
|
while (!device.LinkUp && attempts < 30)
|
||||||
{
|
{
|
||||||
@@ -64,29 +56,29 @@ public partial class Kernel : Sys.Kernel
|
|||||||
|
|
||||||
if (!device.Ready)
|
if (!device.Ready)
|
||||||
{
|
{
|
||||||
Console.WriteLine("[ERROR] Device not ready.");
|
Console.WriteLine("Network device not ready.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("[TCP Server] Initializing network stack...");
|
Console.WriteLine("Initializing network stack...");
|
||||||
NetworkStack.Initialize();
|
NetworkStack.Initialize();
|
||||||
|
|
||||||
Console.WriteLine("[TCP Server] Running DHCP...");
|
Console.WriteLine("Requesting IP via DHCP...");
|
||||||
DHCPClient dhcp = new DHCPClient();
|
DHCPClient dhcp = new DHCPClient();
|
||||||
if (dhcp.SendDiscoverPacket() == -1)
|
if (dhcp.SendDiscoverPacket() == -1)
|
||||||
{
|
{
|
||||||
Console.WriteLine("[ERROR] DHCP failed.");
|
Console.WriteLine("DHCP discover failed.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPConfig? config = NetworkConfigManager.Get(device);
|
IPConfig? config = NetworkConfigManager.Get(device);
|
||||||
if (config?.IPAddress == null)
|
if (config?.IPAddress == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("[ERROR] No IP from DHCP.");
|
Console.WriteLine("Failed to obtain IP address.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("[TCP Server] IP: " + config.IPAddress);
|
Console.WriteLine("IP: " + config.IPAddress);
|
||||||
|
|
||||||
Sys.Graphics.Canvas canvas = Sys.Graphics.FullScreenCanvas.GetFullScreenCanvas();
|
Sys.Graphics.Canvas canvas = Sys.Graphics.FullScreenCanvas.GetFullScreenCanvas();
|
||||||
|
|
||||||
|
|||||||
@@ -86,35 +86,35 @@ internal sealed class RemoteDesktopProcess() : Process("Remote Desktop Server")
|
|||||||
|
|
||||||
server.ListenTo("MouseMove", async (payload) =>
|
server.ListenTo("MouseMove", async (payload) =>
|
||||||
{
|
{
|
||||||
var msg = DeserializeMouseMove(payload);
|
(int X, int Y) = DeserializeMouseMove(payload);
|
||||||
WindowManager.EnqueueMouseEvent(MouseEvent.Move(msg.X, msg.Y));
|
WindowManager.EnqueueMouseEvent(MouseEvent.Move(X, Y));
|
||||||
});
|
});
|
||||||
|
|
||||||
server.ListenTo("MouseDown", async (payload) =>
|
server.ListenTo("MouseDown", async (payload) =>
|
||||||
{
|
{
|
||||||
var msg = DeserializeMouseButton(payload);
|
(int X, int Y, string Button) = DeserializeMouseButton(payload);
|
||||||
WindowManager.EnqueueMouseEvent(MouseEvent.ButtonDown(msg.X, msg.Y, ParseButton(msg.Button)));
|
WindowManager.EnqueueMouseEvent(MouseEvent.ButtonDown(X, Y, ParseButton(Button)));
|
||||||
});
|
});
|
||||||
|
|
||||||
server.ListenTo("MouseUp", async (payload) =>
|
server.ListenTo("MouseUp", async (payload) =>
|
||||||
{
|
{
|
||||||
var msg = DeserializeMouseButton(payload);
|
(int X, int Y, string Button) = DeserializeMouseButton(payload);
|
||||||
WindowManager.EnqueueMouseEvent(MouseEvent.ButtonUp(msg.X, msg.Y, ParseButton(msg.Button)));
|
WindowManager.EnqueueMouseEvent(MouseEvent.ButtonUp(X, Y, ParseButton(Button)));
|
||||||
});
|
});
|
||||||
|
|
||||||
server.ListenTo("MouseWheel", async (payload) =>
|
server.ListenTo("MouseWheel", async (payload) =>
|
||||||
{
|
{
|
||||||
var msg = DeserializeMouseWheel(payload);
|
(int X, int Y, int Delta) = DeserializeMouseWheel(payload);
|
||||||
WindowManager.EnqueueMouseEvent(MouseEvent.Wheel(msg.X, msg.Y, msg.Delta));
|
WindowManager.EnqueueMouseEvent(MouseEvent.Wheel(X, Y, Delta));
|
||||||
});
|
});
|
||||||
|
|
||||||
server.ListenTo("KeyEvent", async (payload) =>
|
server.ListenTo("KeyEvent", async (payload) =>
|
||||||
{
|
{
|
||||||
var msg = DeserializeKeyEvent(payload);
|
(int Key, string KeyChar, bool Shift, bool Alt, bool Control, bool Pressed) = DeserializeKeyEvent(payload);
|
||||||
ConsoleKeyEx key = (ConsoleKeyEx)msg.Key;
|
ConsoleKeyEx key = (ConsoleKeyEx)Key;
|
||||||
char keyChar = msg.KeyChar.Length > 0 ? msg.KeyChar[0] : '\0';
|
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);
|
WindowManager.EnqueueKeyEvent(keyEvent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public static class CanvasExtensions
|
|||||||
for (int cy = 0; cy < height; cy++)
|
for (int cy = 0; cy < height; cy++)
|
||||||
{
|
{
|
||||||
int startY = cy * targetHeight / height;
|
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++)
|
for (int cx = 0; cx < width; cx++)
|
||||||
{
|
{
|
||||||
@@ -106,7 +106,7 @@ public static class CanvasExtensions
|
|||||||
if (font.ConvertByteToBitAddress(byteValue, (cx % 8) + 1))
|
if (font.ConvertByteToBitAddress(byteValue, (cx % 8) + 1))
|
||||||
{
|
{
|
||||||
int startX = cx * targetWidth / width;
|
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++)
|
for (int sy = startY; sy < endY; sy++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user