La souris marche.
This commit is contained in:
		| @@ -6,8 +6,8 @@ | |||||||
| @using Newtonsoft.Json.Linq | @using Newtonsoft.Json.Linq | ||||||
| @inject IJSRuntime jsRuntime | @inject IJSRuntime jsRuntime | ||||||
|  |  | ||||||
| <div @ref="divCanvas" @onclick="OnClick"> | <div @ref="divCanvas" @onmousemove="OnMouseMove"> | ||||||
|     <BECanvas @ref="myCanvas" Height="800" Width="800"></BECanvas> |     <BECanvas @ref="myCanvas" Height="1920" Width="1080"></BECanvas> | ||||||
| </div> | </div> | ||||||
|  |  | ||||||
| <h3>CanvasDrawing</h3> | <h3>CanvasDrawing</h3> | ||||||
| @@ -17,10 +17,12 @@ | |||||||
|     BECanvasComponent myCanvas; |     BECanvasComponent myCanvas; | ||||||
|     Canvas2DContext currentCanvasContext; |     Canvas2DContext currentCanvasContext; | ||||||
|  |  | ||||||
|     async void OnClick(MouseEventArgs eventArgs) |     async void OnMouseMove(MouseEventArgs eventArgs) | ||||||
|     { |     { | ||||||
|         double mouseX = 0, mouseY = 0; |         double mouseX = 0, mouseY = 0; | ||||||
|  |  | ||||||
|  |         if (eventArgs.Buttons == 0) | ||||||
|  |             return; | ||||||
|         if (divCanvas.Id?.Length > 0) |         if (divCanvas.Id?.Length > 0) | ||||||
|         { |         { | ||||||
|             string data = await jsRuntime.InvokeAsync<string>("getDivCanvasOffsets", |             string data = await jsRuntime.InvokeAsync<string>("getDivCanvasOffsets", | ||||||
| @@ -34,11 +36,11 @@ | |||||||
|  |  | ||||||
|             currentCanvasContext = await myCanvas.CreateCanvas2DAsync(); |             currentCanvasContext = await myCanvas.CreateCanvas2DAsync(); | ||||||
|  |  | ||||||
|             await currentCanvasContext.ClearRectAsync(0, 0, 800, 800); |             //await currentCanvasContext.ClearRectAsync(0, 0, 800, 800); | ||||||
|             await currentCanvasContext.SetFillStyleAsync("Red"); |             await currentCanvasContext.SetFillStyleAsync("Red"); | ||||||
|             await currentCanvasContext.FillRectAsync(mouseX, mouseY, 5, 5); |             await currentCanvasContext.FillRectAsync(mouseX, mouseY, 2, 2); | ||||||
|             await currentCanvasContext.StrokeTextAsync("ClientX: " + mouseX + |             //await currentCanvasContext.StrokeTextAsync("ClientX: " + mouseX + | ||||||
|                 "   Client Y: " + mouseY, 20, 20); |             //    "   Client Y: " + mouseY, 20, 20); | ||||||
|  |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user