From f064b4485e24f7317b81b7364df76c0dfb63c74f Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Sat, 11 Nov 2023 15:56:09 -0500 Subject: [PATCH] La souris marche. --- BlazorCanvas/BlazorCanvas/Pages/Index.razor | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/BlazorCanvas/BlazorCanvas/Pages/Index.razor b/BlazorCanvas/BlazorCanvas/Pages/Index.razor index 35cc197..35bb4f4 100644 --- a/BlazorCanvas/BlazorCanvas/Pages/Index.razor +++ b/BlazorCanvas/BlazorCanvas/Pages/Index.razor @@ -6,8 +6,8 @@ @using Newtonsoft.Json.Linq @inject IJSRuntime jsRuntime -
- +
+

CanvasDrawing

@@ -17,10 +17,12 @@ BECanvasComponent myCanvas; Canvas2DContext currentCanvasContext; - async void OnClick(MouseEventArgs eventArgs) + async void OnMouseMove(MouseEventArgs eventArgs) { double mouseX = 0, mouseY = 0; + if (eventArgs.Buttons == 0) + return; if (divCanvas.Id?.Length > 0) { string data = await jsRuntime.InvokeAsync("getDivCanvasOffsets", @@ -34,11 +36,11 @@ currentCanvasContext = await myCanvas.CreateCanvas2DAsync(); - await currentCanvasContext.ClearRectAsync(0, 0, 800, 800); + //await currentCanvasContext.ClearRectAsync(0, 0, 800, 800); await currentCanvasContext.SetFillStyleAsync("Red"); - await currentCanvasContext.FillRectAsync(mouseX, mouseY, 5, 5); - await currentCanvasContext.StrokeTextAsync("ClientX: " + mouseX + - " Client Y: " + mouseY, 20, 20); + await currentCanvasContext.FillRectAsync(mouseX, mouseY, 2, 2); + //await currentCanvasContext.StrokeTextAsync("ClientX: " + mouseX + + // " Client Y: " + mouseY, 20, 20); } }