From b31e2049bdbb3c68365857253310fd5bb9e004c7 Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Sun, 19 Nov 2023 12:06:26 -0500 Subject: [PATCH] Hallelujah! --- .../Components/Data/CanvasService.cs | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/BlazorCanvas/BlazorCanvas.Server/Components/Data/CanvasService.cs b/BlazorCanvas/BlazorCanvas.Server/Components/Data/CanvasService.cs index f61f6ab..e0dca97 100644 --- a/BlazorCanvas/BlazorCanvas.Server/Components/Data/CanvasService.cs +++ b/BlazorCanvas/BlazorCanvas.Server/Components/Data/CanvasService.cs @@ -36,18 +36,6 @@ public class CanvasService { public ElementReference divCanvas { get; set; } public BECanvasComponent myCanvas { get; set; } = new(); - /// - /// Version Pub/Sub - /// - public async void Subscribe() { - CancellationToken cToken = new(); - while (!cToken.IsCancellationRequested) { - var comm = await _redisService.Subscribe(cToken); - if (comm is not null) - Draw(comm); - } - } - public async void Consume() { while (!_has_ended) { if (_lsComms.Count > 0) @@ -117,17 +105,13 @@ public class CanvasService { string color = "White"; CanvasCommand command = new(); - mouseX = eventArgs.OffsetX - (pointSize / 2); - mouseY = eventArgs.OffsetY - (pointSize / 2); + // Magnétisme boboche si activé, centrage si pas activé. + mouseX = eventArgs.OffsetX - (!snap? pointSize / 2: mouseX % pointSize); + mouseY = eventArgs.OffsetY - (!snap? pointSize / 2: mouseY % pointSize); if (eventArgs.Buttons == 1) // Couleur si bouton gauche, blanc si bouton droit color = currentColor; - if (snap) { // Magnétisme boboche. - mouseX -= mouseX % pointSize; - mouseY -= mouseY % pointSize; - } - command.X = mouseX; command.Y = mouseY; command.Color = color; @@ -136,7 +120,7 @@ public class CanvasService { if (command.Equals(_lastCommand)) return; // Pour pas spammer des commandes si c'est pas pertinent. - _redisService.Produce(command); // Stream + _redisService.Produce(command); _lastCommand = command; }