Hallelujah!
This commit is contained in:
parent
279247905c
commit
b31e2049bd
@ -36,18 +36,6 @@ public class CanvasService {
|
|||||||
public ElementReference divCanvas { get; set; }
|
public ElementReference divCanvas { get; set; }
|
||||||
public BECanvasComponent myCanvas { get; set; } = new();
|
public BECanvasComponent myCanvas { get; set; } = new();
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Version Pub/Sub
|
|
||||||
/// </summary>
|
|
||||||
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() {
|
public async void Consume() {
|
||||||
while (!_has_ended) {
|
while (!_has_ended) {
|
||||||
if (_lsComms.Count > 0)
|
if (_lsComms.Count > 0)
|
||||||
@ -117,17 +105,13 @@ public class CanvasService {
|
|||||||
string color = "White";
|
string color = "White";
|
||||||
CanvasCommand command = new();
|
CanvasCommand command = new();
|
||||||
|
|
||||||
mouseX = eventArgs.OffsetX - (pointSize / 2);
|
// Magnétisme boboche si activé, centrage si pas activé.
|
||||||
mouseY = eventArgs.OffsetY - (pointSize / 2);
|
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
|
if (eventArgs.Buttons == 1) // Couleur si bouton gauche, blanc si bouton droit
|
||||||
color = currentColor;
|
color = currentColor;
|
||||||
|
|
||||||
if (snap) { // Magnétisme boboche.
|
|
||||||
mouseX -= mouseX % pointSize;
|
|
||||||
mouseY -= mouseY % pointSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
command.X = mouseX;
|
command.X = mouseX;
|
||||||
command.Y = mouseY;
|
command.Y = mouseY;
|
||||||
command.Color = color;
|
command.Color = color;
|
||||||
@ -136,7 +120,7 @@ public class CanvasService {
|
|||||||
if (command.Equals(_lastCommand))
|
if (command.Equals(_lastCommand))
|
||||||
return; // Pour pas spammer des commandes si c'est pas pertinent.
|
return; // Pour pas spammer des commandes si c'est pas pertinent.
|
||||||
|
|
||||||
_redisService.Produce(command); // Stream
|
_redisService.Produce(command);
|
||||||
|
|
||||||
_lastCommand = command;
|
_lastCommand = command;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user