forked from shin1m/Canvas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merged in pull request from original repo "Added OnClick and OnMouse …
…actions for Canvas BlazorExtensions#84"
- Loading branch information
Showing
14 changed files
with
121 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
@inherits BECanvasComponent | ||
|
||
<canvas id="@Id" width="@Width" height="@Height" @ref="_canvasRef"></canvas> | ||
<canvas id="@Id" width="@Width" height="@Height" @ref="_canvasRef" onclick="@OnClick" onmousedown="@OnMouseDown" onmousemove="@OnMouseMove" onmouseout="@OnMouseOut" onmouseover="@OnMouseOver" onmouseup="@OnMouseUp" onmousewheel="@OnMouseWheel"></canvas> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,4 +40,4 @@ | |
</Content> | ||
</ItemGroup> | ||
|
||
</Project> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,12 +39,12 @@ public enum LineJoin | |
Round, | ||
Bevel | ||
} | ||
|
||
public enum RepeatPattern | ||
{ | ||
Repeat = 0, | ||
RepeatX, | ||
RepeatY, | ||
NoRepeat | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/Blazor.Extensions.Canvas/Infrastructure/ImageDataArrayConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Buffers; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Blazor.Extensions.Canvas.Infrastructure | ||
{ | ||
class ImageDataArrayConverter : JsonConverter<byte[]> | ||
{ | ||
public override byte[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
Dictionary<string, byte> dictionary = JsonSerializer.Deserialize<Dictionary<string, byte>>(ref reader, options); | ||
return dictionary.Values.ToArray<byte>(); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, byte[] value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteStartObject(); | ||
for (int i = 0; i < value.Length; i++) | ||
{ | ||
writer.WritePropertyName(i.ToString()); | ||
JsonSerializer.Serialize(writer, value[i], options); | ||
} | ||
writer.WriteEndObject(); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Blazor.Extensions.Canvas/Infrastructure/ImageDataConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Blazor.Extensions.Canvas.Model; | ||
using System; | ||
using System.Buffers; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Blazor.Extensions.Canvas.Infrastructure | ||
{ | ||
class ImageDataConverter : JsonConverter<ImageData> | ||
{ | ||
public override ImageData Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
return JsonSerializer.Deserialize<ImageData>(ref reader, options); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, ImageData value, JsonSerializerOptions options) | ||
{ | ||
JsonSerializer.Serialize(writer, value, options); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Blazor.Extensions.Canvas.Infrastructure; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Blazor.Extensions.Canvas.Model | ||
{ | ||
public class ImageData | ||
{ | ||
[JsonPropertyName("data")] | ||
[JsonConverter(typeof(ImageDataArrayConverter))] | ||
public byte[] Data { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,4 +135,4 @@ public void Dispose() | |
|
||
#endregion | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.